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

plugins.crunchyroll: update/fix #4510

Merged
merged 1 commit into from
May 8, 2022
Merged

Conversation

mkbloke
Copy link
Member

@mkbloke mkbloke commented May 2, 2022

  • update params for Windows app
  • remove Android headers
  • fix device_id cached value
  • add id to metadata
  • minor spelling corrections
  • add support for beta URLs
  • update tests
  • update cache.set() calls to use expires kw
  • update expires_at=0 to expires=0

closes #3674
closes #4453

@mkbloke mkbloke added the plugin issue A Plugin does not work correctly label May 2, 2022
Copy link
Member

@bastimeyer bastimeyer left a comment

Choose a reason for hiding this comment

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

Since you're changing the _access_type from the Android app to the Windows desktop app, it's probably not a bad idea to change the _user_agent (or alternatively, import from the existing user agents)

@mkbloke
Copy link
Member Author

mkbloke commented May 2, 2022

Initially, I thought what you wrote about updating the user agent was a good idea, but there are also a lot of other Android related headers sent at the moment too. The thing is, I can't test this plugin properly myself as I don't have an account with Crunchyroll to do so. #4453 (comment) suggests that these changes alone result in a working plugin, so I'm reluctant to make changes without being able to test fully.

I could look at the Windows app traffic and copy the UA and headers from it so that the plugin looks and acts like the app, although I'll need to get folks in #4453 to help test it fully.

@mkbloke mkbloke added the WIP Work in process label May 3, 2022
@mkbloke mkbloke changed the title plugins.crunchyroll: update _access_token, _access_type plugins.crunchyroll: update/fix May 5, 2022
@mkbloke
Copy link
Member Author

mkbloke commented May 5, 2022

Some things to note:

start_session is a GET request in the Windows app rather than a POST, but POST works fine, so I have left it like that for the time being.

The HTTP client in the Windows app does not send many headers. It doesn't send Host:, even though it's using HTTPS. It doesn't send User-Agent: either. I tried not sending the UA by popping it from self.session.http.headers, but that just reverts to the Python requests default UA string. Setting it to a zero length string causes User-Agent: to be sent with no value. I have left it to send the default Firefox UA for the time being, which is probably fine.

It seems like there has been a minor bug since the refactor in #1820 which caused the device_id value to be set to the expires value. Strange how it's gone unnoticed for so long, but obviously not of any great consequence.

I've tested this on a free stream, but cannot test the login and therefore access to premium content. I will ask if folks can test it fully in #4453. Hopefully that will all still work correctly, as little has changed and the request sending the login data is the same as that used by the Windows app.

@mkbloke mkbloke added WIP Work in process and removed WIP Work in process labels May 5, 2022
@mkbloke
Copy link
Member Author

mkbloke commented May 6, 2022

I've added the WIP label again... bear with me.

I've added some code (not yet pushed to GH) to also try to close #3674, which will need testing with a selection of beta URLs, as I only have access to those in the issue. I've also updated the tests to use should_match_groups[] and the added the beta URLs in the tests.

Hopefully not too much more to do.

@mkbloke mkbloke removed the WIP Work in process label May 7, 2022
Copy link
Member

@bastimeyer bastimeyer left a comment

Choose a reason for hiding this comment

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

While your changes will fix the plugin issue according to the user responses, there's still a ton of things wrong with the current plugin implementation, because it hasn't been properly maintained and updated in years. The plugin should get rewritten from scratch at some point in the future, to fix all the other issues. Fixing the current issues should be good for now though.

src/streamlink/plugins/crunchyroll.py Outdated Show resolved Hide resolved
src/streamlink/plugins/crunchyroll.py Outdated Show resolved Hide resolved
src/streamlink/plugins/crunchyroll.py Outdated Show resolved Hide resolved
src/streamlink/plugins/crunchyroll.py Outdated Show resolved Hide resolved
@mkbloke mkbloke force-pushed the crunchyroll branch 2 times, most recently from fa8a935 to ca115a4 Compare May 7, 2022 18:06
* update params for Windows app
* remove Android headers
* fix device_id cached value
* add id to metadata
* minor spelling corrections
* add support for beta URLs
* update tests
* update cache.set() calls to use expires kw
* update expires_at=0 to expires=0
@bastimeyer
Copy link
Member

@mkbloke Do you want to wait for some responses to your question in regards to the site's beta version, or do you think that the current changes are good enough and can get merged into master?

@mkbloke
Copy link
Member Author

mkbloke commented May 8, 2022

A couple of people have reported feedback on the beta URL support in issue #4453 so far to say that it's working for them, so, I think the code is probably OK to be merged as is, but I'm also happy to wait a bit longer for more testing and possible feedback on it.

@back-to back-to merged commit d9bd451 into streamlink:master May 8, 2022
@mkbloke mkbloke deleted the crunchyroll branch May 8, 2022 18:31
@mkbloke mkbloke mentioned this pull request May 25, 2022
4 tasks
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
3 participants