aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfetch.sh37
-rwxr-xr-xgetyt18
-rwxr-xr-xgetytmd8
-rwxr-xr-xpreview.sh10
-rwxr-xr-xwatch.sh2
5 files changed, 40 insertions, 35 deletions
diff --git a/fetch.sh b/fetch.sh
index d7a7e61..446e150 100755
--- a/fetch.sh
+++ b/fetch.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# arg1 is the url and arg2 is the playlist name
# if arg1 is not defined. just fetch thumbnails
@@ -7,13 +7,14 @@
# yt-dlp --get-filename -o "insert into ytlist values('%(title)s','%(channel)s','%(id)s','shorts','');" "https://www.youtube.com/playlist?list=PLwpvCCyacwS9Us6F1_UUUre1Py9p4ex4J" 2> out2.txt #| sed "s/'/''/g" #| sqlite3 ./youtube_stuffs.db
-cd "$(dirname "$0")"
+cd "$(dirname "$0")" || exit
file="./download.txt"
+emptyvar=""
-[ "$3" == "t" ] && Cookies="--cookies cookies.txt"
+[ "$3" = "t" ] && Cookies="--cookies cookies.txt"
if [ "$1" ]; then
- [ -z "$2" ] && echo playlist not defined. continue? && read -p "continue? (press any key)"
+ [ -z "$2" ] && echo playlist not defined. continue? && printf "continue? (press any key)" && read -r emptyvar
yt-dlp $Cookies --get-filename -o "%(title)s----%(id)s----%(channel)s" "$1" > "$file" 2> download_err.txt
printf "\n\n"
@@ -23,16 +24,17 @@ if [ "$1" ]; then
printf -- "insert into ytlist values('%s','%s','')" "$(head -n $i $file | tail -n 1 | sed "s/'/''/g" | sed "s/----/','/g" )" "$2"
printf "\n"
printf -- "insert into ytlist values('%s','%s','')" "$(head -n $i $file | tail -n 1 | sed "s/'/''/g" | sed "s/----/','/g" )" "$2" | sqlite3 ./youtube_stuffs.db
- printf "insert: $i\n"
- ((i=$i+1))
- if (( $i >= $max + 1 )); then
+ printf "insert: %s\n" "%i"
+ i=$((i+1))
+ if [ $i -gt $max ]; then
break
fi
done
echo ----PLAYLIST DONE
- read -p "continue? (Y,n)" input
- [ "$input" == "n" ] && exit 1;
- [ "$input" == "N" ] && exit 1;
+ printf "continue? (Y,n)"
+ read -r input
+ [ "$input" = "n" ] && exit 1;
+ [ "$input" = "N" ] && exit 1;
fi
@@ -41,19 +43,20 @@ i=1
max=$(( $(sqlite3 ./youtube_stuffs.db 'select rowid from ytlist order by rowid desc limit 1;') ))
while :; do
urlid="$(sqlite3 ./youtube_stuffs.db 'select id from ytlist where rowid='$i';')"
- if [ -z "$(ls -l thumbnails | grep ".$urlid")" ]; then
- printf "$i::$urlid\n"
+
+ if [ "$urlid" ] && [ ! -e "./thumbnails/$urlid."* ]; then
+ printf "%s::%s\n" "$i" "$urlid"
thumbnailurl="$(yt-dlp $Cookies --get-thumbnail "https://youtube.com/watch?v=$urlid" 2>> thumberr.txt)"
- if [ ! "$thumbnailurl" == "" ]; then
- ext="$(printf "$thumbnailurl" | sed 's/.*\.//g' | sed 's/?.*//')"
+ if [ ! "$thumbnailurl" = "" ]; then
+ ext="$(printf -- "%s" "$thumbnailurl" | sed 's/.*\.//g' | sed 's/?.*//')"
wget "$thumbnailurl" -O "thumbnails/$urlid.$ext"
else
- echo could not download thumbnail $urlid
+ printf "could not download thumbnail %s\n" "$urlid"
fi
fi
- ((i=$i+1))
- if (( $i >= $max + 1 )); then
+ i=$((i+1))
+ if [ $i -gt $max ]; then
break
fi
done
diff --git a/getyt b/getyt
index 5ea79e9..2ea3d6f 100755
--- a/getyt
+++ b/getyt
@@ -1,15 +1,17 @@
-#!/bin/bash
+#!/bin/sh
FZF_PREVIEW_LINES=20
-FZF_PREVIEW_COLUMN=3
+FZF_PREVIEW_COLUMNS=50
-cd "$(dirname "$0")"
+cd "$(dirname "$0")" || exit
has_chafa=0
while getopts "c" opt; do
case "$opt" in
- c) has_chafa=1
+ c) has_chafa=1;
+ break;
;;
+ *) break;;
esac
done
@@ -21,14 +23,14 @@ shift $((OPTIND-1))
playlist=$1
-if [ "$playlist" == "" ]; then
+if [ "$playlist" = "" ]; then
item="$(sqlite3 ./youtube_stuffs.db "select rowid,* from ytlist")"
else
item="$(sqlite3 ./youtube_stuffs.db "select rowid,* from ytlist where category='$playlist'")"
fi
-if [ "$has_chafa" == "1" ]; then
+if [ "$has_chafa" = "1" ]; then
item="$( printf -- "%s" "$item" | \
fzf --preview "./preview.sh {} | xargs chafa --clear -f sixel -s ${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" \
| sed -- 's/|.*//g')"
@@ -41,7 +43,7 @@ fi
url=$(sqlite3 ./youtube_stuffs.db "select id from ytlist where rowid=$item")
if [ -z "$WAYLAND_DISPLAY" ]; then
- printf "https://youtube.com/watch?v=$url" | xclip -selection clipboard
+ printf -- "https://youtube.com/watch?v=%s" "$url" | xclip -selection clipboard
else
- printf "https://youtube.com/watch?v=$url" | wl-copy
+ printf -- "https://youtube.com/watch?v=%s" "$url" | wl-copy
fi
diff --git a/getytmd b/getytmd
index 4c9a563..93cbfa4 100755
--- a/getytmd
+++ b/getytmd
@@ -1,9 +1,9 @@
-#!/bin/bash
-script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+#!/bin/sh
+script_dir="$( cd "$( dirname "$0" )" > /dev/null 2>&1 && pwd )"
playlist=$1
-if [ "$playlist" == "" ]; then
+if [ "$playlist" = "" ]; then
ytid_arr="$(sqlite3 "$script_dir/youtube_stuffs.db" "select id from ytlist")"
else
ytid_arr="$(sqlite3 "$script_dir/youtube_stuffs.db" "select id from ytlist where category='$playlist'")"
@@ -15,7 +15,7 @@ printf "# yt list gen\n\n" > ytlist-thumb.md
for ytid in $ytid_arr; do
item="$(sqlite3 -- "$script_dir/youtube_stuffs.db" "select rowid,title from ytlist where id='$ytid'" | sed 's/*/\\*/g')"
- thumb="$(find -- $script_dir/thumbnails/$ytid*)"
+ thumb="$(find -- "$script_dir"/thumbnails/"$ytid"*)"
printf -- "- [%s](https://youtube.com/watch?v=%s)\n" "$item" "$ytid" >> ytlist.md
printf -- "- [%s](https://youtube.com/watch?v=%s)\n - ![thumb](%s)\n" "$item" "$ytid" "$thumb" >> ytlist-thumb.md
done
diff --git a/preview.sh b/preview.sh
index 9c3ba40..7d7990a 100755
--- a/preview.sh
+++ b/preview.sh
@@ -1,5 +1,5 @@
-#!/bin/bash
-cd "$(dirname "$0")"
-rowid="$(echo $1 | sed 's/|.*//g')"
-thumbnail="$(ls thumbnails/ | grep -e "$(sqlite3 ./youtube_stuffs.db "select id from ytlist where rowid=$rowid;").*" )"
-printf "thumbnails/$thumbnail"
+#!/bin/sh
+cd "$(dirname "$0")" || exit
+rowid="$(echo "$1" | sed 's/|.*//g')"
+thumbnail="$(find thumbnails/"$(sqlite3 ./youtube_stuffs.db "select id from ytlist where rowid=$rowid;")"* )"
+printf -- "%s" "$thumbnail"
diff --git a/watch.sh b/watch.sh
index 2b0b318..dbdf218 100755
--- a/watch.sh
+++ b/watch.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
while :; do
clear
sqlite3 --markdown ./youtube_stuffs.db 'select * from ytlist order by rowid desc limit 30;'