Advertisement
Guest User

GMusicProxy-mpd prealpha

a guest
Nov 22nd, 2016
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.52 KB | None | 0 0
  1. #!/bin/bash
  2. Check()
  3. {
  4. [[ -z "${1// }" ]] &&   printf "Empty argument or spaces!\n" && exit
  5. }
  6.  
  7. Artist()
  8. {
  9. printf "Enter mode\n 1 - search\n 2 - discography\n 3 - top\n"
  10. read mode
  11. Check $mode
  12. case "$mode" in
  13.     "1" )   url="http://localhost:9999/get_by_search?type=artist&artist=${1// /%20}";;
  14.     "2" )   id=$(curl -L# "http://localhost:9999/search_id?type=artist&artist=$1")
  15.         url="http://localhost:9999/get_discography_artist?id=$id";;
  16.     "3" )   id=$(curl -L# "http://localhost:9999/search_id?type=artist&artist=$1")
  17.         url="http://localhost:9999/get_top_tracks_artist?id=$id&type=artist";;
  18. esac
  19. }
  20.  
  21. Search()
  22. {
  23. printf "\nEnter $1\n"
  24. read data
  25. Check $data
  26. case "$1" in
  27.     "artist" )  Artist $data;;
  28.     "album"  )  id=$(curl -L# "http://localhost:9999/search_id?type=album&title=${data// /%20}")
  29.             [[ -z "${id// }" ]] && printf "No matches found\n" && exit
  30.             url="http://localhost:9999/get_album?id=$id";;
  31.     "song" )    id=$(curl -L# "http://localhost:9999/search_id?type=song&title=${data// /%20}")
  32.             [[ -z "${id// }" ]] && printf "No matches found\n" && exit
  33.             url="http://localhost:9999/get_song?id=$id";;
  34.     "matches" ) exit
  35. esac
  36. curl -s $url > /var/lib/mpd/playlists/${data// /_}.m3u
  37. mpc load ${data// /_}
  38. }
  39.  
  40. printf "GMusicProxy-mpc brigde by Essir\n"
  41. mode=0
  42. while [ "$mode" != "exit" ]
  43. do
  44. printf "Enter:\n 1 - Artist\n 2 - Album\n 3 - Song\n 4 - Any matches\n exit - obviosly\n"
  45. read mode
  46. Check $mode
  47. case "$mode" in
  48.     "1" )   Search "artist";;
  49.     "2" )   Search "album";;
  50.     "3" )   Search "song";;
  51.     "4" )   Search "matches";;
  52. esac
  53. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement