2022-02-28 08:13:49 +00:00
|
|
|
function ytmpv -d 'A script to help queue youtube videos on MPV'
|
2022-03-09 21:29:18 +00:00
|
|
|
set -l queue ~/.ytmpv_queue
|
|
|
|
set -l downloads ~/.ytmpv_downloads/
|
|
|
|
|
|
|
|
if not test -f $queue
|
|
|
|
touch $queue
|
|
|
|
end
|
|
|
|
|
|
|
|
if not test -d $downloads
|
|
|
|
mkdir $downloads
|
2022-02-28 08:13:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
while read -P 'url(s)/command (play)> ' -l video
|
|
|
|
switch $video
|
|
|
|
case cl clear
|
|
|
|
clear
|
|
|
|
case c copy
|
|
|
|
set -l video (fromcb)
|
2022-03-09 21:29:18 +00:00
|
|
|
string split ' ' $video >> $queue
|
2022-02-28 08:13:49 +00:00
|
|
|
case d destroy
|
2022-03-09 21:29:18 +00:00
|
|
|
rm -r $queue $downloads
|
|
|
|
break
|
|
|
|
case dl download
|
|
|
|
set -l urls (cat $queue)
|
|
|
|
read -P 'username> ' -l username
|
|
|
|
read -P 'password> ' -s -l password
|
|
|
|
|
|
|
|
tmux attach -t ytdlp
|
|
|
|
tmux new-session -s ytdlp -- \
|
|
|
|
yt-dlp \
|
|
|
|
--username="$username" \
|
|
|
|
--password="$password" \
|
|
|
|
--paths=$downloads \
|
|
|
|
--write-subs \
|
|
|
|
$urls
|
|
|
|
|
|
|
|
break
|
2022-05-12 23:08:48 +00:00
|
|
|
case e edit
|
|
|
|
$EDITOR $queue
|
2022-02-28 08:13:49 +00:00
|
|
|
case f fg
|
|
|
|
tmux attach -t ytmpv
|
|
|
|
case h help
|
|
|
|
functions ytmpv
|
|
|
|
case l list
|
2022-03-09 21:29:18 +00:00
|
|
|
cat $queue
|
2022-02-28 08:13:49 +00:00
|
|
|
case p play
|
2022-03-09 21:29:18 +00:00
|
|
|
tmux attach -t ytmpv
|
|
|
|
tmux new-session -s ytmpv -- mpv --save-position-on-quit --playlist=$queue
|
|
|
|
break
|
|
|
|
case pdl play-downloads
|
|
|
|
tmux attach -t ytmpv
|
|
|
|
tmux new-session -s ytmpv -- mpv --save-position-on-quit $downloads
|
2022-02-28 08:13:49 +00:00
|
|
|
break
|
|
|
|
case q quit
|
|
|
|
return
|
|
|
|
case '*'
|
2022-03-09 21:29:18 +00:00
|
|
|
if test -z "$video"
|
|
|
|
tmux attach -t ytmpv
|
|
|
|
tmux new-session -s ytmpv -- mpv --save-position-on-quit --playlist=$queue
|
|
|
|
break
|
|
|
|
end
|
|
|
|
|
|
|
|
string split ' ' $video >> $queue
|
2022-02-28 08:13:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
ytmpv
|
|
|
|
end
|