yt-dlp Cheatsheet
Snehith,
yt-dlp is a feature-rich command-line audio/video downloader with support for thousands of sites. The project is a fork of youtube-dl based on the now inactive youtube-dlc. Since it is a CLI tool, its hyper extensible and and scriptable. Lets understand how it works, The yt-dlp github wiki is very nice and detailed but it can feel verbose at times for quick refernce, so here are few very useful commands:
Installing yt-dlp.
- Install
yt-dlp: You’ll need to installyt-dlpfirst. Instructions are on the official GitHub page: https://github.com/yt-dlp/yt-dlp - Update Regularly: YouTube changes frequently, so update
yt-dlpregularly to keep it working:pip install --upgrade yt-dlp - Legality: Be aware of copyright laws and YouTube’s Terms of Service. Downloading copyrighted content without permission may be illegal.
aria2c: If you use--external-downloader aria2c, make surearia2cis installed on your system.- Format Codes: Use
-Fto see the format codes available for a video. These codes are specific to each video.
Basic Usage
yt-dlp [OPTIONS] [--] URL [URL...]
Basic Downloads
yt-dlp <URL>: Downloads the video from the given URL. The simplest way to get a video.yt-dlp -F <URL>: Lists available formats (quality, resolution, codecs) for the video. See what you can download.yt-dlp -f <format_code> <URL>: Downloads a specific format (e.g.,137+140for video and audio). Use the output of-Fto find the format code.yt-dlp -o <filename> <URL>: Downloads and saves the video with a specified filename. (e.g.,-o "my_video.mp4").yt-dlp -o "%(title)s-%(id)s.%(ext)s" <URL>: Downloads and saves with a filename based on title and ID. Good for organization.
Quality & Format Selection
yt-dlp -f bv+ba <URL>: Downloads the b available video and audio streams and merges them. Generally gets the highest quality.yt-dlp -f "bv[ext=mp4]+ba[ext=m4a]/b[ext=mp4]/b" <URL>: Downloads b quality MP4 if available, otherwise tries other formats. More robust.yt-dlp -f "bv[height<=720]+ba/b[height<=720]/b" <URL>: Downloads the b video up to 720p, or the b available if not. Limits resolution.yt-dlp --limit-rate 2M <URL>: Limits download speed to 2MB/s. Useful for avoiding bandwidth issues.yt-dlp --external-downloader aria2c -o <filename> <URL>: Usesaria2cas the downloader for potentially faster downloads. Requiresaria2cto be installed.
Metadata & Information
yt-dlp --get-title <URL>: Gets only the video title.yt-dlp --get-description <URL>: Gets only the video description.yt-dlp --get-thumbnail <URL>: Gets the video thumbnail URL.yt-dlp --dump-json <URL>: Outputs all available information about the video in JSON format. Good for scripting.
Playlist & Channel Downloads
yt-dlp <Playlist_URL>: Downloads all videos in a playlist.yt-dlp <Channel_URL>: Downloads all videos from a YouTube channel.yt-dlp --playlist-start <index> <Playlist_URL>: Starts downloading a playlist from a specific video index.yt-dlp --playlist-end <index> <Playlist_URL>: Ends downloading a playlist at a specific video index.
Advanced & Useful Options
yt-dlp --cookies-from-browser browser_name <URL>: Uses cookies from a browser session to access content that requires login.yt-dlp --username <username> --password <password> <URL>: Provides username and password for login (less secure, use cookies if possible).yt-dlp --no-check-certificate <URL>: Disables SSL certificate verification. Use with caution (security risk).yt-dlp --ignore-errors <URL>: Continues downloading even if some videos fail.yt-dlp --no-overwrites <URL>: Prevents overwriting existing files.yt-dlp --split-into <parts> <URL>: Splits the download into multiple parts. Useful for unreliable connections.yt-dlp --sub-lang <language_code> <URL>: Downloads subtitles in a specific language (e.g.,--sub-lang enfor English).yt-dlp --write-auto-sub <URL>: Downloads auto-generated subtitles.yt-dlp --simulate <URL>: Simulates the download without actually downloading anything. Good for testing.`yt-dlp --help: ** Shows a comprehensive list of all available options. Your go-to reference!
My Favourite
yt-dlp -x --embed-metadata --embed-thumbnail -o "%(uploader)s/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s" <URL>: This command add cover art and add metadata to the audio file.
Tags:
Tech