kodi-pvr / pvr.iptvsimple

IPTV Simple client for Kodi PVR
GNU General Public License v2.0
761 stars 370 forks source link

Channel Unique ID vs. tvg-id #766

Open mariano-git opened 1 year ago

mariano-git commented 1 year ago

Hello Guys, I'm struggling right now to get the correct channel ID using JSONRPC, but unless I'm wrong I find that the Channel UniqueId is auto generated and isn't honoring the m3u8 tvg-id, neither xml channel attribute id.

https://github.com/kodi-pvr/pvr.iptvsimple/blob/7a4c7bc121e2c4766a7ed8f7943dfc5eb23da22e/src/iptvsimple/Channels.cpp#L101

At this moment I don't know if that is a bug, a missing feature or just I didn't find the way to make it work. I understand that this ID must be unique, but would be possible at least to create a flag to activate the auto generation or use the declared id on m3u or xml, similar on how channel number works?

Would you provide some insight to fix my problem? I'm open to suggestions...

Basically, the iptv provider has it's own id and I'd like to keep those ids (Channel and Broadcast/Program) and grab them using JSON. Other way I'm forced to use my own database or parse the xml file to get the correct channel id when it should be available doing a json-rpc query to "PVR.GetChannels"

Thank you!

phunkyfish commented 1 year ago

The channel unique ID is not related to TVG ID at all. It is mandated by the Kodi PVR API and exists across all PVR add-ons. So it cannot be changed or made to work differently.

TVG ID is unique to iptvsimple, or more directly to M3U files. Most PVR add-ons don’t use M3U at all.

mariano-git commented 1 year ago

Hi @phunkyfish Thank you for your response.

According to my understanding you aren't using tvg-id for any other purpose that to match m3u entries with xml entries, and that isn't an exclusive way...

I think won't be a huge impact if the tvg-id could be use as channel's uniqueId too.

Kodi declares uniqueId as interger, and I get one from my iptv provider, I'd like to use it, as I do with the channel number, configuring kodi to use channel number from backend. You could keep the current functionality for those who use alphanumeric tvg-ids and honor the unique tvg-ids on the list when are unique integers

Since this plugin (pvr-iptvsimple) is a kind of proxy for kodi, isn't a real data generator, I mean. I don't see why you're generating ids when those are provided via m3u or xml

phunkyfish commented 1 year ago

The channel id is used to give a level of uniqueness that represents the channel. Tvg Id would not provide that.

For instance it’s quite common for the same tvg id to be used for both SD and HD channels. This would result in one of those channels being dropped if tvg id was used for channel id.

Or in other words, using tvg id would alter the behaviour of the addon and make it non deterministic. We should avoid that because support becomes very difficult.

mariano-git commented 1 year ago

I see the point about SD and HD, as a matter of fact my provider has unique ids for both.

I must remind you, I'm not talking about channelId, but channel uniqueId. The governance of channelId belongs to Kodi

I think the problem is who is the data owner. From my perspective pvr-simple isn't the owner. In this case the owner is the m3u/xml file or if you want, who generated it.

pvr-simple as not data owner, must transfer information to kodi unaltered or provide a way to, as it currently does with channel number.

if you believe that using tvg-id would be problematic, then provide a way to transfer an unique channel id from m3u/xml file to Kodi's channel uniqueId field on database. Same applies to PVR.Broadcast / Programs

If you have concerns about that uniqueness, you can create rules to enforce it and display a log warning message when violated, then the data owner will know and will deal with that if they truly want their data inside Kodi.

PS: You can forget all of this, if you can provide me a way to add EPG data to Kodi from python without going directly to the db.

Thank you!

phunkyfish commented 1 year ago

This is incorrect, unique_id is used in the equality operator in Kodi. So fundamental to how PVR works. So we can’t open this up to setting it externally.

But you are correct that there is no way to set up epg data yourself. There should be but it was never implemented in Kodi PVR. This would be a feature request to the Kodi project. So should be posted on the forum.

mariano-git commented 1 year ago

I see, I'm not sure where starts and ends this problem.

Would be nice to be able to query Kodi for channels and programs and obtain the information that you instructed to put in there.

The only way I found at this moment is the channel number because it seems to travel unaltered, but isn't a good source of information because is open to user manipulation. Even without manipulation, channel number isn't a solution because it forces me to keep a way to map channel number to provider channelId and any other solution is forcing me to that internal map and was just that, what I was trying to avoid.

Thank you for the assistance! PLS: I don't know how to classify this problem. Give it the appropriate following.

phunkyfish commented 1 year ago

The proper solution is to add the ability to load EPG data into Kodi without using a PVR addon.

so the only solution currently is to map the id yourself, using a DB or a file. This is what all the video add-ons in kodi do.

mariano-git commented 1 year ago

Several things here.

I agree with you, Kodi should provide a way to add EPG without so whistle.

But, pvr.iptvsimple should't be manipulating data at all because it's just a proxy without data governance. If uniqueness is a concern it should create it's own identifiers without changing provided information.

Naive python plugins should be able to rely on the information they provide to Kodi will remain as it is but as consequence of the above that's impossible.

I'm aware that different source of information could end on prv.iptvsimple, but it is segmentable via groups, in that way it's possible to have same id in different groups. Generating a composite key would be enough to keep the provided id untouched.

So, from my perspective and at this moment until Kodi allow to control EPG data without PVR addon this is a prv.iptvsimple's problem.

I'm unable to classify it as feature lack, bug or design mistake but the problem is here...

phunkyfish commented 1 year ago

I completely disagree. It is not a problem with iptvsimple at all. The implementation ofas it stands works and a global user base gets great value from it.

Why not figure out how to add this functionality to kodi and give this ability to everyone? Or, add the feature request and wait until a contributor picks it up. FYI, that could be a long wait.