Skip to content

Instantly share code, notes, and snippets.

@marco-mamani
Created November 20, 2023 15:08
Show Gist options
  • Save marco-mamani/331eb3e9ea6a489fbd805d97f97a59bf to your computer and use it in GitHub Desktop.
Save marco-mamani/331eb3e9ea6a489fbd805d97f97a59bf to your computer and use it in GitHub Desktop.
youtube-dl cheat sheat

To download a video in 720p MP4:

youtube-dl -f 22 example.com/watch?v=id

To download a video in 720p MP4 or WebM or FLV:

youtube-dl -f 22/45/120

To list all available formats of a video:

youtube-dl -F example.com/watch?v=id

To download a video to /$uploader/$date/$title.$ext:

youtube-dl -o '%(uploader)s/%(date)s/%(title)s.%(ext)s' example.com/watch?v=id

To download a video playlist starting from a certain video:

youtube-dl --playlist-start 5 example.com/watch?v=id&list=listid

To simulate a download with youtube-dl:

youtube-dl -s example.com/watch?v=id

To download audio in mp3 format with best quality available

youtube-dl --extract-audio --audio-format mp3 --audio-quality 0 example.com/watch?v=id

For all video formats see link below (unfold "Comparison of YouTube media encoding options")

tldr:youtube-dl

youtube-dl

Download videos from YouTube and other websites.

Download a video or playlist:

youtube-dl 'https://www.youtube.com/watch?v=oHg5SJYRHA0'

List all formats that a video or playlist is available in:

youtube-dl --list-formats 'https://www.youtube.com/watch?v=Mwa0_nE9H7A'

Download a video or playlist at a specific quality:

youtube-dl --format "best[height<=480]" 'https://www.youtube.com/watch?v=oHg5SJYRHA0'

Download the audio from a video and convert it to an MP3:

youtube-dl -x --audio-format mp3 'url'

Download the best quality audio and video and merge them:

youtube-dl -f bestvideo+bestaudio 'url'

Download video(s) as MP4 files with custom filenames:

youtube-dl --format mp4 -o "%(playlist_index)s-%(title)s by %(uploader)s on %(upload_date)s in %(playlist)s.%(ext)s" 'url'

Download a particular language's subtitles along with the video:

youtube-dl --sub-lang en --write-sub 'https://www.youtube.com/watch?v=Mwa0_nE9H7A'

Download a playlist and extract MP3s from it:

youtube-dl -f "bestaudio" --continue --no-overwrites --ignore-errors --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" url_to_playlist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment