Hiumee / service.discord.richpresence

MIT License
49 stars 5 forks source link

Support for Live TV #10

Open zeroquinc opened 10 months ago

zeroquinc commented 10 months ago

Would be nice if it could support it. I have IPTV with EPG and for now it just shows this:

image

Thanks in advance!

Hiumee commented 10 months ago

The image uses the IMDB/TMBD id and name of the media. Both are extracted using Kodi's API. If the IPTV service doesn't set one of those fields correctly, the lookup will fail and a default image will be displayed. I don't have an IPTV service so I can't test the interaction

zeroquinc commented 10 months ago

The image uses the IMDB/TMBD id and name of the media. Both are extracted using Kodi's API. If the IPTV service doesn't set one of those fields correctly, the lookup will fail and a default image will be displayed. I don't have an IPTV service so I can't test the interaction

I'm not really concerned about the image (although I am sure it can also be done with a 3rd party host like imgur), but it would be nice to just show what channel I am playing. The data should be in the KODI API is my guess:

image

maybe I will submit a PR this week and try it myself. Thanks for the quick response and loving the addon.

zeroquinc commented 8 months ago

Hmm I looked into this. I think it's not currently possible to fetch the channel ID and title with the current python module. However it does seem to be available in the C++ module, but that's no use here.

I made an own script that's on my GitHub that can use LiveTV but it works with JSONRPC.

image

So I don't think it's (currently) possible in the addon right now sadly.

Hiumee commented 7 months ago

If you can do it using the JSONRPC, it should also be possible through the python API using xbmc.executeJSONRPC Details here http://alwinesch.github.io/group__python__xbmc.html#gacbdcb8982550fbbe24c7b79ed84ed846

zeroquinc commented 7 months ago

If you can do it using the JSONRPC, it should also be possible through the python API using xbmc.executeJSONRPC Details here http://alwinesch.github.io/group__python__xbmc.html#gacbdcb8982550fbbe24c7b79ed84ed846

I would love to give it a go, but this addon also has the problem for me that it can't fetch the IMDB / TMDB id, while that is always present in my Kodi and thus falls back on the title which almost never works sadly.

In my own script it works by just extracting the uniqueid:

    def get_tmdb_id(info, media_type):
    # If the media type is a channel, return None
    if media_type == 'channel':
        return None

    tmdb_id = None
    if info['type'] == 'episode':
        tv_show_id = info['tvshowid']
        # If tvshowid is not None or -1, fetch the TMDB ID from the TV show details
        tv_show_url = f"http://localhost:{port}/jsonrpc?request={{%22jsonrpc%22:%222.0%22,%22method%22:%22VideoLibrary.GetTVShowDetails%22,%22params%22:{{%22tvshowid%22:{tv_show_id},%22properties%22:[%22uniqueid%22]}},%22id%22:%22libTvShow%22}}"
        tv_show_response = requests.get(tv_show_url).json()
        # Check if 'result' key exists in the response
        if 'result' in tv_show_response and 'tvshowdetails' in tv_show_response['result'] and 'uniqueid' in tv_show_response['result']['tvshowdetails'] and 'tmdb' in tv_show_response['result']['tvshowdetails']['uniqueid']:
            tmdb_id = tv_show_response['result']['tvshowdetails']['uniqueid']['tmdb']
    # Check if 'uniqueid' and 'tmdb' keys exist in the info
        elif 'uniqueid' not in info or 'tmdb' not in info['uniqueid']:
            tmdb_id = get_tmdb_id_for_episode(info)
            logger.debug("Cannot find uniqueid, trying to find tmdb_id via showtitle")
    else:
        if info['type'] == 'movie':
            tmdb_id = get_tmdb_id_for_movie(info)
            logger.debug("Cannot find uniqueid, trying to find tmdb_id via title")
    return tmdb_id

So I think before I will try to add the JSONRPC in it, I'll try to fix this first.

Hiumee commented 7 months ago

So far I used getIMDBNumber() to get the IMDB/TMDB id. I wasn't aware of the addition of UniqueID in v20. It would be better and more reliable to use it but it would mean dropping support for Kodi 19. Might replace it in the future as it requires some changes to the image server

zeroquinc commented 7 months ago

So far I used getIMDBNumber() to get the IMDB/TMDB id. I wasn't aware of the addition of UniqueID in v20. It would be better and more reliable to use it but it would mean dropping support for Kodi 19. Might replace it in the future as it requires some changes to the image server

I tried using getIMDBNumber() too in mine but it always gave wrong results for tv shows. I think for episodes it gives you a episode link which you can't do anything with, we need the show IMDB id. I'm guessing thats why my posters dont work 99% of the time in this addon and do work with the UniqueID tag in my script because I look up the TV Show after I grabbed the episode details.

I understand that you don't want to drop support for v19, I honestly didn't know it was a v20 only thing.