Created
December 12, 2015 23:54
-
-
Save Peetz0r/4485bf8589efdf01e241 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# http://alexpb.com/notes/articles/2014/01/01/xbmc-how-to-remotely-start-media-file-from-command-line/ | |
## XBMC: Remotely Start Playing a Media File From the Command Line Using the JSON API | |
## Configure your XBMC RPC details here | |
XBMC_HOST=192.168.1.10 | |
XBMC_PORT=8080 | |
XBMC_USER=xbmc | |
XBMC_PASS=xbmc | |
# You should not have to touch anything below | |
ID=$1 | |
if [ "$ID" == "" ]; | |
then | |
echo "Syntax $0 </full/path/file.[mp4|mp3|etc]>" | |
exit | |
fi | |
URL=$(youtube-dl -g -- "$ID") | |
function xbmc_req { | |
curl -s -i -X POST --header "Content-Type: application/json" -d "$1" http://$XBMC_USER:$XBMC_PASS@$XBMC_HOST:$XBMC_PORT/jsonrpc >/dev/null | |
} | |
echo -n "Opening YouTube video id $ID on $XBMC_HOST ..." | |
xbmc_req '{"jsonrpc": "2.0", "method": "Playlist.Clear", "params":{"playlistid":1}, "id": 1}'; | |
xbmc_req '{"jsonrpc": "2.0", "method": "Playlist.Add", "params":{"playlistid":1, "item" :{ "file" : "'$URL'"}}, "id" : 1}'; | |
xbmc_req '{"jsonrpc": "2.0", "method": "Player.Open", "params":{"item":{"playlistid":1, "position" : 0}}, "id": 1}'; | |
echo " done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment