add more functions to yt

This commit is contained in:
randomuser 2020-12-20 11:50:47 -06:00
parent 66ce84a309
commit f7e4897de8
1 changed files with 14 additions and 2 deletions

16
yt
View File

@ -1,11 +1,11 @@
#!/bin/sh #!/bin/sh
DATFILE="~/.config/youtube" DATFILE="~/.config/youtube/dat"
CACHEDIR="~/.config/youtube/cache" CACHEDIR="~/.config/youtube/cache"
tmp1=$(mktemp) tmp1=$(mktemp)
tmp2=$(mktemp) tmp2=$(mktemp)
mkdir -p $DATFILE touch $DATFILE
mkdir -p $CACHEDIR mkdir -p $CACHEDIR
sync () { sync () {
@ -24,10 +24,22 @@ display () {
done done
cat $tmp1 $tmp2 | pr -2t -s" | " cat $tmp1 $tmp2 | pr -2t -s" | "
} }
add () { # $1: name of channel id
printf "%s\n" $1 >> $DATFILE
}
del () { # $1: line number of channel id
sed -i "${1}d" $DATFILE
}
case $1 in case $1 in
*"sync"*) *"sync"*)
sync sync
;; ;;
*"add"*)
[ $# -eq 2 ] && add $2
;;
*"del"*)
[ $# -eq 2 ] && del $2
;;
*) *)
display display
;; ;;