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...]

Common usage examples:
yt-dlp https://www.youtube.com/watch?v=VIDEO_ID
yt-dlp -f bestvideo[ext=mp4]+bestaudio[ext=m4a] -o "%(title)s.%(ext)s" URL
yt-dlp --extract-audio --audio-format mp3 URL
yt-dlp --write-subs --all-subs --embed-subs URL

PARAMETERS

-f, --format FORMAT
    Selects the desired video and/or audio format.

-o, --output TEMPLATE
    Specifies the output filename template.

-x, --extract-audio
    Extracts only the audio from the video.

--audio-format FORMAT
    Specifies the audio format to convert to when extracting audio (e.g., mp3, aac).

--write-subs, --write-auto-subs
    Downloads available subtitles or auto-generated captions.

--all-subs
    Downloads all available subtitles for the video.

--embed-subs
    Embeds subtitles into the video file (requires ffmpeg).

--write-thumbnail
    Downloads the video thumbnail.

--embed-thumbnail
    Embeds the thumbnail into the video file.

--ignore-errors
    Continues downloading other videos in a playlist even if one fails.

--playlist-start NUMBER
    Starts downloading a playlist from a specific entry.

--playlist-end NUMBER
    Ends downloading a playlist at a specific entry.

--abort-on-error
    Aborts the entire operation if a download error occurs.

--restrict-filenames
    Restricts filenames to only ASCII characters and avoids special characters.

--dump-json
    Prints video information in JSON format and does not download.

-U, --update
    Updates the yt-dlp executable to the latest version.

-v, --verbose
    Prints verbose debugging information.

--proxy URL
    Uses a specified HTTP/SOCKS proxy.

--user-agent UA
    Specifies a custom User-Agent header.

--force-ipv4, --force-ipv6
    Forces yt-dlp to use IPv4 or IPv6 respectively.

DESCRIPTION

yt-dlp is a free and open-source command-line program for downloading videos and audio from over 1000 websites. It is a fork of the popular youtube-dl project, created to address its slower development pace and to introduce new features and improvements.

It offers extensive customization options for video and audio formats, resolution, quality, and output filenames. Key features include support for playlists, entire channels, embedding metadata, downloading subtitles (including auto-generated ones), and integrating with external tools like ffmpeg for post-processing (e.g., converting formats, extracting audio). yt-dlp also boasts advanced features such as SponsorBlock integration for skipping unwanted segments, parallel downloads, and the ability to handle various authentication methods. Its robust nature and active development make it a versatile tool for media acquisition, respecting user-defined preferences and offering granular control over the download process.

CAVEATS

Legal and ethical considerations: Downloading copyrighted material without permission may be illegal in some jurisdictions. Users are responsible for ensuring their usage complies with copyright laws and terms of service of the respective platforms.

Reliance on external tools: For certain features like format conversion, embedding, or specific post-processing, yt-dlp often requires ffmpeg or ffprobe to be installed and accessible in the system's PATH.

Website changes: Video hosting sites frequently update their structures and APIs, which can sometimes temporarily break yt-dlp's ability to download from them until an update is released.

CONFIGURATION FILE

Users can create a configuration file (typically ~/.config/yt-dlp/config or ~/.yt-dlp.conf) to define default options and arguments that yt-dlp will use every time it runs. This is useful for consistently applying preferred settings without typing them out for each command.

SPONSORBLOCK INTEGRATION

yt-dlp includes native support for SponsorBlock, allowing users to automatically skip sponsored segments, introductions, outros, and other unwanted parts of videos during playback or even during the download process itself by applying post-processing.

HISTORY

yt-dlp emerged as a fork of the widely used youtube-dl project. The motivation behind its creation was the perceived stagnation of youtube-dl's development, with long-standing issues and feature requests going unaddressed. The yt-dlp project aimed to provide a more actively maintained and feature-rich alternative, quickly integrating new extractors, bug fixes, and advanced functionalities like SponsorBlock and parallel downloads. It has since gained significant popularity and is now often recommended as the preferred choice over its predecessor due to its robust and up-to-date capabilities.

SEE ALSO

youtube-dl(1), ffmpeg(1), wget(1), curl(1)

Copied to clipboard