Skip to content

plugins.mitele: fix and refactor plugin #4760

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

Merged
merged 1 commit into from
Aug 21, 2022

Conversation

bastimeyer
Copy link
Member

Fixes #4726

This refactors the plugin (mainly code style and validation schema refinements) and fixes the "Forbidden token format" issue.

The problem was how the query string with the HMAC was applied to the stream URL. Both parts are retrieved from different API calls and instead of concatenating the parts like {url}?{querystring}, the query string was parsed and the URL updated with the parsed query string dictionary. While updating the URL, Python automatically quotes/percent-encodes query string values, which broke the token format, hence the added quote_via=lambda string, *_, **__: string keyword to update_qsd() which simply passes through the value.

As an additional note, it's probably unnecessary to yield this many streams with duplicate names, but since it's from different CDNs, I don't want to change this. Very much related to #4758 (comment)


Non-Spanish IP address (geo-blocked):

$ streamlink 'https://mitele.es/directo/telecinco' best
[cli][info] Found matching plugin mitele for URL https://mitele.es/directo/telecinco
[plugins.mitele][error] Could not get stream tokens: 4038 (User has no privileges)
error: No playable streams found on this URL: https://mitele.es/directo/telecinco

Spanish IP address:

$ streamlink -l debug 'https://mitele.es/directo/telecinco' best
[cli][debug] OS:         Linux-5.19.2-1-git-x86_64-with-glibc2.36
[cli][debug] Python:     3.10.6
[cli][debug] Streamlink: 4.3.0+9.g3b0c5c36
[cli][debug] Dependencies:
[cli][debug]  isodate: 0.6.1
[cli][debug]  lxml: 4.9.0
[cli][debug]  pycountry: 22.3.5
[cli][debug]  pycryptodome: 3.14.1
[cli][debug]  PySocks: 1.7.1
[cli][debug]  requests: 2.28.1
[cli][debug]  websocket-client: 1.3.2
[cli][debug] Arguments:
[cli][debug]  url=https://mitele.es/directo/telecinco
[cli][debug]  stream=['best']
[cli][debug]  --loglevel=debug
[cli][debug]  --player=mpv
[cli][info] Found matching plugin mitele for URL https://mitele.es/directo/telecinco
[utils.l10n][debug] Language code: en_US
[utils.l10n][debug] Language code: en_US
[utils.l10n][debug] Language code: en_US
[utils.l10n][debug] Language code: en_US
[utils.l10n][debug] Language code: en_US
[cli][info] Available streams: none_150k, 360p_620k_alt2 (worst), 360p_620k_alt, 360p_620k, 360p_1100k_alt2, 360p_1100k_alt, 360p_1100k, 576p_1900k_alt2, 576p_1900k_alt, 576p_1900k, 576p_3100k_alt, 576p_3100k, 720p_4200k_alt, 720p_4200k (best)
[cli][info] Opening stream: 720p_4200k (hls)
[cli][info] Starting player: mpv
[stream.hls][debug] Reloading playlist
[cli][debug] Pre-buffering 8192 bytes
[stream.hls][debug] First Sequence: 216279944; Last Sequence: 216279947
[stream.hls][debug] Start offset: 0; Duration: None; Start Sequence: 216279945; End Sequence: None
[stream.hls][debug] Adding segment 216279945 to queue
[stream.hls][debug] Adding segment 216279946 to queue
[stream.hls][debug] Adding segment 216279947 to queue
[stream.hls][debug] Segment 216279945 complete
[cli.output][debug] Opening subprocess: mpv --force-media-title=https://mitele.es/directo/telecinco -
[stream.hls][debug] Segment 216279946 complete
[stream.hls][debug] Segment 216279947 complete
[cli][debug] Writing stream to output

@bastimeyer
Copy link
Member Author

it's probably unnecessary to yield this many streams with duplicate names

The name_fmt of the HLS streams could be changed, so that each CDN has its own prefix. The CDN name is included in the first API call, but is not read. I don't care though. If one feels like improving that, go for it.

@gravyboat gravyboat merged commit 6718941 into streamlink:master Aug 21, 2022
@bastimeyer bastimeyer deleted the plugins/mitele/fix branch August 21, 2022 07:09
Billy2011 added a commit to Billy2011/streamlink-27 that referenced this pull request Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plugins.mitele: 403 Client Error: Forbidden token format
2 participants