Knowledge Base updated: 2026-11-16
Knowledge Base Index
Orientation
yt-dlp is a Python command-line downloader: CLI/config parsing builds runtime parameters, YoutubeDL orchestrates URL extraction, format selection, download backends, and post-processing.
Main parts:
- yt_dlp/YoutubeDL.py — central runtime orchestration and lifecycle.
yt_dlp/extractor/**— URL matching and metadata extraction for supported sites.yt_dlp/downloader/**— protocol-specific media download backends.yt_dlp/networking/**— request/response abstraction and transport handlers.yt_dlp/postprocessor/**— post-download transformations and file finalization.devscripts/**,bundle/**, and project metadata — build, release, generated docs, and test-maintenance tooling.
Critical state lives mostly on disk rather than in a server-side datastore:
- Download outputs, temporary fragments, archives, thumbnails, subtitles, and postprocessor artifacts are filesystem state managed by
YoutubeDL, downloaders, and postprocessors. - Cache data is managed by yt_dlp/cache.py.
- Cookies and credentials are loaded from browser stores, cookie files, and netrc-style sources through the cookies/auth modules.
- There is no application database, queue, or long-running service process in this repository.
Architecture diagrams
flowchart TD
User[CLI or python -m yt_dlp] --> CLI[yt_dlp.__init__ / __main__ / options]
CLI --> Core[YoutubeDL]
subgraph Runtime[yt_dlp runtime]
Core --> Extractors[extractor framework and site extractors]
Core --> Downloaders[downloader backends]
Core --> PostProcessors[postprocessor pipeline]
Core --> Cache[cache]
Core --> Cookies[cookies and auth]
Extractors --> JS[JS / crypto / text parsers]
Extractors --> Networking[networking stack]
Downloaders --> Networking
PostProcessors --> FFmpeg[external tools such as ffmpeg]
Core --> Utils[utils and compat]
end
subgraph Tooling[repository tooling]
Tests[test harness]
Devscripts[devscripts]
Bundle[bundle / packaging]
end
Devscripts --> Extractors
Devscripts --> Bundle
Tests --> Runtime
flowchart LR
Args[CLI args and config files] --> Options[yt_dlp/options.py]
Options --> Params[YoutubeDL params]
Params --> YDL[YoutubeDL]
YDL --> Match[select InfoExtractor]
Match --> Extract[extract info dicts]
Extract --> Select[format and playlist processing]
Select --> Download[downloader selection]
Download --> Post[postprocessor stages]
Post --> Files[final files and metadata]
sequenceDiagram
participant YDL as YoutubeDL
participant IE as InfoExtractor
participant Net as networking stack
participant DL as downloader backend
participant PP as postprocessors
YDL->>IE: choose extractor and extract URL
IE->>Net: issue HTTP/API requests
Net-->>IE: response data
IE-->>YDL: info dict / playlist entries
YDL->>DL: download selected formats
DL->>Net: fetch media/fragments
DL-->>YDL: downloaded files and status
YDL->>PP: run configured stages
PP-->>YDL: updated info dict and final paths
flowchart TD
Source[Source tree] --> Tests[test/*.py]
Source --> Scripts[devscripts]
Source --> Metadata[pyproject.toml / uv.lock]
Scripts --> Generated[README, supportedsites, completions, changelog]
Metadata --> Package[package metadata]
Bundle[bundle/**] --> Distributions[PyInstaller / bundled artifacts]
Package --> Distributions
Generated --> Distributions
Glossary
- InfoExtractor — a class under
yt_dlp/extractor/that matches URLs and returns yt-dlp info dicts or playlists. - info dict — the metadata/result contract passed from extractors through
YoutubeDL, downloaders, and postprocessors. - PostProcessor — a stage under
yt_dlp/postprocessor/that mutates downloaded files or their metadata after download. - lazy extractors — generated extractor registry/import machinery produced by devscripts/make_lazy_extractors.py.
- downloader backend — a protocol implementation under
yt_dlp/downloader/selected to retrieve media data.
Codebase-wide invariants
- Runtime package code is rooted under
yt_dlp/; representative entrypoints include yt_dlp/__init__.py, yt_dlp/__main__.py, and yt_dlp/YoutubeDL.py. - Site-specific extraction code is concentrated under
yt_dlp/extractor/**, with shared extractor framework files such as yt_dlp/…/common.py and registry files such as yt_dlp/…/_extractors.py. - Protocol download implementations live under
yt_dlp/downloader/**; representative files include yt_dlp/…/common.py, yt_dlp/…/http.py, yt_dlp/…/hls.py, and yt_dlp/…/external.py. - Test modules are organized under
test/and mostly named test_*.py, with shared harness files test/conftest.py and test/helper.py. - Build, release, generated-documentation, and maintenance automation is separated from runtime code under
devscripts/**,bundle/**, pyproject.toml, andMakefile.
Routing table
-
yt-dlp.cmd-> docs/cli-entrypoints-and-options.md -
test/test_execution.py -> docs/cli-entrypoints-and-options.md
-
test/test_verbose_output.py -> docs/cli-entrypoints-and-options.md
-
any change to CLI argument parsing, config-file precedence, startup, or Python module invocation -> docs/cli-entrypoints-and-options.md
-
yt_dlp/minicurses.py -> docs/youtubedl-core-orchestration.md
-
test/test_YoutubeDL.py -> docs/youtubedl-core-orchestration.md
-
test/test_download.py -> docs/youtubedl-core-orchestration.md
-
test/test_overwrites.py -> docs/youtubedl-core-orchestration.md
-
any change to the main URL processing, info-dict lifecycle, archive/cache behavior, format selection, progress hooks, or orchestration between extraction/download/postprocessing -> docs/youtubedl-core-orchestration.md
-
yt_dlp/extractor/**-> docs/extractor-framework-and-registry.md -
devscripts/make_lazy_extractors.py -> docs/extractor-framework-and-registry.md
-
devscripts/lazy_load_template.py -> docs/extractor-framework-and-registry.md
-
test/test_InfoExtractor.py -> docs/extractor-framework-and-registry.md
-
test/test_all_urls.py -> docs/extractor-framework-and-registry.md
-
test/test_age_restriction.py -> docs/extractor-framework-and-registry.md
-
test/test_subtitles.py -> docs/extractor-framework-and-registry.md
-
test/test_youtube_misc.py -> docs/extractor-framework-and-registry.md
-
any new supported site, URL matcher, extractor helper, playlist/result contract, or lazy extractor generation change -> docs/extractor-framework-and-registry.md
-
yt_dlp/downloader/**-> docs/downloader-subsystem.md -
test/test_downloader_http.py -> docs/downloader-subsystem.md
-
test/test_downloader_external.py -> docs/downloader-subsystem.md
-
any change to protocol download behavior, fragment assembly, external downloader integration, progress reporting, or file output during download -> docs/downloader-subsystem.md
-
yt_dlp/networking/**-> docs/networking-stack.md -
any change to request handlers, proxies, TLS, impersonation, websocket transport, or networking exceptions -> docs/networking-stack.md
-
yt_dlp/postprocessor/**-> docs/postprocessor-pipeline.md -
test/test_postprocessors.py -> docs/postprocessor-pipeline.md
-
any change to postprocessor ordering, ffmpeg integration, metadata mutation, thumbnail embedding, SponsorBlock/chapter handling, xattrs, exec hooks, or final file movement -> docs/postprocessor-pipeline.md
-
yt_dlp/utils/**-> docs/utils-and-compatibility.md -
yt_dlp/compat/**-> docs/utils-and-compatibility.md -
any shared helper, traversal helper, progress helper, compatibility shim, or deprecated/legacy export change -> docs/utils-and-compatibility.md
-
yt_dlp/dependencies/**-> docs/cookies-auth-and-credentials.md -
test/test_cookies.py -> docs/cookies-auth-and-credentials.md
-
test/test_YoutubeDLCookieJar.py -> docs/cookies-auth-and-credentials.md
-
any change to cookie loading/saving, browser cookie extraction, cookie decryption, netrc handling, or optional auth dependencies -> docs/cookies-auth-and-credentials.md
-
public.key-> docs/plugins-and-update-system.md -
any change to plugin discovery/loading, plugin namespaces, self-update metadata, signature verification, update channels, or version constants -> docs/plugins-and-update-system.md
-
yt_dlp/jsinterp.py -> docs/javascript-crypto-and-text-parsers.md
-
yt_dlp/webvtt.py -> docs/javascript-crypto-and-text-parsers.md
-
test/test_jsinterp.py -> docs/javascript-crypto-and-text-parsers.md
-
test/test_jsc/**-> docs/javascript-crypto-and-text-parsers.md -
test/test_aes.py -> docs/javascript-crypto-and-text-parsers.md
-
test/test_devalue.py -> docs/javascript-crypto-and-text-parsers.md
-
any change to JavaScript interpretation, signature deciphering support, AES helpers, WebVTT/subtitle parsing, or parser fixtures -> docs/javascript-crypto-and-text-parsers.md
-
pyproject.toml -> docs/build-packaging-and-release-scripts.md
-
Makefile-> docs/build-packaging-and-release-scripts.md -
bundle/**-> docs/build-packaging-and-release-scripts.md -
devscripts/bash-completion.*-> docs/build-packaging-and-release-scripts.md -
devscripts/fish-completion.*-> docs/build-packaging-and-release-scripts.md -
devscripts/zsh-completion.*-> docs/build-packaging-and-release-scripts.md -
devscripts/prepare_manpage.py -> docs/build-packaging-and-release-scripts.md
-
devscripts/make_readme.py -> docs/build-packaging-and-release-scripts.md
-
devscripts/make_supportedsites.py -> docs/build-packaging-and-release-scripts.md
-
devscripts/make_changelog.py -> docs/build-packaging-and-release-scripts.md
-
devscripts/update_changelog.py -> docs/build-packaging-and-release-scripts.md
-
devscripts/update-version.py -> docs/build-packaging-and-release-scripts.md
-
devscripts/install_deps.py -> docs/build-packaging-and-release-scripts.md
-
devscripts/set-variant.py -> docs/build-packaging-and-release-scripts.md
-
supportedsites.md -> docs/build-packaging-and-release-scripts.md
-
any change to package metadata, dependency locking, generated completions/manpage/readme/supportedsites/changelog, release helpers, variants, PyInstaller, Docker bundle, or distribution assets -> docs/build-packaging-and-release-scripts.md
-
test/__init__.py -> docs/test-infrastructure-and-devscripts.md
-
test/conftest.py -> docs/test-infrastructure-and-devscripts.md
-
test/helper.py -> docs/test-infrastructure-and-devscripts.md
-
test/parameters.json -> docs/test-infrastructure-and-devscripts.md
-
test/testdata/**-> docs/test-infrastructure-and-devscripts.md -
test/test_pot/**-> docs/test-infrastructure-and-devscripts.md -
test/testcert.pem-> docs/test-infrastructure-and-devscripts.md -
devscripts/run_tests.py -> docs/test-infrastructure-and-devscripts.md
-
devscripts/setup_variables.py -> docs/test-infrastructure-and-devscripts.md
-
devscripts/setup_variables_tests.py -> docs/test-infrastructure-and-devscripts.md
-
devscripts/generate_aes_testdata.py -> docs/test-infrastructure-and-devscripts.md
-
devscripts/check-porn.py -> docs/test-infrastructure-and-devscripts.md
-
devscripts/utils.py -> docs/test-infrastructure-and-devscripts.md
-
any change to pytest harness behavior, shared test helpers, fixture/data layout, test parameterization, generated test variables, or test-running scripts -> docs/test-infrastructure-and-devscripts.md