-
-
Save hamidzr/f0fda69a1f41170fbd975f0876ffc467 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
REGEX="^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*" | |
ID=$1 | |
if [ "$ID" == "" ]; | |
then | |
echo "Syntax $0 <id|url>" | |
exit | |
fi | |
if [[ $ID =~ $REGEX ]]; then | |
ID=${BASH_REMATCH[7]} | |
fi | |
echo "Sending request to play youtube video: $ID" | |
curl -s --data-binary '{"jsonrpc":"2.0","id":"1","method":"Application.SetVolume","params":{"volume":70}}' -H 'content-type: application/json;' http://localhost:8080/jsonrpc | |
curl -s --data-binary '{"jsonrpc":"2.0","id":"1","method":"Player.Open","params":{"item":{"file":"plugin://plugin.video.youtube/?action=play_video&videoid='$ID'"}}}' -H 'content-type: application/json;' http://localhost:8080/jsonrpc | |
#xbmc-send --action="SetVolume(70)" | |
#xbmc-send --action="PlayMedia(plugin://plugin.video.youtube/?action=play_video&videoid=$ID)" |
uri to play a playlist plugin://plugin.video.youtube/?path=/root/video&action=play_all&playlist=$PLAYLISTID
http://feeds.feedburner.com/tedtalksHD scrape to play a new ted talk every morning.
note:
- can't rely on latest url being updated each day.
- play a playlist: http://192.168.15.117/jsonrpc?request={"jsonrpc":"2.0","id":1,"method":"Player.Open","params":{"item":{"playlistid":1},"options":{"repeat":"all"}}}
- 5.10.2 Playlist.Clear
- add Item to playlist1 curl -s --data-ascii '{"jsonrpc":"2.0","id":"1","method":"Playlist.Add","params":{"playlistid":1, "item":{"file":"plugin://plugin.video.youtube/?action=play_video&videoid=MH9ilfAZHOs"}}}' -H 'content-type: application/json;' http://hpi:8080/jsonrpc
//add to playlist
curl -s --data-ascii '{"jsonrpc":"2.0","id":"1","method":"Playlist.Add","params":{"playlistid":1, "item":{"file":"plugin://plugin.video.youtube/?action=play_video&videoid=vm_GroJMOVM","label": "hamidoooooo"}}}' -H 'content-type: application/json;' http://hpi:8080/jsonrpc
// add multiple items to playlist
http://hpi:8080/jsonrpc?request={"jsonrpc":"2.0","id":"1","method":"Playlist.Add","params":{"playlistid":1,"item":[{"file":"plugin://plugin.video.youtube/?action=play_video&videoid=vm_GroJMOVM"},{"file":"plugin://plugin.video.youtube/?action=play_video&videoid=RhU9MZ98jxo"}]}}
//get items of a playlist
http://hpi:8080/jsonrpc?request={"jsonrpc":"2.0","id":"1","method":"Playlist.GetItems","params":{"playlistid":1}}
// play playlist ( using get)
http://hpi:8080/jsonrpc?request={"jsonrpc":"2.0","id":1,"method":"Player.Open","params":{"item":{"playlistid":1},"options":{"repeat":"all"}}}
// clear playlist ( using get)
http://hpi:8080/jsonrpc?request={"jsonrpc":"2.0","id":1,"method":"Playlist.Clear","params":{"playlistid":1}}
https://gist.github.com/hamidzr/f0fda69a1f41170fbd975f0876ffc467#gistcomment-2072711
great idea, added to my crontab:
feedurl=http://feeds.feedburner.com/tedtalksHD
playurl=$(xmllint --xpath 'string(//channel/item/enclosure[@type="video/mp4"]/@url)' "$feedurl")
play-media.sh "$playurl"
also, sets the volume, can be scheduled with cron to work as an alarm in the morning.