Skip to content

Instantly share code, notes, and snippets.

@vogler
Last active August 21, 2022 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vogler/5661b400a63e4c2437bc81a153ac454f to your computer and use it in GitHub Desktop.
Save vogler/5661b400a63e4c2437bc81a153ac454f to your computer and use it in GitHub Desktop.
Chrome OS: download YouTube Watch later videos

Download YouTube Watch later videos on Chrome OS

The command I use on macOS fails on Chrome OS since the Linux container can not access the Chrome profile to get the cookies:

$ yt-dlp --cookies-from-browser chrome --max-downloads 10 --sponsorblock-remove default :ytwatchlater
[Cookies] Extracting cookies from chrome
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/bin/yt-dlp/__main__.py", line 17, in <module>
  File "/usr/local/bin/yt-dlp/yt_dlp/__init__.py", line 953, in main
  File "/usr/local/bin/yt-dlp/yt_dlp/__init__.py", line 915, in _real_main
  File "/usr/local/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 715, in __init__
  File "/usr/local/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 3764, in _setup_opener
  File "/usr/local/bin/yt-dlp/yt_dlp/cookies.py", line 89, in load_cookies
  File "/usr/local/bin/yt-dlp/yt_dlp/cookies.py", line 110, in extract_cookies_from_browser
  File "/usr/local/bin/yt-dlp/yt_dlp/cookies.py", line 246, in _extract_chrome_cookies
FileNotFoundError: could not find chrome cookies database in "/home/voglerr/.config/google-chrome"

According to chrome://version/ 'Profile Path' is /home/chronos/u-9... and unsurprisingly this is not mapped into the Linux container:

la /home /mnt/chromeos 
/home:
total 0
drwxr-xr-x 1 voglerr voglerr 620 Aug 21 15:41 voglerr

/mnt/chromeos:
total 4.0K
drwxr-xr-x 14 nobody nogroup 4.0K Jul 31 07:00 fonts

Besides --cookies-from-browser chrome, yt-dlp also has --cookies FILE ('Netscape formatted file to read cookies from and dump cookie jar in').

Can't just copy from Chrome Dev Tools, but need to convert to Netscape format via https://github.com/dandv/convert-chrome-cookies-to-netscape-format

  • Create folder in Files app, right click > Share with Linux - we don't want to fill up the 6.3GB free on the 10GB container (running out of space somehow broke the container (freed up space, still did not start new shells, reboot, it created a new user, old one did not work anymore))
  • cd /mnt/chromeos/MyFiles/yt-dlp (depends on which folder you created)
  • Visit https://www.youtube.com/playlist?list=WL
  • Chrome Dev Tools (Ctrl-Shift-I) > Application > Storage > Cookies
  • Select all, right click, Copy, Paste into cookies-ch
  • node convert-chrome-cookies-to-netscape-format/convert-cookies.js cookies-ch > cookies-ns
  • yt-dlp --cookies cookies-ns --max-downloads 10 :ytwatchlater

fix sponsorblock postprocessing with ffmpeg

Due to a bug in ffmpeg (cut/merge of VP9 videos, yt-dlp issue), --sponsorblock-remove did not work and left behind temporary files. The bug is present after version 3.0.1 and before version 5.1. Debian bullseye version is 4.3.4, snap is even 4.3.1. The following will download a patched version of ffmpeg (no need for ffplay, ffprobe) from https://github.com/yt-dlp/FFmpeg-Builds to /usr/local/bin which fixes the sponsorblock issue for yt-dlp.

  • cd /usr/local/bin && wget -qO- https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz | sudo tar -xJ ffmpeg-master-latest-linux64-gpl/bin/ffmpeg --strip-components 2
  • yt-dlp --cookies cookies-ns --max-downloads 10 --sponsorblock-remove default :ytwatchlater
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment