Bonnie Eisenman bio photo

Bonnie Eisenman

Software engineer, author, knitter, Esperantist. Member of NYC Resistor and author of Learning React Native.

🐦 Twitter πŸ€– Github πŸ”Ά RSS Feed

I subscribe to several Patreons that offer paywalled video content. Some of these are reference materials that I might want to re-watch over and over again, and I find it annoying to have to stream them when I could just download the videos and have them available offline. There are loads of sketchy Chrome and Firefox extensions that purport to let you download these videos, but most of them 1) don’t work and 2) require very broad permissions. Eventually Reddit led me to a command-line tool that I strongly preferred.

yt-dlp is a CLI tool for downloading video and audio streams. It supports many different sites, including Vimeo and Patreon. You’ll also need ffmpeg installed for best results. Here are some notes on my personal usage of it.

My typical command looks like this:

yt-dlp --cookies-from-browser firefox "https://www.patreon.com/posts/POST-ID-HERE" -f "bv*[height<=640]+ba" --prefer-free-formats 

Breaking this down:

--cookies-from-browser firefox does what it sounds like: uses cookies from Firefox. This means, e.g., that if you’re logged in to Patreon, yt-dlp will use those cookies.

The next argument is the URL for the video you’re trying to download. I’ve been downloading videos from individual posts, but supposedly you can also have it download all available videos from a feed. I haven’t bothered figuring that out yet.

The -f flag is used to select which format you want. I found the formatting options to be pretty arcane, to be honest. Most video players these days offer a lot of different video and audio formats. You can see the available formats by using the --list-formats flag:

yt-dlp --cookies-from-browser firefox "https://www.patreon.com/posts/POST-ID-HERE" -v --list-formats

[info] Available formats for 800787707:
ID                                                EXT RESOLUTION FPS β”‚   FILESIZE   TBR PROTO β”‚ VCODEC        VBR ACODEC      ABR ASR MORE INFO
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
hls-akfire_interconnect_quic_sep-audio-high-audio mp4 audio only     β”‚                  m3u8  β”‚ audio only        unknown             audio
hls-fastly_skyfire_sep-audio-high-audio           mp4 audio only     β”‚                  m3u8  β”‚ audio only        unknown             audio
dash-akfire_interconnect_quic_sep-audio-fef31d49  m4a audio only     β”‚ ~ 31.66MiB  191k dash  β”‚ audio only        mp4a.40.2  191k 48k DASH audio, m4a_dash
dash-akfire_interconnect_quic_sep-audio-0ef89a72  m4a audio only     β”‚ ~ 11.11MiB   67k dash  β”‚ audio only        opus        67k 48k DASH audio, m4a_dash
hls-akfire_interconnect_quic-312                  mp4 426x240     30 β”‚ ~ 51.72MiB  312k m3u8  β”‚ avc1.640015  312k video only
dash-fastly_skyfire_sep-video-754f8367            mp4 426x240     30 β”‚ ~ 56.86MiB  343k dash  β”‚ avc1.640015  343k video only          DASH video, mp4_dash
hls-akfire_interconnect_quic-4989                 mp4 1920x1080   30 β”‚ ~827.03MiB 4989k m3u8  β”‚ avc1.64002A 4989k video only

Luckily there’s an extensive example section in the yt-dlp FAQ.

# Download best format that contains video,
# and if it doesn't already have an audio stream, merge it with best audio-only format
$ yt-dlp -f "bv*+ba/b"

By using the flag -f "bv*[height<=640]+ba", we request the best video format with a height <= 640 pixels, and the best audio format. yt-dlp will merge them into one file.

Finally, the --prefer-free-formats flag is necessary to avoid crashing on an error. This is tracked in issue 4838 and may just be an intermittent Vimeo problem? Unclear.

I love finding new CLI tools that just work.