Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken: plugin.video.curiositystream - seems API changed #4208

Closed
1 task
wa3573 opened this issue Jan 10, 2023 · 6 comments
Closed
1 task

Broken: plugin.video.curiositystream - seems API changed #4208

wa3573 opened this issue Jan 10, 2023 · 6 comments

Comments

@wa3573
Copy link

wa3573 commented Jan 10, 2023

Add-on details:

  • Add-on name: Curiosity Stream
  • Add-on ID: plugin.video.curiositystream
  • Version number: 2.0.2+matrix.2
  • Kodi/repository version: 19.4

Ownership

  • I am the owner of this add-on

Broken because:

Seems the Curiosity Stream API may have changed, and I was getting some error messages. I'm too busy to include logs or every detail, but I'll share what I discovered, and how I fixed it. Hopefully this will help someone with the same issue. Or if someone really wants, I can make the changes and open a PR.

Issue: IndexError because of empty streams list

Error originates from last line below (router.py):

    def _play_media(self, media):
        stream = self._cs_api.media_stream_info(media)
        play_item = xbmcgui.ListItem(path=stream["streams"][0]["master_playlist_url"])

Fix: Adapt to seeming API changes (curiositystream.py)

I solved this using postman to check API responses. Two problems. First, the API wasn't happy with the User-Agent provided by the Python requests package. Give it something it does like:


    def authenticate(self, force=False):
...
            self._session.headers.update(
                {"x-auth-token": data["message"]["auth_token"],
                "User-Agent": 'Mozilla/5.0'}
            )

Second, the "type" field of the response showed "HD" which (pretty sure) wont match with == "hd":

    @_authenticate_and_retry_on_401
    def media_stream_info(self, media):
...
        return {
            "streams": [
                encoding
                for encoding in data["data"]["encodings"]
                if str(encoding["type"]).lower() == "hd"
            ],
            "subtitles": data["data"]["closed_captions"]
            if "closed_captions" in data["data"]
            else [],
        }

Issue: Kodi can't play the "master_playlist_url"

Maybe the API changed the provided file from .m3u8 to .mpd. Kodi seemed confused.

Fix: Use inputstream.adaptive (router.py)

    def _play_media(self, media):
        stream = self._cs_api.media_stream_info(media)
        play_item = xbmcgui.ListItem(path=stream["streams"][0]["master_playlist_url"])
        play_item.setSubtitles([c["file"] for c in stream["subtitles"]])
        
        play_item.setProperty('inputstream', 'inputstream.adaptive')
        play_item.setProperty('inputstream.adaptive.manifest_type', 'mpd')
        xbmcplugin.setResolvedUrl(self._plugin_handle, True, listitem=play_item)

A proper solution would probably check to make sure it's really an mpd file first, but things seem to be working consistently for me.

Hope this helps!

@mintsoft
Copy link

mintsoft commented Jun 8, 2023

@GMaxera Not sure if you've seen this, I'm happy to pick up PRing this into the main repo and stuff if you don't want to do it etc

mintsoft added a commit to mintsoft/plugin.video.curiositystream that referenced this issue Jun 8, 2023
@GMaxera
Copy link

GMaxera commented Jun 8, 2023

@GMaxera Not sure if you've seen this, I'm happy to pick up PRing this into the main repo and stuff if you don't want to do it etc

No, I didn't see, I'm sorry.

If you can pick it up and fix it, please do it.
At the moment, I'm not able to develop on it, really sorry for that.

@mintsoft
Copy link

mintsoft commented Jun 8, 2023

No problem, I'll probably pull it into its own repository and stuff and we can sort out getting it all consistent once it's working again

@mintsoft
Copy link

mintsoft commented Jun 8, 2023

I've PR'd in a fix for it. The code for just the plugin is here: https://github.com/mintsoft/plugin.video.curiositystream

@mintsoft
Copy link

This can be closed now; the addon is fixed as of June and I've taken over as maintainer of this addon for the forseeable

@mintsoft
Copy link

@basrieter Can you close this issue for me? This was fixed in: #4400

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants