Kodi Community Forum
Getting remaing run time and current chapter? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+---- Forum: JSON-RPC (https://forum.kodi.tv/forumdisplay.php?fid=174)
+---- Thread: Getting remaing run time and current chapter? (/showthread.php?tid=272202)



Getting remaing run time and current chapter? - ksassenf - 2016-05-02

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


RE: Getting remaing run time and current chapter? - ksassenf - 2016-05-03

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


RE: Getting remaing run time and current chapter? - VeggieVampire - 2016-11-27

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