LinuxCommandLibrary

yt-dlp

Download videos from online platforms

TLDR

Download a video or playlist (with the default options from command below)

$ yt-dlp "[https://www.youtube.com/watch?v=oHg5SJYRHA0]"
copy

List the available downloadable formats for a video
$ yt-dlp [[-F|--list-formats]] "[https://www.youtube.com/watch?v=oHg5SJYRHA0]"
copy

Download a video or playlist using the best MP4 video available (default is "bv\*+ba/b")
$ yt-dlp [[-f|--format]] "[bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4]]" "[https://www.youtube.com/watch?v=oHg5SJYRHA0]"
copy

Extract audio from a video (requires ffmpeg or ffprobe)
$ yt-dlp [[-x|--extract-audio]] "[https://www.youtube.com/watch?v=oHg5SJYRHA0]"
copy

Specify audio format and audio quality of extracted audio (between 0 (best) and 10 (worst), default = 5)
$ yt-dlp [[-x|--extract-audio]] --audio-format [mp3] --audio-quality [0] "[https://www.youtube.com/watch?v=oHg5SJYRHA0]"
copy

Download only the second, fourth, fifth, sixth, and last items in a playlist (the first item is 1, not 0)
$ yt-dlp [[-I|--playlist-items]] 2,4:6,-1 "[https://youtube.com/playlist?list=PLbzoR-pLrL6pTJfLQ3UwtB-3V4fimdqnA]"
copy

Download all playlists of a YouTube channel/user keeping each playlist in a separate directory
$ yt-dlp [[-o|--output]] "[%(uploader)s/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s]" "[https://www.youtube.com/user/TheLinuxFoundation/playlists]"
copy

Download a Udemy course keeping each chapter in a separate directory
$ yt-dlp [[-u|--username]] [user] [[-p|--password]] [password] [[-P|--paths]] "[path/to/directory]" [[-o|--output]] "[%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s]" "[https://www.udemy.com/java-tutorial]"
copy

SYNOPSIS

yt-dlp [OPTIONS] URL [URL ...]

PARAMETERS

-h, --help
    Show detailed help message and exit

--version
    Show program version

-U, --update
    Update yt-dlp to latest version

-v, --verbose
    Increase verbosity (repeatable)

-q, --quiet
    Activate quiet mode

-i, --ignore-errors
    Continue downloads on errors

--abort-on-error
    Abort downloading on first error

--no-warnings
    Ignore warnings

-o, --output TEMPLATE
    Output filename template, e.g., %(title)s.%(ext)s

-f, --format FORMAT
    Video/audio format selector, e.g., bestvideo+bestaudio

-F, --list-formats
    List available formats for given URL

-S, --format-sort SORT
    Sort formats, e.g., res:1080

--flat-playlist
    Do not extract playlist/URLs

--yes-playlist
    Force download as playlist

--no-playlist
    Download single video from playlist

-a, --batch-file FILE
    File containing list of URLs

--cookies COOKIES.txt
    Browser cookies file for auth

-r, --limit-rate RATE
    Max download rate, e.g., 50K

--user-agent UA
    Override User-Agent header

--referer URL
    Referer URL

--add-header HEADER
    Add custom HTTP header

-j, --dump-json
    Print JSON info per video (no download)

--write-info-json
    Write video metadata to .info.json

--write-subs
    Write subtitle file

--embed-subs
    Embed subtitles in video

DESCRIPTION

yt-dlp is a robust, open-source command-line tool for downloading audio and video content from YouTube and over 10,000 other websites. Forked from youtube-dl in 2021, it receives active development, supporting more extractors, formats, and features like automatic updates, sponsorblock integration, and advanced post-processing.

Core features include format selection by quality/resolution, playlist/channel downloads, subtitle extraction in multiple languages, thumbnail/metadata embedding, and conversion/merging with FFmpeg. It handles age-restricted content via cookies or accounts, rate limiting, parallel fragments, and custom output templates for organized files.

Highly configurable via files (~/.config/yt-dlp/config), it's scriptable for automation, lightweight, and cross-platform. Install via pip install -U yt-dlp or Linux repos. Regular yt-dlp -U keeps it current against site changes.

Ideal for archivists, researchers, and bulk downloaders, but respect site ToS and robots.txt.

CAVEATS

Sites may block requests; run yt-dlp -U often. Needs FFmpeg for merging/conversions. Respect ToS; no warranty on private/paywalled content.

CONFIGURATION

Default options in $XDG_CONFIG_HOME/yt-dlp/config or ~/.config/yt-dlp/config; one per line, e.g., -f bestvideo+bestaudio.

INSTALLATION

Linux: pipx install yt-dlp or distro repo. Update: yt-dlp -U.

POST-PROCESSING

Auto-invokes FFmpeg for muxing, thumbnails, metadata. Install FFmpeg separately.

HISTORY

Forked from youtube-dl in Oct 2021 amid stalled upstream development. yt-dlp team added 1000+ new extractors, SponsorBlock, ARI support. Now dominant tool with 50k+ GitHub stars, daily updates.

SEE ALSO

ffmpeg(1), curl(1), wget(1)

Copied to clipboard