Added commands to script.
This commit is contained in:
parent
d714a37953
commit
d6ad9cb833
42
play-lofi
42
play-lofi
@ -23,6 +23,19 @@
|
|||||||
|
|
||||||
link_file="$XDG_CONFIG_HOME/lofi-link"
|
link_file="$XDG_CONFIG_HOME/lofi-link"
|
||||||
|
|
||||||
|
print_help() {
|
||||||
|
echo "USAGE: play-lofi [commands]
|
||||||
|
A program to play a lofi stream from Invidious (a YouTube proxy). When
|
||||||
|
given no options, it plays from the stream URL in '\$XDG_CONFIG_HOME/
|
||||||
|
lofi-link'. If the file does not exist it will give you a selection of
|
||||||
|
streams to choose from.
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
new choose a new stream URL
|
||||||
|
set <url> set stream URL
|
||||||
|
help show this help information"
|
||||||
|
}
|
||||||
|
|
||||||
new_link() {
|
new_link() {
|
||||||
local results=$(curl -s "https://invidio.us/search?q=lofi+radio" |
|
local results=$(curl -s "https://invidio.us/search?q=lofi+radio" |
|
||||||
grep "<p>.*watch" | tr -d "\n" | tr -s " ")
|
grep "<p>.*watch" | tr -d "\n" | tr -s " ")
|
||||||
@ -55,6 +68,35 @@ new_link() {
|
|||||||
echo $link > $link_file
|
echo $link > $link_file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# argument parsing
|
||||||
|
if [ "$#" -eq "1" ]
|
||||||
|
then
|
||||||
|
case $1 in
|
||||||
|
"help")
|
||||||
|
print_help
|
||||||
|
exit 0;;
|
||||||
|
"new")
|
||||||
|
new_link;;
|
||||||
|
*)
|
||||||
|
echo "Unknown command '$1'. Run 'play-lofi help' for a list of commands."
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
elif [ "$#" -eq "2" ]
|
||||||
|
then
|
||||||
|
if [ "$1" = "set" ]
|
||||||
|
then
|
||||||
|
echo "$2" > $link_file
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Unknown command '$1 $2'. Run 'play-lofi help' for a list of commands."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
elif [ "$#" -gt "2" ]
|
||||||
|
then
|
||||||
|
echo "Too many arguments. Run 'play-lofi help' for a list of commands."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# check for link file
|
# check for link file
|
||||||
if ! [ -e "$link_file" ]
|
if ! [ -e "$link_file" ]
|
||||||
then
|
then
|
||||||
|
Loading…
Reference in New Issue
Block a user