What Is the dry_run Mode in you-get and When Should You Use It?
The dry_run mode in you-get lets you preview extraction results, view real media URLs, and inspect metadata without downloading any files by using the -i, -u, or --json flags.
The soimort/you-get repository provides a command-line utility for downloading media from various websites. The dry_run mode allows you to run the complete extraction logic while short-circuiting the actual download process. This feature is essential for debugging extractors, building automation scripts, and verifying URL resolution before committing to large file transfers.
How the dry_run Mode Works in you-get
CLI Flags That Trigger dry_run
According to the source code in src/you_get/common.py (lines 1547–1561), three mutually exclusive command-line options activate the dry_run mode:
-ior--info: Prints extracted metadata including title, quality, and file size-uor--url: Outputs the direct media URLs that would be fetched--json: Returns structured JSON output containing URLs and metadata, which also forcesdry_run
When any of these options are present, the global flag dry_run is set to True in src/you_get/common.py (lines 1715–1719).
The Core Implementation in common.py
The actual short-circuit logic resides in the download_urls function within src/you_get/common.py (lines 999–1005). When dry_run is enabled, this function:
- Prints the User-Agent string being used for the request
- Displays the list of real URLs that would be downloaded
- Returns immediately without creating any files or making download requests
This ensures zero network I/O for actual media content, though the extractor still performs the initial page parsing to gather metadata.
Extractor-Level dry_run Guards
Individual extractors respect the dry_run flag when handling optional artifacts. In src/you_get/extractor.py (lines 257–263), the base extractor checks if not dry_run: before processing additional files like subtitles, danmaku, or lyrics.
For example, in src/you_get/extractors/missevan.py (lines 192–258), the extractor guards its subtitle and弹幕 (danmaku) download logic with the same condition, ensuring these auxiliary files are also skipped during a dry run.
When to Use the you-get dry_run Mode
The dry_run functionality serves four primary use cases in real-world workflows:
Inspecting extraction results – Verify video titles, available qualities, and filenames without waiting for downloads to complete. This helps confirm the correct extractor is being used for the target URL.
Scripting and automation – Capture direct media URLs in machine-readable formats using --url or --json. Downstream scripts can feed these URLs into custom downloaders, streaming players, or archival systems.
Debugging extractor issues – When downloads fail or produce unexpected results, dry_run mode reveals the exact URLs and HTTP headers the extractor generates. This helps identify changes in target site structures or extractor bugs.
Continuous integration testing – Run you-get --info in CI pipelines to verify that extractors still parse target pages correctly without downloading large video files, saving bandwidth and execution time.
Practical Examples of Using dry_run Mode
Here are concrete command-line examples demonstrating each dry_run variant:
# Display metadata only: title, size, quality options
you-get -i "https://www.bilibili.com/video/BV1xJ411x7Jd"
# Output the real media URLs for use in other tools
you-get -u "https://www.youtube.com/watch?v=abc123"
# Get structured JSON output suitable for scripting
you-get --json "https://vimeo.com/12345678" > urls.json
Each command triggers the dry_run flag, executing the short-circuit logic in download_urls that prints diagnostic information and exits before any file creation.
Summary
- The dry_run mode in you-get is activated by
-i/--info,-u/--url, or--jsonflags - Implementation resides primarily in
src/you_get/common.pywheredownload_urlschecks the globaldry_runflag and returns early - Extractors guard auxiliary file downloads (subtitles, danmaku) using
if not dry_run:checks as seen insrc/you_get/extractor.pyand specific implementations likemissevan.py - Use this mode for metadata inspection, URL extraction, debugging, and CI testing without consuming bandwidth
Frequently Asked Questions
What is the difference between --info and --url in you-get?
The --info flag displays human-readable metadata including video title, file size, and available quality streams. The --url flag outputs only the direct media URLs in plain text, making it ideal for piping into other tools or scripts that need the raw download locations.
Does dry_run mode download any data?
No. While the extractor still performs initial HTTP requests to parse the target webpage and resolve media URLs, the dry_run flag prevents download_urls from fetching actual media content or writing files to disk. As implemented in src/you_get/common.py lines 999–1005, the function returns immediately after printing URL information.
Can I use dry_run mode with all extractors?
Yes. The dry_run mechanism is implemented in the core download infrastructure within src/you_get/common.py, meaning all extractors inherit this behavior automatically. However, individual extractors must explicitly check the dry_run flag when handling optional artifacts like subtitles, as shown in src/you_get/extractor.py lines 257–263.
How does dry_run affect subtitle and danmaku downloads?
When dry_run is enabled, extractors skip downloading auxiliary files. The base Extractor class in src/you_get/extractor.py and specific implementations like missevan.py use if not dry_run: guards to ensure subtitles, lyrics, and danmaku files are only processed during actual download operations.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →