Kodi Community Forum

Full Version: Recording API problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everybody,

I was trying to use the Recording API (JSON) and was running into troubles.
I think there's a bug, because the API returns:

{"broadcastid":1536257700,"endtime":"2018-09-06 19:45:00","genre":["Andere","Unbekannt"],"hasrecording":false,"hastimer":false,"hastimerrule":false,"isactive":false,"label":"Wolfsland - Tief im Wald","plot":"Fernsehfilm Deutschland 2016\nEin Monat ist vergangen, seit \"Butsch\", der Oberlausitzer Eigenbrötler, und Viola Delbrück, die Kriminalistin aus Hamburg, ein junges kriminelles Paar gestoppt haben. Trotz dieses Erfolgs ist die Stimmung zwischen den Kommissaren schlechter denn je. Aber gerade jetzt sind sie als Team gefragt, denn in Görlitz scheint ein Serientäter unterwegs zu sein, der es auf junge, attraktive Joggerinnen abgesehen hat. Viola Delbrücks größtes Problem ist jedoch nicht \"Butsch\", sondern ihr Noch-Ehemann, der versucht, sich im neuen Leben seiner Frau einzunisten - auch beruflich. \"Butsch\" aber wittert Gefahr und vertraut seinem eigenen Instinkt.","plotoutline":"","progresspercentage":0,"rating":-1,"recording":"","runtime":90,"starttime":"2018-09-06 18:15:00","thumbnail":"","title":"Wolfsland - Tief im Wald"} 

 So the show I want to record is "broadcastid":1536257700


When I send the  command 

{"id":335,"jsonrpc":"2.0","method":"PVR.AddTimer","params":{"broadcastid":1536257700,"timerrule":false}} 

With the correct broadcastid some more or less random show timer is created.
The record time was correct, but the channel was completly wrong. And it doesn't seem to be a fixed offset, the channel selection just seems to be randomly.

If anybody could take care of this problem would be great.

thanks in advance
higgx
The AddTimer API function is broken by design.

A broadcast id is only unique for a given channel. This means, the same broadcast id can appear in the epg of different channels. The broadcast id without a channel does not allow definitely to identify a show.

In your case, Kodi just picks the show with the given broadcast id on any(!) channel providing a show with the given id. You're doing nothing wrong here, you can't do better, but the API function needs to be extended with "channeluid" parameter to solve your issue.

You might want to open a trac ticket for this.
Thanks ksooo for your reply.

Just to clarify. Who is generating this broadcastid, KODI or the TV backend? And is there some rules to create it?
Maybe the update of my pvr backend is causing the problem, because it now seems to create more equal IDs than it did before.
If they could integrate the channel # into the BroadcastID, it would be more unique and therefore not so many wrong timers?

How would I open a trac ticket for this API function extension?
The broadcast id is either generated by the backend or the respective Kodi pvr add-on.

As per API definition the id has to be unique only per channel and not across all channels, making the ids unique across channels for your backend will solve your particular problem, but is not the proper fix.

The right fix needs to be implemented in the Kodi core - namely the JSON RPC API needs to be extended like I wrote earlier.

Open as ticket here: trac.kodi.tv

EDIT: it seems that your backend is using the start time of the show converted to a number as broadcastid. This explains why there are so many duplicates; for example in Germany many shows start at 8:15 pm
I know it would be just a workaround, but it seems to be easier to pursuade one person to change their IDs instead of trying to change the whole world of JSON RPC, TVMosaic, KODI and who else could be involved and everybody is just pointing to the other ?!? :-)

How do you conclude that 1536257700 is derived from 2018-09-06 18:15:00 ?


I tried my best to create a trac issue 
https://trac.kodi.tv/ticket/18030

Hopefully somebody feels to be in charge and has time to do the needed extension.

regards
higgx
I hate hacks. We should do things right. ;-)

www.epochconverter.com =>
1536257700 = Sep 10 2018, 15:24:11

This made me think that your backend could use show start time as broadcastid
BTW, as Kodi pvr maintainer I could be the one taking care to fix stuff in Kodi core. No backend, no pvr add-on needs to be changed, but the clients using the affected json API functions. That's live.
Thanks for explaining the epoch stuff, that makes sense  Smile  and thanks for picking up the API issue. 

regards
higgx