Downloads from Terminal: ydl

I use yt-dlp to download videos from the internet. It is a very actively maintained project that can download basically any video or media file, and I have used it almost since it came out. It is the Swiss Army knife for this kind of thing.

I also built a small wrapper around it to make it easier to use. Enter ydl, my macOS-friendly downloader. It takes the URL from your clipboard, such as a YouTube link, and downloads the best available version. If the video is served as VP9, it re-encodes it to MP4. If a site needs you to be logged in, you can tell it which browser to use and it will authenticate with that browser’s cookies. Very convenient.

Here is how to install it:

  1. Install Homebrew — if you do not already have it, Homebrew is a package manager for macOS. Visit the site and follow the installation instructions.
  2. brew install ffmpeg — this handles the video encoding step. You may already have it installed.
  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, install ydl. This downloads my little script to /usr/local/bin and makes it available as a system-wide command.

To use it, open Terminal, navigate to the folder where you want the download to go, and run ydl. It will 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 a URL explicitly: ydl 'URL'.

For example, say you found this video and want to keep it in your archives.

Copy the URL from your browser, open Terminal, run ydl, and press Enter. That is it. YouTube links, Instagram reels, traditional broadcast station URLs — they should all work.

Why not just use yt-dlp directly?

Great question! ydl always tries to download the best Mac-friendly version. If the video is encoded as VP9, it re-encodes it to MP4, which makes the result easier to use on a Mac. It can also use your browser cookies for sites that require a logged-in user. For instance, if the X link above needed authentication, you could enter ydl -c and presto. Safari is the default browser, but you can also pass ydl -c chrome, etc.

Here is the full command 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!