Skip to content

Instantly share code, notes, and snippets.

@maxime1992
Forked from dataolle/sendxbmc.sh
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxime1992/11fac771189ce5963f95 to your computer and use it in GitHub Desktop.
Save maxime1992/11fac771189ce5963f95 to your computer and use it in GitHub Desktop.
#!/bin/bash
#set url and port to the xbmc box webservice
XBMC_HOST="http://127.0.0.1:8080"
if [ "$1" = "" ]; then
echo -n "Insert URL: "
read url
else
url="$1"
fi
if [[ "$url" == *youtube.com* ]]
then
vid=$( echo "$url" | tr '?&#' '\n\n' | grep -e '^v=' | cut -d'=' -f2 )
payload='{"jsonrpc": "2.0", "method": "Player.Open", "params":{"item": {"file" : "plugin://plugin.video.youtube/?action=play_video&videoid='$vid'" }}, "id" : "1"}'
elif [[ "$url" == *vimeo.com* ]]
then
vid=$( echo "$url" | awk -F"/" '{print ($(NF))}' )
payload='{"jsonrpc": "2.0", "method": "Player.Open", "params":{"item": {"file" : "plugin://plugin.video.vimeo/?action=play_video&videoid='$vid'" }}, "id": "1" }'
else
payload='{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "file": "'${url}'" }}, "id": 1 }'
fi
curl -v -u xbmc:password -d "$payload" -H "Content-type:application/json" -X POST "${XBMC_HOST}/jsonrpc"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment