mirror of https://github.com/mitchell/dotfiles.git
74 lines
2.1 KiB
Fish
74 lines
2.1 KiB
Fish
function ytmpv -d 'A script to help queue youtube videos on MPV'
|
|
set -l queue ~/.ytmpv_queue
|
|
|
|
if not test -f $queue
|
|
touch $queue
|
|
end
|
|
|
|
while read -P 'url(s)/command (play)> ' -l video
|
|
switch $video
|
|
case cl clear
|
|
clear
|
|
case c copy
|
|
set -l video (fromcb)
|
|
string split ' ' $video >>$queue
|
|
case d destroy
|
|
rm -r $queue
|
|
break
|
|
case e edit
|
|
$EDITOR $queue
|
|
case f fg
|
|
tmux attach -t ytmpv
|
|
case h help
|
|
functions ytmpv
|
|
case l list
|
|
cat $queue
|
|
case q quit
|
|
return
|
|
case p play
|
|
tmux attach -t ytmpv
|
|
tmux new-session -s ytmpv -- \
|
|
mpv \
|
|
--ytdl \
|
|
--save-position-on-quit \
|
|
--playlist=$queue
|
|
break
|
|
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
|
|
tmux attach -t ytmpv
|
|
tmux new-session -s ytmpv -- \
|
|
streamlink \
|
|
--player mpv \
|
|
(cat $queue) \
|
|
best
|
|
break
|
|
case '*'
|
|
if test -z "$video"
|
|
tmux attach -t ytmpv
|
|
tmux new-session -s ytmpv -- \
|
|
mpv \
|
|
--ytdl \
|
|
--save-position-on-quit \
|
|
--playlist=$queue
|
|
break
|
|
end
|
|
|
|
string split ' ' $video >>$queue
|
|
end
|
|
end
|
|
|
|
ytmpv
|
|
end
|