diff options
| author | iceyrazor <iceyrazor@mailfence.com> | 2026-05-24 01:25:07 -0500 |
|---|---|---|
| committer | iceyrazor <iceyrazor@mailfence.com> | 2026-05-24 01:25:07 -0500 |
| commit | d4e34ad096cfc15b9c537463dd3c08becc5dc84e (patch) | |
| tree | 5f5a90c64a4cc07898f5a6579538fb985b5686fb | |
| parent | 431ffd2edf3d52bbe8b7999dbd4f771d236fa065 (diff) | |
posix shell changes
removed ls | grep
fixed miss spelled word
| -rwxr-xr-x | fetch.sh | 37 | ||||
| -rwxr-xr-x | getyt | 18 | ||||
| -rwxr-xr-x | getytmd | 8 | ||||
| -rwxr-xr-x | preview.sh | 10 | ||||
| -rwxr-xr-x | watch.sh | 2 |
5 files changed, 40 insertions, 35 deletions
@@ -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 @@ -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 @@ -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 - \n" "$item" "$ytid" "$thumb" >> ytlist-thumb.md done @@ -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" @@ -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;' |
