Skip to content

Instantly share code, notes, and snippets.

@fasiha
Last active April 15, 2024 14:51
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save fasiha/3cde9ab6d2fec66f6df9c553554d63ed to your computer and use it in GitHub Desktop.
Save fasiha/3cde9ab6d2fec66f6df9c553554d63ed to your computer and use it in GitHub Desktop.
Youtube-dl with Crunchyroll

Get the following:

  • a Crunchyroll account (though they let you watch/download some videos without an account, at 480p),
  • the latest youtube-dl (brew upgrade youtube-dl),
  • your browser’s user agent,
  • your Crunchyroll cookies (cookie.txt export for Chrome is handy) into a cookies.txt file.

Then,

$ youtube-dl "http://www.crunchyroll.com/recovery-of-an-mmo-junkie/episode-4-like-a-maiden-in-love-749529" \
    --all-subs \
    -u "ENTER_EMAIL_ADDRESS" \
    -p "ENTER_PASSWORD" \
    --user-agent "ENTER_USER_AGENT" \
    --cookies cookies.txt

If an error related to the cookies file is thrown, note: I had to replace all the decimal expiration timestamps in cookies.txt with the integer versions (so 123.456 becomes 123), and be sure to add # Netscape HTTP Cookie File to the top (source).

If VLC cannot display the subtitles, it may be because the font used in the ASS subtitle file is for some reason unavailable, i.e., Trebuchet MS on macOS. Option 1: add --sub-format "srt" flag to the youtube-dl invocation to get dumb SRT subtitles (no styles, no speaker information, etc.). Option 2: edit the ASS file and replace the offending fonts with other ones (e.g., Trebuchet MS to Avenir on macOS). (Also useful for this issue: --skip-download will skip downloading the video and only download the subtitles.)

@Bhavya031
Copy link

Bhavya031 commented Jul 22, 2023

Hey, I just don't want to give you a bunch of lines of errors, but can you help me with this?

crunchyroll] 749529: Downloading webpage
WARNING: unable to extract OpenGraph description; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "/opt/homebrew/bin/youtube-dl", line 33, in <module>
    sys.exit(load_entry_point('youtube-dl==2021.12.17', 'console_scripts', 'youtube-dl')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.11/site-packages/youtube_dl/__init__.py", line 475, in main
    _real_main(argv)
  File "/opt/homebrew/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.11/site-packages/youtube_dl/__init__.py", line 465, in _real_main
    retcode = ydl.download(all_urls)
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.11/site-packages/youtube_dl/YoutubeDL.py", line 2068, in download
    res = self.extract_info(
          ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.11/site-packages/youtube_dl/YoutubeDL.py", line 808, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.11/site-packages/youtube_dl/YoutubeDL.py", line 815, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.11/site-packages/youtube_dl/YoutubeDL.py", line 836, in __extract_info
    ie_result = ie.extract(url)
                ^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.11/site-packages/youtube_dl/extractor/common.py", line 534, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.11/site-packages/youtube_dl/extractor/crunchyroll.py", line 456, in _real_extract
    video_title = re.sub(r'^Watch\s+', '', self._og_search_description(webpage))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/__init__.py", line 185, in sub
    return _compile(pattern, flags).sub(repl, string, count)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'

@fasiha
Copy link
Author

fasiha commented Jul 28, 2023

@Bhavya031 hmm, my first instinct would be to try yt-dlp (their "known issues" thread suggests Crunchyroll should work with it)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment