Kodi feature request (runtime)

kodi
Tags: #<Tag:0x00007fd311eb2058>

(Håvard) #1

I’d like to have the ability to make different lighting schemas on tv shows if its a short comedy or a longer drama/action.
I’m thinking of doing it with runtime as I usually want it a bit darker in the room if the show is longer than 30 mins.

I didn’t find the runtime info in the binding and think that would be nice addition.

I’ll try using the json api for now, if somebody has done anything similar with kodi, some code snippets would be most appreciated :).


(Christoph Weitkamp) #2

Hi Håvard,

I have no proper solution for OH2 but an idea how to get the information from Kodi. I tested some commands with the JSON-RPC API and gathered the following details:

This curl request gets duration or runtime properties. duration for audio files/streams and runtime for video files/streams. Problem is that the response doesn’t return a default value for a property is it is not present. It returns nothing instead which makes the parsing a little bit more complex.

curl -D- -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"Player.GetItem","params":{"properties":["duration","runtime","showtitle"],"playerid":1},"id":"1"}' http://<kodi ip address>:8080/jsonrpc

Response:

{"id":"1","jsonrpc":"2.0","result":{"item":{"id":21,"label":"A World Without God","runtime":2837,"showtitle":"The Frankenstein Chronicles","type":"episode"}}}

I found another solution which returns maybe more useful information.

curl -D- -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"Player.GetProperties","params":{"properties":["percentage","time","totaltime"],"playerid":1},"id":"1"}' http://<kodi ip address>:8080/jsonrpc

Response:

{"id":"1","jsonrpc":"2.0","result":{"percentage":5.0042195320129394531,"time":{"hours":0,"milliseconds":18,"minutes":2,"seconds":22},"totaltime":{"hours":0,"milliseconds":965,"minutes":47,"seconds":17}}}

Anything useful for your approach?


(Håvard) #3

should be helpful, thanks. Might have a go at it again this weekend