init
This commit is contained in:
commit
ca584b8fd8
|
@ -0,0 +1,2 @@
|
||||||
|
*youtube_stuffs.db
|
||||||
|
thumbnails/**
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025 iceyrazor
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,36 @@
|
||||||
|
# youtube playlist cli
|
||||||
|
A simplish set of bash scripts to have a locally stored youtube playlist using fzf and sqlite3 with thumbnails
|
||||||
|
|
||||||
|
Technically you can modify this to store anything other than just yt videos
|
||||||
|
|
||||||
|
# download.
|
||||||
|
Just download this repo and rename youtube_stuffs.db.def to youtube_stuffs.db
|
||||||
|
|
||||||
|
# requirements
|
||||||
|
- bash
|
||||||
|
- fzf
|
||||||
|
- sqlite3
|
||||||
|
- sed
|
||||||
|
- youtube-dl
|
||||||
|
|
||||||
|
## optional requirements
|
||||||
|
- chafa # for image previews
|
||||||
|
- a terminal that works with chafa. i use wezterm
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
- have a playlist or video thats either unlisted or public.
|
||||||
|
- run ``fetch.sh "youtube url/playlist url" "playlist name"``.
|
||||||
|
that should pretty much do everything.
|
||||||
|
- check download_err.txt for download errors. Videos that are marked as nsfw and require sign in will NOT be added to the list and require manual intervention
|
||||||
|
- then ``get_yt2.sh.``.
|
||||||
|
if you want thumbnails ``get_yt2.sh 1``.
|
||||||
|
- if you want too then delete download.txt and download_err.txt and thumberr.txt
|
||||||
|
|
||||||
|
# config
|
||||||
|
- In ``get_yt2.sh`` there is the preview lines and columns. Idk if I can autodetect this because something something fzf doesn't do something something
|
||||||
|
- If you want to change anything else you would have to change the script. Feel free to make your own config system
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# todo
|
||||||
|
- auto detect detect last item in list when and before adding new item so thumbnails doesn't start at 1. Or async it or something idk
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# if a item on the db doesnt have a channel name. it will fetch it
|
||||||
|
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';')"
|
||||||
|
channelname="$(sqlite3 ./youtube_stuffs.db 'select channel from ytlist where rowid='$i';')"
|
||||||
|
if [ -z "$channelname" ]; then
|
||||||
|
setchannel=$(youtube-dl --get-filename -o "%(channel)s" "https://youtube.com/watch/?v=$urlid" | sed "s/'/''/g")
|
||||||
|
sqlite3 ./youtube_stuffs.db "update ytlist set channel='$setchannel' where rowid=$i;"
|
||||||
|
printf "$i::$urlid\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
((i=$i+1))
|
||||||
|
if (( $i >= $max + 1 )); then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
|
@ -0,0 +1,51 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# arg1 is the url and arg2 is the playlist name
|
||||||
|
# if arg1 is not defined. just fetch thumbnails
|
||||||
|
|
||||||
|
# cant do whats below because i need to replace all ' within a subset of 'string' with '' to escape it.
|
||||||
|
|
||||||
|
# youtube-dl --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")"
|
||||||
|
file="./download.txt"
|
||||||
|
|
||||||
|
if [ "$1" ]; then
|
||||||
|
[ -z "$2" ] && echo playlist not defined. continue? && read -p "continue? (press any key)"
|
||||||
|
youtube-dl --get-filename -o "%(title)s----%(id)s----%(channel)s" "$1" > "$file" 2> download_err.txt
|
||||||
|
printf "\n\n"
|
||||||
|
|
||||||
|
i=1
|
||||||
|
max=$(( $(wc -l "$file" | sed 's/ .*//g') ))
|
||||||
|
while :; do
|
||||||
|
printf "insert into ytlist values('$(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
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo ----PLAYLIST DONE
|
||||||
|
read -p "continue? (Y,n)" input
|
||||||
|
[ "$input" == "n" ] && exit 1;
|
||||||
|
[ "$input" == "N" ] && exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo ----Downloading Thumbnails
|
||||||
|
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"
|
||||||
|
thumbnailurl="$(youtube-dl --get-thumbnail "https://youtube.com/watch?v=$urlid" 2> thumberr.txt)"
|
||||||
|
ext="$(printf "$thumbnailurl" | sed 's/.*\.//g' | sed 's/?.*//')"
|
||||||
|
wget "$thumbnailurl" -O "thumbnails/$urlid.$ext"
|
||||||
|
fi
|
||||||
|
|
||||||
|
((i=$i+1))
|
||||||
|
if (( $i >= $max + 1 )); then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
FZF_PREVIEW_LINES=20
|
||||||
|
FZF_PREVIEW_COLUMN=3
|
||||||
|
|
||||||
|
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
has_chafa=$1
|
||||||
|
! command -v chafa >/dev/null && has_chafa=0
|
||||||
|
|
||||||
|
if [ "$has_chafa" == "1" ]; then
|
||||||
|
item="$(sqlite3 ./youtube_stuffs.db "select rowid,* from ytlist" | \
|
||||||
|
fzf --preview "./preview.sh {} | xargs chafa --clear -f iterm -s ${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" \
|
||||||
|
| sed 's/|.*//g')"
|
||||||
|
else
|
||||||
|
item="$(sqlite3 ./youtube_stuffs.db "select rowid,* from ytlist" | \
|
||||||
|
fzf \
|
||||||
|
| sed 's/|.*//g')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
url=$(sqlite3 ./youtube_stuffs.db "select id from ytlist where rowid=$item")
|
||||||
|
printf "https://youtube.com/watch?v=$url" | xclip -selection clipboard
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
rowid="$(echo $1 | sed 's/|.*//g')"
|
||||||
|
thumbnail="$(ls thumbnails/ | grep "$(sqlite3 ./youtube_stuffs.db "select id from ytlist where rowid=$rowid;").*" )"
|
||||||
|
printf "thumbnails/$thumbnail"
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
while :; do
|
||||||
|
clear
|
||||||
|
sqlite3 --markdown ./youtube_stuffs.db 'select * from ytlist order by rowid desc limit 30;'
|
||||||
|
sleep 3s
|
||||||
|
done
|
Binary file not shown.
Loading…
Reference in New Issue