Introducing a new way to review your PRs.

Read the announcement

yt-dlp / yt-dlp

A feature-rich command-line audio/video downloader

View on GitHub

13 documents · Updated Nov 16, 2026

overview

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

Routing table