Download videos on the Mac using Terminal

I'm using yt-dlp to download videos from the internet. If you didn't know it: very actively maintained project that just downloads basically any video or media content. It's like a swiss army knife for these types of things. I used it basically ever since it came out.

Not only that but I have developed and improved a small wrapper around it which makes it even easier to use. Enter ydl which is the macOS friendly downloader. What it does is it takes the clipboard contents (a website URL, such as a YouTube link) and downloads the best possible version the site serves. If VP9 is served, then it re-encodes that to MP4. If you can't download something because you need to be a logged in user, you can tell which browser you used and it will use that cookie to authenticate. Very convenient.

Here is how to install it:

  1. install Homebrew — if you didn't have this already, this is a package manager for macOS, visit the URL and install it as described
  2. brew install ffmpeg — we will need this for encoding (you may also have this installed already)
  3. brew install yt-dlp — the downloader itself
  4. curl -fsSL https://gist.githubusercontent.com/raw/7d32c10cf595b20dd968d0a3a7c745b9 -o /usr/local/bin/ydl && chmod +x /usr/local/bin/ydl — finally, my little script (this command will download it and copy to /usr/local/bin so it's always available system wide as a command)

Usage: open a new Terminal window, navigate to the folder of your choosing, and run ydl — it will automatically download whatever URL is in your clipboard. It does some sanity checking, so only http://https://, or ftp:// URLs will work. You can also pass the URL explicitly, e.g. ydl 'URL'.

As an example, say you have this video in mind, that you'd like to keep in your archives.

You click in the browser address bar, copy, open Terminal, ydl and press Enter. That is it. Take any YouTube video link, Instagram reel, a traditional broadcast station's URL — all will work.

Why is it different than using yt-dlp the exact same way?

Great question! It will always select the best possible Mac-friendly version and if it was encoded as a VP9 video, it will re-encode as MP4 (also something that makes it very convenient on the Mac to use). You can also pass the browser you were logged in with if it needs an authenticated user. For example, if x.com link above required a logged in user then you could've just entered ydl -c and presto! (It takes Safari as the default browser name, but you can pass ydl -c chrome etc.)

Here is the full help:

jozsi@jozsimini ~ % ydl -h
ydl 1.2.1
Usage: ydl [-c [browser]] ['URL'] [extra yt-dlp args...]

Downloads the best available video using yt-dlp, preferring H.264/H.265.
If no URL is given, reads from clipboard.
VP9 videos are automatically re-encoded to H.264.

URL should be wrapped in quotes to avoid shell interpretation.

Options:
  -c [browser]  Use cookies from browser (default: safari)
  -h            Show this help

Enjoy!