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
while pgrep Discord >/dev/null 2>&1
pkill Discord
sleep 1
set -l to_kill discord
if test -n "$argv"
set to_kill $argv
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

View File

@ -1,39 +1,19 @@
function ytmpv -d 'A script to help queue youtube videos on MPV'
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
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
string split ' ' $video >>$queue
case d destroy
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
rm -r $queue
break
case e edit
$EDITOR $queue
@ -43,24 +23,49 @@ function ytmpv -d 'A script to help queue youtube videos on MPV'
functions ytmpv
case l list
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
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 --save-position-on-quit --playlist=$queue
tmux new-session -s ytmpv -- \
mpv \
--ytdl \
--save-position-on-quit \
--playlist=$queue
break
end
string split ' ' $video >> $queue
string split ' ' $video >>$queue
end
end

View File

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