yt-dlp: [crunchyroll] Error 403 Forbidden for all URLs
DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
- I understand that I will be blocked if I intentionally remove or skip any mandatory* field
Checklist
- I’m reporting that yt-dlp is broken on a supported site
- I’ve verified that I’m running yt-dlp version 2023.06.22 (update instructions) or later (specify commit)
- I’ve checked that all provided URLs are playable in a browser with the same IP and same login details
- I’ve checked that all URLs and arguments with special characters are properly quoted or escaped
- I’ve searched known issues and the bugtracker for similar issues including closed ones. DO NOT post duplicates
- I’ve read the guidelines for opening an issue
- I’ve read about sharing account credentials and I’m willing to share it if required
Region
Brazil
Provide a description that is worded well enough to be understood
CR probably broke CR plugin… again.
I tryed to download lists for taking links for new episodes just to get a 403 error. Downloading episodes also don’t work anymore.
KODI plugin is working fine. Website is working fine. Tested the PS4 app and also working fine.
Provide verbose output that clearly demonstrates the problem
- Run your yt-dlp command with -vU flag added (
yt-dlp -vU <your command line>
) - If using API, add
'verbose': True
toYoutubeDL
params instead - Copy the WHOLE output (starting with
[debug] Command-line config
) and insert it below
Complete Verbose Output
The nightly verbose:
yt-dlp.exe -vU
[debug] Command-line config: ['-vU']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version nightly@2023.06.27.202841 [5b4b92769] (win_exe)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.22621-SP0 (OpenSSL 1.1.1k 25 Mar 2021)
[debug] exe versions: ffmpeg 2022-12-04-git-6c814093d8-full_build-www.gyan.dev (setts), ffprobe 2022-12-04-git-6c814093d8-full_build-www.gyan.dev
[debug] Optional libraries: Cryptodome-3.18.0, brotli-1.0.9, certifi-2023.05.07, mutagen-1.46.0, sqlite3-2.6.0, websockets-11.0.3
[debug] Proxy map: {}
[debug] Loaded 1852 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest
Available version: nightly@2023.06.27.202841, Current version: nightly@2023.06.27.202841
Current Build Hash: 9eb7dae08abf2a5c725c0635519bb9568f0892e6b2145850e16ecff62186b637
yt-dlp is up to date (nightly@2023.06.27.202841)
The output when trying to download anything (also for trying to retrieve playlist):
yt-dlp.exe -vU --cookies-from-browser vivaldi --sub-langs pt-BR --remux-video mkv --embed-subs -a "C:\animetemp\queue2.txt" -o "%(season)s - %(episode_number)s.%(ext)s" --paths "C:\animetemp"
[debug] Command-line config: ['-vU', '--cookies-from-browser', 'vivaldi', '--sub-langs', 'pt-BR', '--remux-video', 'mkv', '--embed-subs', '-a', 'C:\\animetemp\\queue2.txt', '-o', '%(season)s - %(episode_number)s.%(ext)s', '--paths', 'C:\\animetemp']
[debug] Batch file urls: ['https://www.crunchyroll.com/pt-br/watch/G0DUNJKE4/scrambling-and-dripping']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version nightly@2023.06.27.202841 [5b4b92769] (win_exe)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.22621-SP0 (OpenSSL 1.1.1k 25 Mar 2021)
[debug] exe versions: ffmpeg 2022-12-04-git-6c814093d8-full_build-www.gyan.dev (setts), ffprobe 2022-12-04-git-6c814093d8-full_build-www.gyan.dev
[debug] Optional libraries: Cryptodome-3.18.0, brotli-1.0.9, certifi-2023.05.07, mutagen-1.46.0, sqlite3-2.6.0, websockets-11.0.3
[Cookies] Extracting cookies from vivaldi
[debug] Extracting cookies from: "C:\Users\tamod\AppData\Local\Vivaldi\User Data\Default\Network\Cookies"
[debug] Found local state file at "C:\Users\tamod\AppData\Local\Vivaldi\User Data\Local State"
[Cookies] Extracted 2856 cookies from vivaldi
[debug] cookie version breakdown: {'v10': 2856, 'other': 0, 'unencrypted': 0}
[debug] Proxy map: {}
[debug] Loaded 1852 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest
Available version: nightly@2023.06.27.202841, Current version: nightly@2023.06.27.202841
Current Build Hash: 9eb7dae08abf2a5c725c0635519bb9568f0892e6b2145850e16ecff62186b637
yt-dlp is up to date (nightly@2023.06.27.202841)
[crunchyroll] Extracting URL: https://www.crunchyroll.com/pt-br/watch/G0DUNJKE4/scrambling-and-dripping
[crunchyroll] Retrieving main page (lang=pt-br/)
ERROR: [crunchyroll] G0DUNJKE4: Unable to download webpage: HTTP Error 403: Forbidden (caused by <HTTPError 403: 'Forbidden'>); please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U
File "yt_dlp\extractor\common.py", line 708, in extract
File "yt_dlp\extractor\crunchyroll.py", line 320, in _real_extract
File "yt_dlp\extractor\crunchyroll.py", line 114, in _call_api
File "yt_dlp\extractor\crunchyroll.py", line 99, in _call_base_api
File "yt_dlp\extractor\crunchyroll.py", line 69, in _update_query
File "yt_dlp\extractor\common.py", line 1111, in _download_webpage
File "yt_dlp\extractor\common.py", line 1062, in download_content
File "yt_dlp\extractor\common.py", line 896, in _download_webpage_handle
File "yt_dlp\extractor\common.py", line 853, in _request_webpage
File "yt_dlp\extractor\common.py", line 835, in _request_webpage
File "yt_dlp\YoutubeDL.py", line 3786, in urlopen
File "urllib\request.py", line 531, in open
File "urllib\request.py", line 640, in http_response
File "urllib\request.py", line 569, in error
File "urllib\request.py", line 502, in _call_chain
File "urllib\request.py", line 649, in http_error_default
urllib.error.HTTPError: HTTP Error 403: Forbidden
It's the same for version 2023.06.22.
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 149 (30 by maintainers)
The
initial state
extractor bug is being tracked in its own issue, and there is a patch available here: https://github.com/yt-dlp/yt-dlp/issues/7624#issuecomment-1638912586The 403 errors are coming from Cloudflare; their fingerprinting is determining that yt-dlp is not a web browser and blocking its requests to Crunchyroll.
There is a workaround for this. It requires cookies from a browser with the same IP address that you will be using with yt-dlp. Here are the steps:
Refresh your cookies in browser by loading a Crunchyroll video page until the video starts playing. If you have not done this within the past 30 minutes, you will need to do it again
Find your browser’s User-Agent string; you need the entire string (starting with
Mozilla/5.0
) and it needs to be up-to-date (i.e. if your browser updates, you’ll need to get its new UA string with the current version)about:support
chrome://version
(or your vendor prefix likebrave://version
, etc)Pass your browser’s user-agent to yt-dlp with
--user-agent "USERAGENT"
along with--cookies-from-browser firefox
USERAGENT
with your actual full user-agent string you got from step 2firefox
with the browser that you are using to browse Crunchyroll--cookies
option, e.g.--cookies cookies.txt
. Note that the cookies need to be exported from a fresh browser session (see step 1) within the past 30 minutes. See the wiki for browser extension recommendationsPS: If you get an
Unable to extract initial state
error, you need to runyt-dlp --update-to nightly
or install master branch with pipPPS: This appears to not work with MS edge. Use chrome/firefox
@Killua-Zolldyck a proper fix is being worked on currently
@Killua-Zolldyck having the same problem
Hmm. Crunchy went through a maintenance outage about an hour ago. Now I get this error message, no matter what I try. Looks like support for Crunchy is gone for the moment…
ERROR: [crunchyroll] G14U4WXJ9: Unable to extract initial state; please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U
Anyone else having this problem or is it just me?
EDIT: I’ve just opened Crunchy in my Edge Browser and the Crunchy Website displayed a message “Your device has been trusted.” or something like that (already closed the message and can’t reproduce it).
To clarify it to everyone: Crunchyroll has changed the access to the videos. You need a cookie that is at max. 30 minutes old and includes your login to the page. The cookie itself is updated everytime you open a CR Website in your browser. If you open a link with yt-dlp the cookies aren’t updated, because yt-dlp is not a browser itself and just uses the cookies of the browser you give in the options. And at least on my system, I have to use Firefox at the moment, because Edge does not work, even if I use --cookies-from-browser edge and the correct --user-agent option for my browser.
I don’t think, this can be updated in yt-dlp easily to work like before. yt-dlp isn’t a full feature web-browser and I wonder if it will be possible at all to keep the cookie updated by yt-dlp.
So as far as I see, there’s only one option to download from CR at this time:
If you know any other working scenario, feel free to report here.
@BraveSail got a working solution for that. It’s was the same here until I opened firefox.
@livelife68 I run 2 downloads at once. But not dare to try more than that.
edit: nightly release broke the season alias…
Switching from Edge to a clean install of Firefox did solve the problem for me. Just to let you know.
Edit: The usage of --user-agent was necessary to make it work on Firefox! Using --user-agent with Edge did not solve the problem.
https://github.com/yt-dlp/yt-dlp/commit/9b16762f48914de9ac914601769c76668e433325 has already been merged instead to solve the initial state removal and to hint towards the workaround.
A release is on it’s way, but like said above, nightly builds can be used instead if required. Use these if required.
Thanks @coletdjnz, this version https://github.com/coletdjnz/yt-dlp-dev/releases works great i can login and download premium content without worrying about cookies expiration or changing useragent on every update i used --impersonate chrome110, and i can confirm that its working with Firefox cookies text file (expires every 30 min) the only problem is with chrome cookies which i think Crunchyroll give different cookies for.
EDIT: --cookies-from-browser firefox never expires and you don’t need to open the browser
Found some issues in #7595 :
arm64
environment need to compile curl_cffi locally to install it. Maybe same as CPython? I’m not sure since I tested pypy first.video.hidive.com
when downloading the stream segment, even though hidive is not using cloudflare. (stable version is ok)#7632 is working for me using “–extractor-arg crunchyrollbeta:ua_workaround” option. Thanks a lot!
@Rafawell you need to add
ua_workaround
to your crunchyrollbeta extractor-args for the “old” way to work with this build e.g.--extractor-args "crunchyrollbeta:format=vo_adaptive_dash;ua_workaround"
or, if you aren’t passing any other extractor args:--extractor-args "crunchyrollbeta:ua_workaround"
Fixes for both the 403 and the initial state have been worked on in #7632, but they need testing.
A pre-release build is available: https://github.com/yt-dlp/yt-dlp/pull/7632#issuecomment-1641074939. Please test it and see if the fixes worked for you.
yt-dlp isn’t a real browser so it won’t update the cookies ever. Use firefox instead and the commands I wrote in my previous comment.
Oh sorry, i was in a hurry. I have tryed it with multiple browsers: chrome, brave, firefox All are the same. The cookies work for 30min after the last request the browser made (refreshing/loading a link, getting a video fragment) and inport into ytdlp. That means if you keep a video playing in the background and make ytdlp reload the cookies every 30 min, it would work no prob.
Need to reinstall chrome first - haven’t used chrome since ages. I’ll check.
Update: Unfortunately (?) downloading a video using --cookies-from-browser chrome works for me as well.
Did you pass Brave’s
--user-agent
, after visiting Crunchyroll at least once?It only adds the framework that would be needed to support this. Actually adding support would be quite a ways away.
Yes, adding support for Curl Impersonate is the ultimate solution to this problem. It can’t be added until https://github.com/yt-dlp/yt-dlp/pull/2861 is merged, but that PR is actually extremely close to being ready to be merged!
Use cookies and user agent from a legit browser. That worked for me.
You need to refresh the cookies directly on firefox. Open something and it’ll work again. yt-dlp need to implement this feature to work without this.
So i am on Windows 10 on Version 2023.06.22 of yt-dlp using following command (cookies on Firefox already remove and renewed for crunchyroll):
.\yt-dlp.exe -vU -f best --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0" --cookies-from-browser firefox --cookies .\auto_cookies.txt --ffmpeg-location .\ffmpeg\bin\ffmpeg.exe --batch-file .\links.txt
and trying to download some german dubbed episodes and getting the following error:
Anybody got any suggestions what the problem could be?
Update:
Ok it works now but not with the
--cookies-from-browser firefox
option. I’ve extracted the cookies with a browser addon on Firefox and used that cookie file and that worked. So the command that worked for me:.\yt-dlp.exe -vU -f best --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0" --cookies .\cookies.txt --ffmpeg-location .\ffmpeg\bin\ffmpeg.exe --batch-file .\links.txt
I suspect that the Crunchyroll Cookies have been shortened to be valid for only 30 minutes. I was able to get downloads using the --user-agent “USERAGENT” along with --cookies-from-browser firefox, however it started to fail about 30 minutes in to downloads.
[download] 100% of 1.38GiB in 00:03:32 at 6.65MiB/s [Metadata] Adding metadata to "downloads\Wandering_Witch_-_The_Journey_of_Elaina\01\002 - The_Land_of_Mages(8).mp4" [crunchyroll] Extracting URL: https://www.crunchyroll.com/watch/G14U4E27X/the-girl-as-pretty-as-a-flower--bottled-happiness [crunchyroll] Authenticating with grant_type=etp_rt_cookie ERROR: [crunchyroll] G14U4E27X: Unable to download JSON metadata: HTTP Error 403: Forbidden (caused by <HTTPError 403: 'Forbidden'>); please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U
I then refreshed Firefox and played a short video segment and then it allowed me to download again for 30 minutes before failing again (Approx 8 episodes). Rinse and repeat the actions.
If you are playing through a recognized browser the browser would automatically update the authentication cookie upon trying to play a video. yt-dlp does not automatically refresh cookies from the site.
I am now limiting myself to 7 - 8 downloads at a time. [Batch list/ not concurrenty]