streamlink: plugins.crunchyroll: Unauthenticated request error, login system may have changed ?

Checklist

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)

Most upvoted comments

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

_access_token = "LNDJgOit5yaRIWN"
_access_type = "com.crunchyroll.windows.desktop"

Seems to fix the issue. This token has not changed since at least 2020, so I think it’s more stable.

Debug log

[cli][debug] OS:         Windows 8.1
[cli][debug] Python:     3.10.3
[cli][debug] Streamlink: 4.0.0
[cli][debug] Requests(2.27.1), Socks(1.7.1), Websocket(1.3.2)
[cli][debug] Arguments:
[cli][debug]  url=https://www.crunchyroll.com/hunter-x-hunter/episode-148-past-x-and-x-future-654039
[cli][debug]  --loglevel=debug
[cli][debug]  --player=C:\mpv\mpv.com
[cli][debug]  --player-args=--pause
[cli][debug]  --verbose-player=True
[cli][debug]  --player-no-close=True
[cli][debug]  --title={title} -!- {author} -!- {category}
[cli][debug]  --stream-sorting-excludes=['None', '>=1440p60']
[cli][debug]  --ringbuffer-size=67108864
[cli][debug]  --stream-segment-threads=4
[cli][debug]  --mux-subtitles=True
[cli][debug]  --ffmpeg-ffmpeg=C:\Program Files\Streamlink\ffmpeg\ffmpeg.exe
[cli][info] Found matching plugin crunchyroll for URL https://www.crunchyroll.com/hunter-x-hunter/episode-148-past-x-and-x-future-654039
[utils.l10n][debug] Language code: pt_BR
[plugins.crunchyroll][debug] Creating session with locale: pt_BR
[plugins.crunchyroll][debug] Session created with ID: a552879f769b72538fdb60edf2945efd
[plugins.crunchyroll][warning] No authentication provided, you won't be able to access premium restricted content
[plugins.crunchyroll][debug] Loading streams from adaptive playlist
[utils.l10n][debug] Language code: pt_BR
[utils.l10n][debug] Language code: pt_BR
[utils.l10n][debug] Language code: pt_BR
Available streams: 240p_alt (worst), 240p, 360p_alt, 360p, 480p_alt, 480p, 720p_alt, 720p, 1080p_alt, 1080p (best)

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

[22:07:38.684278][session][debug] Plugin crunchyroll is being overridden by C:\\Users\\-\\AppData\\Roaming\\streamlink\\plugins\\crunchyroll.py
[22:07:38.710279][cli][debug] OS:         Windows 8.1
[22:07:38.711280][cli][debug] Python:     3.10.3
[22:07:38.711280][cli][debug] Streamlink: 4.0.0
[22:07:38.711280][cli][debug] Requests(2.27.1), Socks(1.7.1), Websocket(1.3.2)
[22:07:38.711280][cli][debug] Arguments:
[22:07:38.711280][cli][debug]  url=https://crunchyroll.com/date-a-live/fairy-tale-842792
[22:07:38.711280][cli][debug]  stream=['1080p']
[22:07:38.712279][cli][debug]  --loglevel=trace
[22:07:38.712279][cli][debug]  --output=\\\\192.168.1.102\\debianshare\\Shows\\Date A Live\\Season 4\\Episode 5 - Fairy Tale.mp4
[22:07:38.712279][cli][debug]  --hls-segment-attempts=5
[22:07:38.712279][cli][debug]  --ffmpeg-ffmpeg=S:\\Programs\\ffmpeg\\ffmpeg.exe
[22:07:38.712279][cli][debug]  --crunchyroll-username=-
[22:07:38.712279][cli][debug]  --crunchyroll-password=********
[22:07:38.713280][cli][info] Found matching plugin crunchyroll for URL https://crunchyroll.com/date-a-live/fairy-tale-842792
[22:07:38.844286][utils.l10n][debug] Language code: en_US
[22:07:38.855288][plugins.crunchyroll][debug] Device ID: 571e5137-0506-400c-93bf-d807524751ca
[22:07:38.856287][plugins.crunchyroll][debug] Creating session with locale: en_US
[22:07:39.051298][plugins.crunchyroll][debug] Session created with ID: 379a8d0dac9f8faeab8359af8172316d
[22:07:39.051298][plugins.crunchyroll][debug] Attempting to login using username and password
error: Authentication error: A system error occurred. Please contact us for help.

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

{ “crunchyroll:device_id”: { “value”: 31536000, “expires”: 1652376376.670161 },

@neko47834, is your plugin.cache looking like this (the same value as here):

{
  "crunchyroll:device_id": {
    "value": 31536000,
    "expires": 1652312844.9755983
  }
}

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.