Downloading YouTube videos with yt-dlp
yt-dlp
is a powerful command-line tool for downloading videos from YouTube and other platforms. I frequently use it to save videos for offline viewing, particularly before long flights or to archive interesting content.
On macOS, you can install it using Homebrew:
brew install yt-dlp
Here’s the onfiguration that I use:
yt-dlp \
--cookies-from-browser safari
--format bestvideo+bestaudio
--merge-output-format mp4
-o "%(title)s.%(ext)s"
You can either supply these options through the command line or save them in a config file at ~/.config/yt-dlp/config
. The config file format is straightforward - just list the flags one per line:
--cookies-from-browser safari
--format bestvideo+bestaudio
--merge-output-format mp4
-o "%(title)s.%(ext)s"
Once configured, downloading a video is as simple as:
yt-dlp https://youtube.com/watch?v=...
The video will download in the highest available quality and save to your current directory.