# What Is the dry_run Mode in you-get and When Should You Use It?

> Explore you-get dry_run mode to preview extraction results, view media URLs, and inspect metadata without downloading. Learn when to use this powerful feature.

- Repository: [Mort Yao/you-get](https://github.com/soimort/you-get)
- Tags: deep-dive
- Published: 2026-03-06

---

**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`](https://github.com/soimort/you-get/blob/main/src/you_get/common.py) (lines 1547–1561), three mutually exclusive command-line options activate the dry_run mode:

- `-i` or `--info`: Prints extracted metadata including title, quality, and file size
- `-u` or `--url`: Outputs the direct media URLs that would be fetched
- `--json`: Returns structured JSON output containing URLs and metadata, which also forces `dry_run`

When any of these options are present, the global flag `dry_run` is set to `True` in [`src/you_get/common.py`](https://github.com/soimort/you-get/blob/main/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`](https://github.com/soimort/you-get/blob/main/src/you_get/common.py) (lines 999–1005). When `dry_run` is enabled, this function:

1. Prints the User-Agent string being used for the request
2. Displays the list of real URLs that would be downloaded
3. 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`](https://github.com/soimort/you-get/blob/main/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`](https://github.com/soimort/you-get/blob/main/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:

```bash

# Display metadata only: title, size, quality options

you-get -i "https://www.bilibili.com/video/BV1xJ411x7Jd"

```

```bash

# Output the real media URLs for use in other tools

you-get -u "https://www.youtube.com/watch?v=abc123"

```

```bash

# 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 `--json` flags
- Implementation resides primarily in [`src/you_get/common.py`](https://github.com/soimort/you-get/blob/main/src/you_get/common.py) where `download_urls` checks the global `dry_run` flag and returns early
- Extractors guard auxiliary file downloads (subtitles, danmaku) using `if not dry_run:` checks as seen in [`src/you_get/extractor.py`](https://github.com/soimort/you-get/blob/main/src/you_get/extractor.py) and specific implementations like [`missevan.py`](https://github.com/soimort/you-get/blob/main/missevan.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`](https://github.com/soimort/you-get/blob/main/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`](https://github.com/soimort/you-get/blob/main/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`](https://github.com/soimort/you-get/blob/main/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`](https://github.com/soimort/you-get/blob/main/src/you_get/extractor.py) and specific implementations like [`missevan.py`](https://github.com/soimort/you-get/blob/main/missevan.py) use `if not dry_run:` guards to ensure subtitles, lyrics, and danmaku files are only processed during actual download operations.