continue to query in interaction mode

This commit is contained in:
Denis Lehmann 2021-03-15 17:16:35 +01:00
parent b4eb6c948f
commit 6b5656ce8f
2 changed files with 72 additions and 10 deletions

View file

@ -232,12 +232,44 @@ If the interactive flag is present, show the first ten results and query for a v
Finally the video is played via mpv. Finally the video is played via mpv.
If the =-m= flag is set, only the audio track is played. If the =-m= flag is set, only the audio track is played.
In interaction mode, another video is queried to be played.
#+begin_src bash #+begin_src bash
echo -ne "Playing: \e[32m\e[1m$title\e[0m (\e[33m\e[1m$uploader\e[0m)\n" function play {
if [ "$music" = true ] echo -ne "Playing: \e[32m\e[1m$2\e[0m (\e[33m\e[1m$3\e[0m)\n"
if [ "$music" = true ]
then
mpv --no-video $1 &> /dev/null
else
mpv $1 &> /dev/null
fi
}
play "$url" "$title" "$uploader"
if [ "$interactive" = true ]
then then
mpv --no-video $url &> /dev/null quit=false
else selections=(0 1 2 3 4 5 6 7 8 9 q)
mpv $url &> /dev/null while [ ! "$quit" = true ]
do
echo -ne "\nSelect another or press [q] to quit: "
read selection
while [[ ! "${selections[@]}" =~ "${selection}" ]]
do
echo -ne "Not valid, try again: "
read selection
done
if [ ! "$selection" = "q" ]
then
echo ""
url=${urls[$selection]}
title=${titles[$selection]}
uploader=${uploaders[$selection]}
play "$url" "$title" "$uploader"
else
quit=true
fi
done
fi fi
#+end_src #+end_src

40
tyt
View file

@ -162,10 +162,40 @@ else
uploader=${uploaders[$alternative]} uploader=${uploaders[$alternative]}
fi fi
echo -ne "Playing: \e[32m\e[1m$title\e[0m (\e[33m\e[1m$uploader\e[0m)\n" function play {
if [ "$music" = true ] echo -ne "Playing: \e[32m\e[1m$2\e[0m (\e[33m\e[1m$3\e[0m)\n"
if [ "$music" = true ]
then
mpv --no-video $1 &> /dev/null
else
mpv $1 &> /dev/null
fi
}
play "$url" "$title" "$uploader"
if [ "$interactive" = true ]
then then
mpv --no-video $url &> /dev/null quit=false
else selections=(0 1 2 3 4 5 6 7 8 9 q)
mpv $url &> /dev/null while [ ! "$quit" = true ]
do
echo -ne "\nSelect another or press [q] to quit: "
read selection
while [[ ! "${selections[@]}" =~ "${selection}" ]]
do
echo -ne "Not valid, try again: "
read selection
done
if [ ! "$selection" = "q" ]
then
echo ""
url=${urls[$selection]}
title=${titles[$selection]}
uploader=${uploaders[$selection]}
play "$url" "$title" "$uploader"
else
quit=true
fi
done
fi fi