xbmc / xbmc

Kodi is an award-winning free and open source home theater/media center software and entertainment hub for digital media. With its beautiful interface and powerful skinning engine, it's available for Android, BSD, Linux, macOS, iOS, tvOS and Windows.
https://kodi.tv/
Other
18.42k stars 6.3k forks source link

PVR Guide Import/Caching Behavior Question for Matrix #19278

Closed kyl416 closed 3 years ago

kyl416 commented 3 years ago

I help maintain an xmltv grabber for the Netherlands and a big issue they have over there is that several major broadcasters like RTL, FOX, Disney and Viacom don't give up to the minute start times for their programming until the night prior, so while the initial 2 weeks worth of data has everything starting at 5 minute intervals, the night before an update comes out that reflects the real start times for the day like 14:57 instead of 14:55 or 15:00.

It seems Matrix changed how it caches guide data, which can be a problem since if they don't run the xmltv grabber until the morning after, they might never see the accurate start times if Kodi already cached the data that has the old times and depending on their settings, Kodi might not check for guide data updates for another day. Is there a hidden option to return to the previous behavior where you can disable caching of the guide so it will always reload the data each time you start Kodi, or an option to always force an update of the next 24-48 hours worth of data to deal with last minute changes?

This might also be an issue for viewers in North America who use schedules direct since updates from them arrive multiple times a day, and might affect things come playoffs time when the NBA, NHL and MLB have best of series, the initial guide data usually have those "if necessary" games, but if the series ended the night prior new episodes of primetime programming might air instead, which schedules direct won't reflect until they get their afternoon or early evening update the same day. It also affects daytime soap operas when breaking news pre-emptions from the network force them to delay episodes by a day, but Kodi might not reflect it if it's still using outdated guide data from the cache.

djp952 commented 3 years ago

What PVR backend are you using? Kodi supports synchronous (pull) and asynchronous (push) updates to EPG data. I maintain an (external) PVR addon and I implement both methods.

Implementing GetEPGForChannel() only works when Kodi knows it needs more data, it has no way to know the data may have been changed. If you have new/updated data you can call the EpgEventStateChanged() [or similar] functions from the PVR addon to update the EPG tags.

For me, I cache the XMLTV data in an addon-specific database that's updated every 24 hours (+/-). When Kodi starts up or has a known gap to fill, it will call GetEPGForChannel(), and I respond accordingly. If the XMLTV data itself has been updated I inform Kodi of this via EpgEventStateChanged() calls.

Seems to work very well IMO, on both Leia and Matrix. If Kodi specifically asks for EPG data, the addon responds to it and gives it what it asked for. If the addon has changes, it doesn't wait for Kodi to ask; it pushes them across.

The Kodi PVR maintainer has also done an excellent job for Matrix with improvements to the mentioned start time deltas that crop up. Kodi handles this much more gracefully in Matrix by "fixing" the EPG tags.

I can't speak for Team Kodi, but I think the PVR API already has the necessary callbacks and tools needed to make your scenario(s) work the way you want them to.

emveepee commented 3 years ago

I can't speak for Team Kodi, but I think the PVR API already has the necessary callbacks and tools needed to make your scenario(s) work the way you want them to.

Speaking for pvr.nextpvr the missing API is being able to notify core of the actual last backend EPG update time, or optionally query for the next planned EPG update time at startup. The goal would be to avoid unnecessary updates and trigger a new one only if the Kodi data or is stale and the time is under updatecheckinterval or epg.epgupdate parameters.

Technically on startup the Kodi database will have stale data because it is typically missing new shows in the "new" hours of the EPG window but I expect users probably prefer the faster launch of Matrix, I know I do.

ksooo commented 3 years ago

an option to always force an update of the next 24-48 hours worth of data to deal with last minute changes?

There is such a setting. Default EPG update interval is 120 mins. This can be customized in Kodi's PVR settings.

emveepee commented 3 years ago

an option to always force an update of the next 24-48 hours worth of data to deal with last minute changes?

There is such a setting. Default EPG update interval is 120 mins. This can be customized in Kodi's PVR settings.

That time based setting doesn't address the problem introduced in v19 where users only want to configure a once a day interval on startup.

djp952 commented 3 years ago

I have an (honest) counter-question to that; what do you feel prevents a PVR addon from implementing a "once a day interval on startup" on it's own? Perhaps I'm being obtuse (OK, that's actually pretty likely - lol!), but there is nothing I am aware of that would prevent a PVR addon from calling EpgEventStateChange() pretty much whenever it wants to? I happen to do this asynchronously on a worker thread after startup, but I've seen no evidence to imply that a PVR addon can't make this work on it's own if it's a valid use case for it's EPG data?