IPTV: The Xtreme Codes Saga (part 2)
My original post on the Xtreme Codes Saga had some misconceptions due to lacking documentation and my partial understanding of the API.
I initially thought that the options for supporting Xtreme Codes were either use the Player API or use the M3U/XML downloads to access the stream playlist and program guide. I was misguided by an IPTV playlist filtering/gateway service one of my beta testers were using that didn't support downloading the M3U stream playlist, but more on that later.
I made the assumption that if the playlist URL didn't work, the EPG URL wouldn't either. So I set about implementing a pure Player API approach to downloading both databases. I managed to get the stream lists parsed, but the main Player API functions to retrieve the EPG wasn't working. The other EPG function was too limited, returning only 4-9 results, not enough to be very useful.
I tried to investigate what other players do to get the EPG. I found a sample project and looked at the Player API call used to download the EPG and it was the one that didn't work for me. I just didn't get what I was doing wrong. I decided to manually build the URL using the API command from this project and my beta tester reported that it worked.
I then took the exact same URL that was built using the code I previously wrote, placed them one line above each other and went letter by letter to try and understand this madness. Eventually I found the culprit, the Player API call listed in the little documentation I was able to find was "get_simple_date_table", but the one in the sample project had it "get_simple_data_table", can you spot the difference?
With that out of the way, I was able to code full support for the Xtream Codes Player API. However... the Player API sucks for EPG. You see, the Player API requires that for each stream's EPG you need to make a separate network query to get the stream's listing. To keep the EPG up to date, this means requesting an update every 1-2 days. If you do the math, downloading the entire EPG database would take several hours on even the fastest connections. The data wasn't big, but the number of network queries required would be absurd.
This led me to write the code to dynamically query the Player API for a stream's EPG as soon as you clicked on it. It worked, but wasn't as quick, the network query added some lag and without the full EPG database, the global EPG filter and EPG grid features were useless.
I wasn't satisfied. Other players were doing something else to get the EPG with the filtering/gateway service my beta tester was using. I supplied him with a custom debug build and the logs caught the first issue. The author of this filtering/gateway service used a wrong time format for the UNIX timestamp used in the authentication process (a float instead of an integer).
I managed to contact the developer and informed him of the bug and at the same time, hardened my code to better handle such issues, just in case. While I had this developer's attention, I asked him why the EPG/Stream Playlist downloads were not available on his service. The reply surprised me. He informed me that the XML EPG download entry point does work and that he doesn't see a point in supporting the M3U playlist download since it was covered by the Player API.
I made a silly mistake. When checking if an IPTV provider supported these download URL entry points, I first checked the M3U playlist URL and assumed that if it didn't exist, the XML EPG URL wouldn't work either. And you know what they say about assuming.
Now that I knew this use case could exist, I created a third data source mode "Player API + XML". In this mode, the stream playlists are downloaded in JSON format directly through the Player API and the entire live streams EPG is downloaded as one big XML file. The best of both worlds, a JSON format stream playlist with working Global EPG filtering and EPG grid, the new default data source option when authenticating an IPTV subscription.
These series of events, while frustrating, should make Zoom Player a lot more versatile as your IPTV player of choice.