add audio only
This commit is contained in:
parent
3f5211e0b1
commit
ac9aa8c0db
2 changed files with 54 additions and 14 deletions
24
README.org
24
README.org
|
|
@ -39,7 +39,7 @@ This function prints the usage of the script.
|
||||||
|
|
||||||
#+begin_src sh
|
#+begin_src sh
|
||||||
function print_usage {
|
function print_usage {
|
||||||
echo "tyt [ (-a* | --alternative) | (-i | --interactive) ] \"QUERY\""
|
echo "tyt [ (-a* | --alternative) | (-i | --interactive) | (-m | --music) ] \"QUERY\""
|
||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
|
@ -50,6 +50,7 @@ We have the following flags:
|
||||||
|
|
||||||
- =a*|alternative= :: Alternative video (optional); You can parse any amount of alternatives (e.g. =-aaa=)
|
- =a*|alternative= :: Alternative video (optional); You can parse any amount of alternatives (e.g. =-aaa=)
|
||||||
- =i|interactive= :: Interactive mode; Shows the first 10 results and queries for a selection; If this flag is set, =-a= is ignored
|
- =i|interactive= :: Interactive mode; Shows the first 10 results and queries for a selection; If this flag is set, =-a= is ignored
|
||||||
|
- =m|music= :: Play only the audio track of the video
|
||||||
|
|
||||||
Additionally we have exacly one mandatory quoted string as query.
|
Additionally we have exacly one mandatory quoted string as query.
|
||||||
|
|
||||||
|
|
@ -57,6 +58,7 @@ Additionally we have exacly one mandatory quoted string as query.
|
||||||
alternative=0
|
alternative=0
|
||||||
format="flac"
|
format="flac"
|
||||||
interactive=false
|
interactive=false
|
||||||
|
music=false
|
||||||
help=false
|
help=false
|
||||||
|
|
||||||
for arg in "$@"
|
for arg in "$@"
|
||||||
|
|
@ -75,6 +77,10 @@ Additionally we have exacly one mandatory quoted string as query.
|
||||||
interactive=true
|
interactive=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-m|--music)
|
||||||
|
music=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
help=true
|
help=true
|
||||||
shift
|
shift
|
||||||
|
|
@ -104,12 +110,22 @@ Additionally we have exacly one mandatory quoted string as query.
|
||||||
*** Greeter
|
*** Greeter
|
||||||
|
|
||||||
If the arguments match, print a greeter.
|
If the arguments match, print a greeter.
|
||||||
|
Another greeter is printed if the flag =-m= is set.
|
||||||
|
Make sure your terminal emulator supports Unicode to see the notes.
|
||||||
|
|
||||||
#+begin_src sh
|
#+begin_src sh
|
||||||
|
if [ "$music" = false ]
|
||||||
|
then
|
||||||
echo -ne "\n \e[1m\ /\e[0m\n"
|
echo -ne "\n \e[1m\ /\e[0m\n"
|
||||||
echo -ne " \e[1m=======\e[0m\n"
|
echo -ne " \e[1m=======\e[0m\n"
|
||||||
echo -ne " \e[1m| \e[31mtyt\e[0m \e[1m|\e[0m\n"
|
echo -ne " \e[1m| \e[31mtyt\e[0m \e[1m|\e[0m\n"
|
||||||
echo -ne " \e[1m=======\e[0m\n\n"
|
echo -ne " \e[1m=======\e[0m\n\n"
|
||||||
|
else
|
||||||
|
echo -ne "\n \e[1m\ /\e[0m ♫\n"
|
||||||
|
echo -ne " \e[1m=======\e[0m ♫\n"
|
||||||
|
echo -ne " \e[1m| \e[31mtyt\e[0m \e[1m|\e[0m\n"
|
||||||
|
echo -ne " \e[1m=======\e[0m\n\n"
|
||||||
|
fi
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Get URL
|
*** Get URL
|
||||||
|
|
@ -203,8 +219,14 @@ If the interactive flag is present, show the first ten results and query for a v
|
||||||
*** Play video
|
*** Play video
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
#+begin_src sh
|
#+begin_src sh
|
||||||
echo -ne "Playing: \e[32m\e[1m$title\e[0m (\e[33m\e[1m$uploader\e[0m)\n"
|
echo -ne "Playing: \e[32m\e[1m$title\e[0m (\e[33m\e[1m$uploader\e[0m)\n"
|
||||||
|
if [ "$music" = true ]
|
||||||
|
then
|
||||||
|
mpv --no-video $url &> /dev/null
|
||||||
|
else
|
||||||
mpv $url &> /dev/null
|
mpv $url &> /dev/null
|
||||||
|
fi
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
|
||||||
30
tyt
30
tyt
|
|
@ -10,12 +10,13 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function print_usage {
|
function print_usage {
|
||||||
echo "tyt [ (-a* | --alternative) | (-i | --interactive) ] \"QUERY\""
|
echo "tyt [ (-a* | --alternative) | (-i | --interactive) | (-m | --music) ] \"QUERY\""
|
||||||
}
|
}
|
||||||
|
|
||||||
alternative=0
|
alternative=0
|
||||||
format="flac"
|
format="flac"
|
||||||
interactive=false
|
interactive=false
|
||||||
|
music=false
|
||||||
help=false
|
help=false
|
||||||
|
|
||||||
for arg in "$@"
|
for arg in "$@"
|
||||||
|
|
@ -34,6 +35,10 @@ do
|
||||||
interactive=true
|
interactive=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-m|--music)
|
||||||
|
music=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
help=true
|
help=true
|
||||||
shift
|
shift
|
||||||
|
|
@ -59,10 +64,18 @@ fi
|
||||||
|
|
||||||
query="${other_arguments[0]}"
|
query="${other_arguments[0]}"
|
||||||
|
|
||||||
echo -ne "\n \e[1m\ /\e[0m\n"
|
if [ "$music" = false ]
|
||||||
echo -ne " \e[1m=======\e[0m\n"
|
then
|
||||||
echo -ne " \e[1m| \e[31mtyt\e[0m \e[1m|\e[0m\n"
|
echo -ne "\n \e[1m\ /\e[0m\n"
|
||||||
echo -ne " \e[1m=======\e[0m\n\n"
|
echo -ne " \e[1m=======\e[0m\n"
|
||||||
|
echo -ne " \e[1m| \e[31mtyt\e[0m \e[1m|\e[0m\n"
|
||||||
|
echo -ne " \e[1m=======\e[0m\n\n"
|
||||||
|
else
|
||||||
|
echo -ne "\n \e[1m\ /\e[0m ♫\n"
|
||||||
|
echo -ne " \e[1m=======\e[0m ♫\n"
|
||||||
|
echo -ne " \e[1m| \e[31mtyt\e[0m \e[1m|\e[0m\n"
|
||||||
|
echo -ne " \e[1m=======\e[0m\n\n"
|
||||||
|
fi
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
|
|
||||||
|
|
@ -139,4 +152,9 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -ne "Playing: \e[32m\e[1m$title\e[0m (\e[33m\e[1m$uploader\e[0m)\n"
|
echo -ne "Playing: \e[32m\e[1m$title\e[0m (\e[33m\e[1m$uploader\e[0m)\n"
|
||||||
mpv $url &> /dev/null
|
if [ "$music" = true ]
|
||||||
|
then
|
||||||
|
mpv --no-video $url &> /dev/null
|
||||||
|
else
|
||||||
|
mpv $url &> /dev/null
|
||||||
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue