Skip to content

[plugins.playtv] Fix for new stream data API#2388

Merged
back-to merged 12 commits intostreamlink:masterfrom
melmorabity:playtv_fix
Oct 24, 2019
Merged

[plugins.playtv] Fix for new stream data API#2388
back-to merged 12 commits intostreamlink:masterfrom
melmorabity:playtv_fix

Conversation

@melmorabity
Copy link
Contributor

@melmorabity melmorabity commented Mar 31, 2019

This PR fixes the playtv plugin:

[cli][info] Found matching plugin playtv for URL http://playtv.fr/television/arte/
error: Unable to parse JSON: Expecting value: line 1 column 1 (char 0) ('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1Ni ...)

Stream data API now returns a JWT-encoded URL. As a result, JWT support for Streamlink is required. This PR also add a new dependency on the PyJWT library.

This PR also:

@codecov
Copy link

codecov bot commented Mar 31, 2019

Codecov Report

Merging #2388 into master will decrease coverage by 0.32%.
The diff coverage is 83.33%.

@@            Coverage Diff             @@
##           master    #2388      +/-   ##
==========================================
- Coverage   52.64%   52.31%   -0.33%     
==========================================
  Files         238      238              
  Lines       14961    14962       +1     
==========================================
- Hits         7876     7828      -48     
- Misses       7085     7134      +49

@codecov
Copy link

codecov bot commented Mar 31, 2019

Codecov Report

Merging #2388 into master will decrease coverage by 0.2%.
The diff coverage is 63.63%.

@@            Coverage Diff             @@
##           master    #2388      +/-   ##
==========================================
- Coverage   52.73%   52.52%   -0.21%     
==========================================
  Files         243      245       +2     
  Lines       15160    15378     +218     
==========================================
+ Hits         7994     8077      +83     
- Misses       7166     7301     +135

@beardypig
Copy link
Member

Just to note that there probably need to be some changes for the windows installer too :)

@@ -1,15 +1,17 @@
import re

import jwt
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably be optional and not forced for every user.

@back-to back-to added the plugin issue A Plugin does not work correctly label Apr 2, 2019
@bastimeyer
Copy link
Member

Is there a way to install all optional dependencies via pip instead of listing them explicitly?

You currently have listed the plugin's optional dependency under a plugin-specific name in the extras_require field. If more plugins add optional dependencies in the future, then we have to explicitly list them as well in the pip install command(s). I don't think it's a good idea.

Btw, the optional dependencies also don't get installed in the CI environments and the only reason why it's working is that the changes are not being tested at the moment.

@melmorabity
Copy link
Contributor Author

melmorabity commented Oct 9, 2019

You currently have listed the plugin's optional dependency under a plugin-specific name in the extras_require field. If more plugins add optional dependencies in the future, then we have to explicitly list them as well in the pip install command(s). I don't think it's a good idea.

Maybe a single "generic" extras_require target (named "extras" or "optional" e.g.) may be appropriate for all plugins with optional deps, instead of the plugin's name.
BTW pyjwt is not an optional dependency for playtv. The plugin won't work without it. It requires a whole library just for it to work, which is a problem according to @back-to.

Is there a way to install all optional dependencies via pip instead of listing them explicitly?

I don't think so, unfortunately. There's nothing in setuptools doc about it.

@beardypig
Copy link
Member

beardypig commented Oct 15, 2019

If you're not verifying the signature, and it's only for this website, probably you can just roll your own method to decode it?

Update: this should do it

def jwt_decode(token):
    info, payload, sig = token.split(".")
    data = base64.urlsafe_b64decode(payload + '=' * (-len(payload) % 4))
    return json.loads(data)

@melmorabity
Copy link
Contributor Author

If you're not verifying the signature, and it's only for this website, probably you can just roll your own method to decode it?

Update: this should do it

def jwt_decode(token):
    info, payload, sig = token.split(".")
    data = base64.urlsafe_b64decode(payload + '=' * (-len(payload) % 4))
    return json.loads(data)

Sorry, I haven't seen your update before pushing my fixes. And I better like your implementation. Will use it instead

@beardypig
Copy link
Member

Restarting travis build for Python 3.7, failure was due to network error

@back-to back-to merged commit cc32730 into streamlink:master Oct 24, 2019
Billy2011 pushed a commit to Billy2011/streamlink-27 that referenced this pull request May 14, 2020
mkbloke pushed a commit to mkbloke/streamlink that referenced this pull request Aug 18, 2020
resiproxy pushed a commit to resiproxy/streamlink that referenced this pull request Nov 5, 2020
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.

Playtv uk

4 participants