CodeVetter · Repo Unpack · Feature catalog
yt-dlp/yt-dlp
The feature surface is one large optparse CLI plus the `YoutubeDL` Python API. Options are organized into ~15 groups (General, Network, Geo, Selection, Download, Filesystem, Thumbnail, Verbosity, Workarounds, Video Format, Subtitles, Authentication, Post-Processing, SponsorBlock, Extractor). Major features: per-site extraction with playlist/search support, format selection DSL, output templates, download archive dedup, browser-cookie and netrc authentication, TLS/browser impersonation, ffmpeg post-processing incl. SponsorBlock, external downloaders, plugins, JS runtimes/remote components for YouTube challenge solving, self-update, and extensive listing/simulation/JSON dump modes.
- The CLI is defined in `create_parser()` using optparse OptionGroups: General, Network, Geo-restriction, Video Selection, Download, Filesystem, Thumbnail, Internet Shortcut, Verbosity/Simulation, Workarounds, Video Format, Subtitle, Authentication, Post-Processing, SponsorBlock, Extractor Options.
- Config files are auto-loaded: `parseOpts` searches user/system config dirs for `yt-dlp.conf`, `config`, `config.txt` and supports `--ignore-config`; URLs come from argv, `-a/--batch-file` (including '-' for stdin).
- Format selection uses a DSL parsed by `build_format_selector` (e.g. 'b/bv', the test default) combined with `FormatSorter` sorting in `sort_formats`.
- Output naming is a template engine (`outtmpl`) supporting `%(field)s` expansion, defaults per type, sanitization, and literal `%%` — implemented in `parse_outtmpl`/`prepare_outtmpl`/`evaluate_outtmpl`.
- `--download-archive` deduplicates across runs: `_make_archive_id` builds `extractor_key video_id`, `in_download_archive` checks the in-memory set (plus `_old_archive_ids`), `record_download_archive` appends under `locked_file`.
- Authentication features: `--cookies-from-browser` supports brave/chrome/chromium/edge/opera/vivaldi/whale/firefox/safari with OS keyring decryption, `--cookies` Netscape files, and per-extractor username/password or netrc via `_NETRC_MACHINE`/`_perform_login`.
- Browser impersonation (`--impersonate`, `--list-impersonate-targets`) maps targets like chrome/safari/firefox/edge/tor to the curl_cffi request handler, with a rendered availability table in `_real_main`.
- Post-processing features include FFmpeg merge/extract-audio/remux/embed-subs/thumbnail & subtitle conversion/fixups/chapter splitting, SponsorBlock removal, metadata parsing, MoveFilesAfterDownload, and xattr writing.
- `--exec [WHEN:]CMD` runs user shell commands after chosen stages via `ExecPP`, which validates template expansion safety unless the `allow-unsafe-exec-expansion` compat opt is set.
- Self-update `-U/--update` supports channels stable/nightly/master (`UPDATE_SOURCES`) and `--update-to CHANNEL@TAG` for pinning.
- Listing/simulation outputs: `--list-extractors`, `--list-extractor-descriptions`, `-F/--list-formats` (render_formats_table), list-thumbnails/subtitles, `--simulate`, `--dump-json`/`--dump-single-json` via `sanitize_info`, and forced `--print`/`--print-to-file` machinery.
- Geo-restriction bypass fakes `X-Forwarded-For` with a random IP from a country or CIDR block (`--geo-bypass-country`, `--geo-bypass-ip-block`), initialized per-extractor and retried once on GeoRestrictedError.
- Plugin loading (`--plugin-dirs`, `--no-plugin-dirs`) imports `yt_dlp_plugins` namespace packages from config dirs, `yt-dlp-plugins` dirs, and PYTHONPATH — including inside zip/egg/whl archives.
- YouTube anti-bot support uses external JS runtimes (`--js-runtimes` deno/node/bun/quickjs registered in `supported_js_runtimes`) and downloadable remote components (`--remote-components ejs:github`/`ejs:npm`, plus the bundled `yt_dlp_ejs` wheel in 'extra' builds).