Skip to content

plugins.twitch: fix HLS multivariant errors #5591

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

Conversation

bastimeyer
Copy link
Member

Fixes #5590

$ streamlink twitch.tv/smoke
[cli][info] Found matching plugin twitch for URL twitch.tv/smoke
Available streams: audio_only, 160p (worst), 360p, 480p, 720p60, 1080p60 (best)

$ streamlink twitch.tv/primevideo
[cli][info] Found matching plugin twitch for URL twitch.tv/primevideo
[plugins.twitch][error] Content Restricted In Region
error: No playable streams found on this URL: twitch.tv/primevideo

I'd appreciate it if someone could test this where the content is actually available. It's blocked when I access it with my local German IP address, and it's also blocked with all the VPNs I've tried.

Btw, the geo-restriction could also be checked here:
https://github.com/streamlink/streamlink/blob/6.2.1/src/streamlink/plugins/twitch.py#L270
But I felt like checking on the HLS multivariant request is a better idea, since the current error handling isn't particularly great.

@bastimeyer bastimeyer added the plugin issue A Plugin does not work correctly label Oct 6, 2023
@adamef93
Copy link

adamef93 commented Oct 6, 2023

I can test it out but need a little guidance if possible. I have streamlink installed via winget on my PC and via homebrew on my Macbook. What would be the simplest way to replace the necessary files with what you wrote so I can try it out?

Ignore this if someone actually involved with streamlink development needs to test it

@bastimeyer
Copy link
Member Author

@adamef93
Copy link

adamef93 commented Oct 6, 2023

High probability I did this wrong but here's what I got. At least the giant original error message is gone

First attempt only with new twitch.py in Appdata\Roaming\streamlink\plugins

PS C:\Users\*user*> streamlink twitch.tv/primevideo best
[cli][info] Found matching plugin twitch for URL twitch.tv/primevideo
[plugins.twitch][error] no_cdm_specified
error: No playable streams found on this URL: twitch.tv/primevideo

Second attempt with both twitch.py and test_twitch.py in Appdata\Roaming\streamlink\plugins

PS C:\Users\*user*> streamlink twitch.tv/primevideo best
[session][error] Failed to load plugin test_twitch from C:\Users\*user*\AppData\Roaming\streamlink\plugins
Traceback (most recent call last):
  File "C:\Users\*user*\AppData\Local\Programs\Streamlink\pkgs\streamlink\session.py", line 649, in load_plugins   
    mod = load_module(module_name, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\*user*\AppData\Local\Programs\Streamlink\pkgs\streamlink\utils\module.py", line 14, in load_module
    spec.loader.exec_module(mod)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\*user*\AppData\Roaming\streamlink\plugins\test_twitch.py", line 6, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'
[cli][info] Found matching plugin twitch for URL twitch.tv/primevideo
[plugins.twitch][error] no_cdm_specified
error: No playable streams found on this URL: twitch.tv/primevideo

@bastimeyer
Copy link
Member Author

Just to make this clear, this fix is about error handling, not about making "primevideo" work when you don't have access. If you can access the channel on Twitch's site but not via Streamlink, then this requires different changes, but as said, I can't access it, so I can't fix this.

Log outputs without the debug level are always meaningless, hence the requirement in plugin issues for --loglevel=debug (you've ignored that).
https://streamlink.github.io/cli.html#cmdoption-loglevel

The test file doesn't belong there, as you can clearly see from the error message after you've copied the file there.

[plugins.twitch][error] no_cdm_specified

It's possible that in order to access these kind of streams that another access token parameter is required.

@adamef93
Copy link

adamef93 commented Oct 6, 2023

My mistake, here's the output with the debug flag and the test file removed. I do have access btw, I'm watching the Twitch stream on my PC right now. This isn't trying to circumvent anything on my side.

PS C:\Users\*user*> streamlink twitch.tv/primevideo best --loglevel=debug 
[session][debug] Plugin twitch is being overridden by C:\Users\*user*\AppData\Roaming\streamlink\plugins\twitch.py
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.11.5
[cli][debug] OpenSSL:    OpenSSL 3.0.9 30 May 2023
[cli][debug] Streamlink: 6.2.0
[cli][debug] Dependencies:
[cli][debug]  certifi: 2023.7.22
[cli][debug]  isodate: 0.6.1
[cli][debug]  lxml: 4.9.3
[cli][debug]  pycountry: 22.3.5
[cli][debug]  pycryptodome: 3.18.0
[cli][debug]  PySocks: 1.7.1
[cli][debug]  requests: 2.31.0
[cli][debug]  trio: 0.22.2
[cli][debug]  trio-websocket: 0.10.4
[cli][debug]  typing-extensions: 4.7.1
[cli][debug]  urllib3: 2.0.4
[cli][debug]  websocket-client: 1.6.3
[cli][debug] Arguments:
[cli][debug]  url=twitch.tv/primevideo
[cli][debug]  stream=['best']
[cli][debug]  --loglevel=debug
[cli][debug]  --ffmpeg-ffmpeg=C:\Users\*user*\AppData\Local\Programs\Streamlink\ffmpeg\ffmpeg.exe
[cli][info] Found matching plugin twitch for URL twitch.tv/primevideo
[plugins.twitch][debug] Getting live HLS streams for primevideo
[plugins.twitch][debug] {'adblock': False, 'geoblock_reason': '', 'hide_ads': False, 'server_ads': True, 'show_ads': True}
[utils.l10n][debug] Language code: en_US
[plugins.twitch][error] no_cdm_specified
error: No playable streams found on this URL: twitch.tv/primevideo

@bastimeyer
Copy link
Member Author

I'm going to merge this PR now.

Please open a new plugin issue with the no_cdm_specified error, so this can be tracked separately. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin issue A Plugin does not work correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plugins.twitch: TypeError: exception causes must derive from BaseException
2 participants