Advertisement
Guest User

Untitled

a guest
Mar 11th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Early exit on incorrect number of parameters
  4. [ "$#" -ne 1 ] && echo "Usage: kodiplay <url>" && exit 1
  5. readonly JSON='{"jsonrpc":"2.0","method":"Player.Open","id":1,"params":{"item":{"file":"'$1'"}}}'
  6.  
  7. # When DEBUG is set, we add the -v flag to curl
  8. [ -z ${DEBUG+x} ] || DEBUG_FLAG="-v"
  9.  
  10. # Load configuration from xbmc-client config file
  11. : ${CONFIG_FILE=$HOME/.config/xbmc-client/config}
  12. HOST=$(sed -n 's/host=//p' < $CONFIG_FILE)
  13. USER=$(sed -n 's/user=//p' < $CONFIG_FILE)
  14. PASS=$(sed -n 's/password=//p' < $CONFIG_FILE)
  15.  
  16. # Send request to Kodi
  17. curl -s \
  18. $DEBUG_FLAG \
  19. -u $USER:$PASS \
  20. --data-binary $JSON \
  21. -H 'content-type: application/json;' \
  22. $HOST/jsonrpc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement