Skip to content

Instantly share code, notes, and snippets.

@ILoveBacteria
Last active August 31, 2024 06:08
Show Gist options
  • Save ILoveBacteria/dd8edf20dc68368170d27a7baa88ecfe to your computer and use it in GitHub Desktop.
Save ILoveBacteria/dd8edf20dc68368170d27a7baa88ecfe to your computer and use it in GitHub Desktop.
The most useful flags for yt-dlp

USAGE AND OPTIONS

General Options

--flat-playlist                 Do not extract the videos of a playlist,
                                only list them

--live-from-start               Download livestreams from the start.
                                Currently only supported for YouTube
                                (Experimental)

--no-live-from-start            Download livestreams from the current time
                                (default)

Video Selection

-I, --playlist-items ITEM_SPEC  Comma separated playlist_index of the items
                                to download. You can specify a range using
                                "[START]:[STOP][:STEP]". For backward
                                compatibility, START-STOP is also supported.
                                Use negative indices to count from the right
                                and negative STEP to download in reverse
                                order. E.g. "-I 1:3,7,-5::2" used on a
                                playlist of size 15 will download the items
                                at index 1,2,3,7,11,13,15

--min-filesize SIZE             Abort download if filesize is smaller than
                                SIZE, e.g. 50k or 44.6M

--max-filesize SIZE             Abort download if filesize is larger than
                                SIZE, e.g. 50k or 44.6M

--date DATE                     Download only videos uploaded on this date.
                                The date can be "YYYYMMDD" or in the format 
                                [now|today|yesterday][-N[day|week|month|year]].
                                E.g. "--date today-2weeks" downloads only
                                videos uploaded on the same day two weeks ago

--datebefore DATE               Download only videos uploaded on or before
                                this date. The date formats accepted is the
                                same as --date

--dateafter DATE                Download only videos uploaded on or after
                                this date. The date formats accepted is the
                                same as --date

Download Options

--skip-download                 Do not download the video but write all
                                related files (Alias: --no-download)

-r, --limit-rate RATE           Maximum download rate in bytes per second,
                                e.g. 50K or 4.2M

Filesystem Options

-a, --batch-file FILE           File containing URLs to download ("-" for
                                stdin), one URL per line. Lines starting
                                with "#", ";" or "]" are considered as
                                comments and ignored

--write-description             Write video description to a .description file

--write-comments                Retrieve video comments to be placed in the
                                infojson. The comments are fetched even
                                without this option if the extraction is
                                known to be quick (Alias: --get-comments)
                                
--write-info-json               Write video metadata to a .info.json file
                                (this may contain personal information)

Verbosity and Simulation Options

-s, --simulate                  Do not download the video and do not write
                                anything to disk

-j, --dump-json                 Quiet, but print JSON information for each
                                video. Simulate unless --no-simulate is
                                used. See "OUTPUT TEMPLATE" for a
                                description of available keys

-J, --dump-single-json          Quiet, but print JSON information for each
                                url or infojson passed. Simulate unless
                                --no-simulate is used. If the URL refers to
                                a playlist, the whole playlist information
                                is dumped in a single line

Workarounds

--sleep-requests SECONDS        Number of seconds to sleep between requests
                                during data extraction

--sleep-interval SECONDS        Number of seconds to sleep before each
                                download. This is the minimum time to sleep
                                when used along with --max-sleep-interval
                                (Alias: --min-sleep-interval)

--max-sleep-interval SECONDS    Maximum number of seconds to sleep. Can only
                                be used along with --min-sleep-interval

--sleep-subtitles SECONDS       Number of seconds to sleep before each
                                subtitle download

Video Format Options

-F, --list-formats              List available formats of each video.
                                Simulate unless --no-simulate is used

Subtitle Options

--write-subs                    Write subtitle file

--list-subs                     List available subtitles of each video.
                                Simulate unless --no-simulate is used

--sub-format FORMAT             Subtitle format; accepts formats preference,
                                e.g. "srt" or "ass/srt/best"

--sub-langs LANGS               Languages of the subtitles to download (can
                                be regex) or "all" separated by commas, e.g.
                                --sub-langs "en.*,ja". You can prefix the
                                language code with a "-" to exclude it from
                                the requested languages, e.g. --sub-langs
                                all,-live_chat. Use --list-subs for a list
                                of available language tags

Post-Processing Options

-x, --extract-audio             Convert video files to audio-only files
                                (requires ffmpeg and ffprobe)

--audio-format FORMAT           Format to convert the audio to when -x is
                                used. (currently supported: best (default),
                                aac, alac, flac, m4a, mp3, opus, vorbis,
                                wav). You can specify multiple rules using
                                similar syntax as --remux-video

--embed-subs                    Embed subtitles in the video (only for mp4,
                                webm and mkv videos)

--embed-thumbnail               Embed thumbnail in the video as cover art

--embed-metadata                Embed metadata to the video file. Also
                                embeds chapters/infojson if present unless
                                --no-embed-chapters/--no-embed-info-json are
                                used (Alias: --add-metadata)

--convert-subs FORMAT           Convert the subtitles to another format
                                (currently supported: ass, lrc, srt, vtt)
                                (Alias: --convert-subtitles)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment