CodeVetter
← All unpacks
CodeVetter · Repo Unpack evidence

ytdl-org/youtube-dl

Scanned commit 956b8c5855 dated 2025-11-26 — last upstream commit. Generated by codevetter 1.12.0 on 2026-09-22.

github.com/ytdl-org/youtube-dl ↗ · 980 files · 6.6 MB

youtube-dl - download videos from youtube.com or other video platforms - INSTALLATION - DESCRIPTION - OPTIONS - CONFIGURATION - OUTPUT TEMPLATE - FORMAT SELECTION - VIDEO SELECTION - FAQ - DEVELOPER INSTRUCTIONS - EMBEDDING YOUTUBE-DL - BUGS - COPYRIGHT INSTAL

Deep analysis by swe-2 via the devin CLI on 2026-09-22 (runtime not recorded) — every claim below links to its cited source files.

Overview

youtube-dl is a dependency-free Python command-line program (and embeddable library) that downloads video and audio from YouTube and ~1200 other sites. A single YoutubeDL orchestrator class routes each user-supplied URL to the first matching InfoExtractor (regex-matched from a registry of ~810 extractor modules), normalizes the returned 'info dict', selects a format via a small DSL, downloads via a protocol-mapped FileDownloader (native HTTP/HLS/DASH or external tools like ffmpeg/aria2c), and runs a postprocessor chain (ffmpeg muxing, metadata, thumbnails). It still maintains Python 2.6 compatibility through a large compat shim and ships as a pip package, a self-updating single-file zip executable, and a py2exe Windows binary.

System map

The system is a monolithic Python package `youtube_dl` with a layered pipeline: CLI parsing (options.py) -> orchestrator (YoutubeDL.py) -> site extractors (extractor/*) -> protocol downloaders (downloader/*) -> postprocessors (postprocessor/*). Shared helpers live in an enormous utils.py and a Python 2/3 compat.py shim. Distribution is via setuptools console script, a Makefile-built single-file zipapp `youtube-dl`, and py2exe; self-update is built in via update.py against yt-dl.org. There is no persistent daemon or service: state is limited to a JSON filesystem cache, a Netscape-format cookie jar, and a download-archive text file.

All 13 system map claims →

Feature catalog

User-facing surface = one CLI command `youtube-dl` with ~200 options defined in options.py plus the embeddable YoutubeDL API. Features cluster around: site extraction (~1200 supported sites), format/playlist/subtitle selection, sidecar file output (info JSON, description, annotations, thumbnails), ffmpeg-based postprocessing (audio extraction, recoding, embedding), authentication (username/password, netrc, video passwords, Adobe Pass TV providers), geo-restriction bypass, external downloaders, self-update, and simulation/printing modes for scripting.

All 15 feature catalog claims →

Data flow

Data moves in one direction through a well-defined pipeline. Inputs: CLI args + config files + batch files produce a URL list; the params dict is the single source of truth shared by all layers. Extractors turn a URL into an 'info dict' (a documented schema with _type discriminators video/url/url_transparent/playlist); process_ie_result resolves indirection recursively; process_video_result normalizes fields and selects formats; process_info emits sidecar files and invokes a protocol-matched FileDownloader that writes .part files and renames on completion; the postprocessor chain mutates/moves the final file; bookkeeping lands in the download archive, cookie jar, and JSON cache.

Behavior traces

Three core flows were traced end-to-end: (1) CLI startup from argv to download; (2) a single-video download from URL through extraction, format selection, HTTP download, fixup and postprocessing to the archive write; (3) the YouTube signature-deciphering path that downloads player JS and interprets it with the built-in JSInterpreter. A fourth trace covers self-update.

Testing signals

Testing is unittest-based, executed by nosetests (pynose on Python >=3.9). Coverage splits into offline unit tests (utils, aes, jsinterp, swfinterp, compat, options, YoutubeDL internals, URL matching) and a large live-download suite generated dynamically from each extractor's embedded _TEST/_TESTS dictionaries. Network-dependent suites are explicitly excluded from 'offlinetest'/'core' runs. CI on GitHub Actions spans CPython 2.6-3.12, PyPy and Jython on Ubuntu and Windows, plus a flake8 lint job; the download test-set is continue-on-error.

Risk map

The highest-risk areas are shell-outs (postprocessor --exec with shell=True, external downloader and ffmpeg command construction), credential handling (cookies, netrc, passwords), the self-update path that replaces the running binary, and the eval-adjacent JS/SWF interpreters. The codebase also carries heavy legacy weight: Python 2.6 compat shims, dead modules (swfinterp is only referenced by tests), and fragile regex-based scraping across ~800 site extractors that break silently when sites change.

Extension points

The codebase is explicitly designed around plugin points. Primary: site extractors subclass InfoExtractor, define _VALID_URL + _real_extract, embed _TEST dicts, and register via an import line in extractor/extractors.py (plus optional lazy_extractors generation). Secondary: downloaders plug into PROTOCOL_MAP or the external-downloader _BY_NAME registry, postprocessors resolve by the '<key>PP' naming convention, and embedders hook progress_hooks, match_filter, custom logger, and the postprocessors param list.

Contributor handoff

For an agent working in this repo: read CONTRIBUTING.md's developer instructions and extractor/common.py's giant docstring first; the info-dict contract and the 'first suitable() wins' ordering are the two invariants that matter most. Python 2.6-compatible style (unicode_literals, compat_* aliases, no f-strings, %-formatting) is mandatory and enforced by CI. Tests are nosetests; extractor changes get a live _TEST; run flake8 with the repo's setup.cfg ignores. Generated files (lazy_extractors.py, README.md, completions, man page) are produced by Makefile/devscripts — edit sources, not artifacts.

Languages

LanguageFilesShare of source
Python90299%
Markdown15docs/config
Shell51%
JSON2docs/config
YAML2docs/config

Start reading here

Probable source entrypoint: youtube_dl/__init__.py — inferred from the directory tree and manifest, not the upstream docs.

Source roots

youtube_dl/ (844 files) devscripts/ (34 files)

Source layout — youtube_dl/

PathFiles
youtube_dl/downloader/12
youtube_dl/extractor/291
youtube_dl/postprocessor/7
youtube_dl/__init__.py1
youtube_dl/aes.py1
youtube_dl/cache.py1
youtube_dl/compat.py1
youtube_dl/options.py1
youtube_dl/traversal.py1
youtube_dl/update.py1
youtube_dl/version.py1

Repository structure

Top-level pathFiles
youtube_dl/844
test/70
devscripts/34
.github/14
docs/6

Docs found: CONTRIBUTING.mdREADME.mddocs/supportedsites.md

CI & config entrypoints

Structural health signals

Average score 6.3/10 across 96 analyzed source files; 55 hotspots surfaced.

These are deterministic review leads — size, churn, and structural signals — not proof of a bug in this project.

Recent history