Improve ytmpv and redisco

This commit is contained in:
mitchell 2022-09-23 01:34:50 -04:00
parent 0978eb701f
commit e8e8b4ba3d
3 changed files with 54 additions and 37 deletions

View File

@ -1,8 +1,20 @@
function redisco function redisco
while pgrep Discord >/dev/null 2>&1 set -l to_kill discord
pkill Discord
sleep 1 if test -n "$argv"
set to_kill $argv
end end
discord >/dev/null 2>&1 & disown pgrep -fia $to_kill
or return
read -P 'continue? [Y/n]> ' -l confirm
if test "$confirm" = 'n'
return
end
pkill -fi $to_kill
nohup $to_kill &> /dev/null & disown
end end

View File

@ -1,39 +1,19 @@
function ytmpv -d 'A script to help queue youtube videos on MPV' function ytmpv -d 'A script to help queue youtube videos on MPV'
set -l queue ~/.ytmpv_queue set -l queue ~/.ytmpv_queue
set -l downloads ~/.ytmpv_downloads/
if not test -f $queue if not test -f $queue
touch $queue touch $queue
end end
if not test -d $downloads
mkdir $downloads
end
while read -P 'url(s)/command (play)> ' -l video while read -P 'url(s)/command (play)> ' -l video
switch $video switch $video
case cl clear case cl clear
clear clear
case c copy case c copy
set -l video (fromcb) set -l video (fromcb)
string split ' ' $video >> $queue string split ' ' $video >>$queue
case d destroy case d destroy
rm -r $queue $downloads rm -r $queue
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 break
case e edit case e edit
$EDITOR $queue $EDITOR $queue
@ -43,24 +23,49 @@ function ytmpv -d 'A script to help queue youtube videos on MPV'
functions ytmpv functions ytmpv
case l list case l list
cat $queue cat $queue
case p play
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
break
case q quit case q quit
return 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 '*' case '*'
if test -z "$video" if test -z "$video"
tmux attach -t ytmpv tmux attach -t ytmpv
tmux new-session -s ytmpv -- mpv --save-position-on-quit --playlist=$queue tmux new-session -s ytmpv -- \
mpv \
--ytdl \
--save-position-on-quit \
--playlist=$queue
break break
end end
string split ' ' $video >> $queue string split ' ' $video >>$queue
end end
end end

View File

@ -1,2 +1,2 @@
#!/usr/bin/env fish #!/usr/bin/env fish
redisco kitty fish -c "redisco $argv"