streamlink: plugins.crunchyroll: Unauthenticated request error, login system may have changed ?
Checklist
- This is a plugin issue and not a different kind of issue
- I have read the contribution guidelines
- I have checked the list of open and recently closed plugin issues
- I have checked the commit log of the master branch
Streamlink version
Latest stable release
Description
The Crunchyroll plugin worked well last Sunday. Now I get an Unauthenticated request message, even though my username/password haven’t changed. I provide the log for an episode I know for a fact played well this weekend.
My best guess would be a change in the way Crunchyroll deals with logins, as I can now activate the CR app on my TV just by writing an activation code on my web browser session instead of writing the whole password, which was not an option weeks ago.
Debug log
C:\Users\Stella>streamlink --loglevel debug crunchyroll.com/fr/spy-x-family/episode-1-operation-strix-842454
[cli][debug] OS: Windows 10
[cli][debug] Python: 3.9.10
[cli][debug] Streamlink: 3.2.0
[cli][debug] Requests(2.27.1), Socks(1.7.1), Websocket(1.2.3)
[cli][debug] Arguments:
[cli][debug] url=crunchyroll.com/fr/spy-x-family/episode-1-operation-strix-842454
[cli][debug] --loglevel=debug
[cli][debug] --locale=en_US
[cli][debug] --player="C:\Users\Stella\Documents\MPV\mpv.exe"
[cli][debug] --player-args=--keep-open=yes --cache=yes
[cli][debug] --player-no-close=True
[cli][debug] --title={author} - {category} - {title}
[cli][debug] --default-stream=['best']
[cli][debug] --ringbuffer-size=134217728
[cli][debug] --stream-segment-threads=3
[cli][debug] --hls-segment-threads=3
[cli][debug] --ffmpeg-ffmpeg=C:\Program Files (x86)\Streamlink\ffmpeg\ffmpeg.exe
[cli][debug] --crunchyroll-username=********
[cli][debug] --crunchyroll-password=********
[cli][info] Found matching plugin crunchyroll for URL crunchyroll.com/fr/spy-x-family/episode-1-operation-strix-842454
[utils.l10n][debug] Language code: en_US
[plugins.crunchyroll][debug] Creating session with locale: en_US
Traceback (most recent call last):
File "runpy.py", line 197, in _run_module_as_main
File "runpy.py", line 87, in _run_code
File "C:\Program Files (x86)\Streamlink\bin\streamlink.exe\__main__.py", line 18, in <module>
File "C:\Program Files (x86)\Streamlink\pkgs\streamlink_cli\main.py", line 1061, in main
handle_url()
File "C:\Program Files (x86)\Streamlink\pkgs\streamlink_cli\main.py", line 570, in handle_url
streams = fetch_streams(plugin)
File "C:\Program Files (x86)\Streamlink\pkgs\streamlink_cli\main.py", line 464, in fetch_streams
return plugin.streams(stream_types=args.stream_types,
File "C:\Program Files (x86)\Streamlink\pkgs\streamlink\plugin\plugin.py", line 336, in streams
ostreams = self._get_streams()
File "C:\Program Files (x86)\Streamlink\pkgs\streamlink\plugins\crunchyroll.py", line 307, in _get_streams
api = self._create_api()
File "C:\Program Files (x86)\Streamlink\pkgs\streamlink\plugins\crunchyroll.py", line 372, in _create_api
api.start_session()
File "C:\Program Files (x86)\Streamlink\pkgs\streamlink\plugins\crunchyroll.py", line 190, in start_session
self.session_id = self._api_call("start_session", params, schema=_session_schema)
File "C:\Program Files (x86)\Streamlink\pkgs\streamlink\plugins\crunchyroll.py", line 166, in _api_call
raise CrunchyrollAPIError(err_msg, err_code)
streamlink.plugins.crunchyroll.CrunchyrollAPIError: Unauthenticated request
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 29 (14 by maintainers)
One can use the token from Windows desktop client, instead of the android.
Changing these lines
https://github.com/streamlink/streamlink/blob/867b9b3b66aab57c0fcb3ab117a275f29a23b71a/src/streamlink/plugins/crunchyroll.py#L102-L103
to
Seems to fix the issue. This token has not changed since at least 2020, so I think it’s more stable.
Debug log
I had no luck , I tried v2.5.0 and v2.6.0 and both uses the old keys in the request, from v3.0.0 and newer releases points to the new API so can’t get the token from this point. And the new login system seems to defer a lot. So a plugin rewrite is mandatory.
@mkbloke
Not much to the log lol. I did try the purge credentials and didn’t do a thing. Also trying to log into the website and it gives the same error (tried logging in on incognito and wasn’t able to log in, but still logged in on normal tab), I think this is just a rate limiting issue since I got this error by pretty much trying to run the plugin too much. After about 10 or so mins I was able to log back in again.
@mkbloke Thank you very much, now everything works very well, tested both free and premium chapters, Normal/BETA URLS.
I will continue testing it to look for some type of error, again thank you very much
@mkbloke I can also confirm that these changes work, along with accessing premium content
EDIT: after testing a bit more, am running into an authentication error:
error: Authentication error: A system error occurred. Please contact us for help.@mkbloke can confirm that updated plugin works for me, and does work with the beta URLs, having sideloaded it.
Note: the latest version adds support for beta URLs, so if you’re trying Crunchyroll beta, any reports from testing of those URLs would also be appreciated. Thanks.
@neko47834, I have edited the link in my comment above (https://github.com/streamlink/streamlink/issues/4453#issuecomment-1119111595) to point to an updated version. Please download that one and give it a try. I hope it will fix your issue. Thanks.
@mkbloke yes, it looks almost the same
@neko47834, is your plugin.cache looking like this (the same value as here):
If so, it’s something I noticed earlier. https://github.com/streamlink/streamlink/blob/e8c7e0ff7ee8388f75e85bb47a5430528124751b/src/streamlink/plugins/crunchyroll.py#L178 The number of parameters in the call to
self.cache.set()is incorrect. I already fixed it in the changes I’m working on. I’ll push those to GitHub soon so that they can be tested.There’s one last chance to see if this works, seems that the 2.5.0 app version received the last update in 30th March, 2022. Just the day before this plugin stop working. I tried to download this version fom apkpure.com but this folks split the apk so I can’t install it. If i could get the apk of this version and install it, maybe i’ll be able to get the token. At least to make it work until June.