Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- Check()
- {
- [[ -z "${1// }" ]] && printf "Empty argument or spaces!\n" && exit
- }
- Artist()
- {
- printf "Enter mode\n 1 - search\n 2 - discography\n 3 - top\n"
- read mode
- Check $mode
- case "$mode" in
- "1" ) url="http://localhost:9999/get_by_search?type=artist&artist=${1// /%20}";;
- "2" ) id=$(curl -L# "http://localhost:9999/search_id?type=artist&artist=$1")
- url="http://localhost:9999/get_discography_artist?id=$id";;
- "3" ) id=$(curl -L# "http://localhost:9999/search_id?type=artist&artist=$1")
- url="http://localhost:9999/get_top_tracks_artist?id=$id&type=artist";;
- esac
- }
- Search()
- {
- printf "\nEnter $1\n"
- read data
- Check $data
- case "$1" in
- "artist" ) Artist $data;;
- "album" ) id=$(curl -L# "http://localhost:9999/search_id?type=album&title=${data// /%20}")
- [[ -z "${id// }" ]] && printf "No matches found\n" && exit
- url="http://localhost:9999/get_album?id=$id";;
- "song" ) id=$(curl -L# "http://localhost:9999/search_id?type=song&title=${data// /%20}")
- [[ -z "${id// }" ]] && printf "No matches found\n" && exit
- url="http://localhost:9999/get_song?id=$id";;
- "matches" ) exit
- esac
- curl -s $url > /var/lib/mpd/playlists/${data// /_}.m3u
- mpc load ${data// /_}
- }
- printf "GMusicProxy-mpc brigde by Essir\n"
- mode=0
- while [ "$mode" != "exit" ]
- do
- printf "Enter:\n 1 - Artist\n 2 - Album\n 3 - Song\n 4 - Any matches\n exit - obviosly\n"
- read mode
- Check $mode
- case "$mode" in
- "1" ) Search "artist";;
- "2" ) Search "album";;
- "3" ) Search "song";;
- "4" ) Search "matches";;
- esac
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement