Getting remaing run time and current chapter?
#1
Hi,
I´m working on an external display for Kodi and am using JSON to query the data I need.

I want to show the remaining run time of the currently playing (mainly movies). I can query most parameters I need with e.g.:

jsonrpc?request={jsonrpc":"2.0","method":"Player.GetProperties","params":{"playerid":1,"properties"":["percentage","time","totaltime"]},"id":"1"

for getting the name of the currently playing movie I use:

jsonrpc?request={"jsonrpc": "2.0", "method": "Player.GetItem", "params": { "properties": ["title", "album", "duration", "showtitle","streamdetails"], "playerid": 1 }, "id": "VideoGetItem"}

but I can´t find a parameter to get th remaining time. Obviously I could calculate the remaining time myself from "totaltime - time", but as a lazy programmer I would prefer Kodi to do the calculation for me (especially as I get hour/minute/seconds all seperate).

Is there any way to get the remaining runtime from JSON api?

And while we are at it:
I´m struggling with the api documentation right now: Is there a parameter to get current and total number of chapters?

Thanks in advance for your help - if this is documented I´d appreciate a link where I could find this ...

Thanks - Peter
Reply
#2
Hi all,
seems to be a tough questions?
I have now calculated the remaining time myself from "Totaltime" - "Time" - works.

For getting the total and current chapter I do not have any idea how to get it - not sure it is possible, can´t find it in the JSON docs.

Regards - Peter
Reply
#3
Here is a I would do it.

Code:
wget -q -O- --header='Content-Type: application/json' --post-data='{"jsonrpc": "2.0", "method": "Player.GetProperties", "params": { "playerid": 1, "properties": ["totaltime"] }, "id": 1}' 'http://127.0.0.1:8080/jsonrpc'| python -m json.tool|grep -i hour|awk '{print $2}'|rev|cut -c 2-|rev>totalhour
wget -q -O- --header='Content-Type: application/json' --post-data='{"jsonrpc": "2.0", "method": "Player.GetProperties", "params": { "playerid": 1, "properties": ["totaltime"] }, "id": 1}' 'http://127.0.0.1:8080/jsonrpc'| python -m json.tool|grep -i minutes|awk '{print $2}'|rev|cut -c 2-|rev>totalminutes

Totalhourz=$(cat totalhour)
Totalminutez=$(cat totalminutes)

wget -q -O- --header='Content-Type: application/json' --post-data='{"jsonrpc": "2.0", "method": "Player.GetProperties", "params": { "playerid": 1, "properties": ["time"] }, "id": 1}' 'http://127.0.0.1:8080/jsonrpc'| python -m json.tool|grep -i hour|awk '{print $2}'|rev|cut -c 2-|rev>hour
wget -q -O- --header='Content-Type: application/json' --post-data='{"jsonrpc": "2.0", "method": "Player.GetProperties", "params": { "playerid": 1, "properties": ["time"] }, "id": 1}' 'http://127.0.0.1:8080/jsonrpc'| python -m json.tool|grep -i minutes|awk '{print $2}'|rev|cut -c 2-|rev>minutes

hourz=$(cat hour)
minutez=$(cat minutes)


echo "Hours:"
expr $Totalhourz - $hourz
echo "Minutes:"
expr $Totalminutez - $minutez

rm -rf totalhour
rm -rf totalminutes
rm -rf hour
rm -rf minutes
Reply

Logout Mark Read Team Forum Stats Members Help
Getting remaing run time and current chapter?0