-
KODI Stuff
6 days ago • 0 commentsFor json_rpc to work make sure you have Allow remote control via HTTP activated on the Control tab of Setting/Services.
How to query KODI to display play time and play duration:
curl -X POST -H "content-type:application/json" http://192.168.1.176:8080/jsonrpc -d '{"jsonrpc":"2.0","method":"XBMC.GetInfoLabels","params":{"labels": ["Player.Time","Player.Duration"] },"id": 1}'
or if you have a password set:
curl -X POST -H "content-type:application/json" http://kodi:kodi@192.168.1.176:8080/jsonrpc -d '{"jsonrpc":"2.0","method":"XBMC.GetInfoLabels","params":{"labels": ["Player.Time","Player.Duration"] },"id": 1}'
or a simple scrip to output well formatted info that looks like 00:40:22/01:43:20
#!/bin/bash
read line < <(curl -s -X POST -H "content-type:application/json" http://192.168.1.176:8080/jsonrpc -d '{"jsonrpc":"2.0","method":"XBMC.GetInfoLabels","params":{"labels": ["VideoPlayer.Duration"] },"id": 1}' | grep -o -P '(?<=Duration":").*?(?="}})') read line2 < <(curl -s -X POST -H "content-type:application/json" http://192.168.1.176:8080/jsonrpc -d '{"jsonrpc":"2.0","method":"XBMC.GetInfoLabels","params":{"labels": ["VideoPlayer.Time"] },"id": 1}' | grep -o -P '(?<=Time":").*?(?="}})') echo "$line2/$line"