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
|
|
|
|
|
|
|
|
if not test -f $queue
|
|
|
|
touch $queue
|
|
|
|
end
|
|
|
|
|
2022-02-28 08:13:49 +00:00
|
|
|
while read -P 'url(s)/command (play)> ' -l video
|
|
|
|
switch $video
|
|
|
|
case cl clear
|
|
|
|
clear
|
|
|
|
case c copy
|
|
|
|
set -l video (fromcb)
|
2022-09-23 05:34:50 +00:00
|
|
|
string split ' ' $video >>$queue
|
2022-02-28 08:13:49 +00:00
|
|
|
case d destroy
|
2022-09-23 05:34:50 +00:00
|
|
|
rm -r $queue
|
2022-03-09 21:29:18 +00:00
|
|
|
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-09-23 05:34:50 +00:00
|
|
|
case q quit
|
|
|
|
return
|
2022-02-28 08:13:49 +00:00
|
|
|
case p play
|
2022-03-09 21:29:18 +00:00
|
|
|
tmux attach -t ytmpv
|
2022-09-23 05:34:50 +00:00
|
|
|
tmux new-session -s ytmpv -- \
|
|
|
|
mpv \
|
|
|
|
--ytdl \
|
|
|
|
--save-position-on-quit \
|
|
|
|
--playlist=$queue
|
2022-03-09 21:29:18 +00:00
|
|
|
break
|
2022-09-23 05:34:50 +00:00
|
|
|
case pl play-login
|
|
|
|
read -P 'username> ' -l username
|
|
|
|
read -P 'password> ' -s -l password
|
|
|
|
|
|
|
|
tmux attach -t ytmpv
|
|
|
|
tmux new-session -s ytmpv -- \
|
|
|
|
mpv \
|
|
|
|
--ytdl \
|
|
|
|
--ytdl-raw-options=username=$username,password=$password \
|
|
|
|
--save-position-on-quit \
|
|
|
|
--playlist=$queue
|
|
|
|
|
|
|
|
break
|
|
|
|
case s stream
|
2022-03-09 21:29:18 +00:00
|
|
|
tmux attach -t ytmpv
|
2022-09-23 05:34:50 +00:00
|
|
|
tmux new-session -s ytmpv -- \
|
|
|
|
streamlink \
|
|
|
|
--player mpv \
|
|
|
|
(cat $queue) \
|
|
|
|
best
|
2022-02-28 08:13:49 +00:00
|
|
|
break
|
|
|
|
case '*'
|
2022-03-09 21:29:18 +00:00
|
|
|
if test -z "$video"
|
|
|
|
tmux attach -t ytmpv
|
2022-09-23 05:34:50 +00:00
|
|
|
tmux new-session -s ytmpv -- \
|
|
|
|
mpv \
|
|
|
|
--ytdl \
|
|
|
|
--save-position-on-quit \
|
|
|
|
--playlist=$queue
|
2022-03-09 21:29:18 +00:00
|
|
|
break
|
|
|
|
end
|
|
|
|
|
2022-09-23 05:34:50 +00:00
|
|
|
string split ' ' $video >>$queue
|
2022-02-28 08:13:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
ytmpv
|
|
|
|
end
|