返回 douyin-downloader
AGENTS.md
根目录 / config / AGENTS.md
1 <!-- Parent: ../AGENTS.md -->
2 <!-- Generated: 2026-03-27 | Updated: 2026-03-27 -->
3
4 # config
5
6 ## Purpose
7 YAML configuration loading with environment variable overrides, default values, cookie resolution, and config validation. Handles the `mix`/`allmix` alias normalization system.
8
9 ## Key Files
10
11 | File | Description |
12 |------|-------------|
13 | `__init__.py` | Exports `ConfigLoader` |
14 | `config_loader.py` | Main config class — loads YAML, merges env overrides, normalizes aliases, validates |
15 | `default_config.py` | `DEFAULT_CONFIG` dict with all default values |
16 | `cookies.json` | Auto-cookie file — loaded when `cookie: auto` or `auto_cookie: true` |
17
18 ## For AI Agents
19
20 ### Working In This Directory
21 - `ConfigLoader` merges: defaults → YAML file → env vars (`DOUYIN_*` prefix)
22 - The `mix`/`allmix` alias system keeps both keys in sync across `number` and `increase` sections
23 - Cookie resolution order: explicit string → dict → `"auto"` keyword → `auto_cookie` flag → fallback JSON files
24 - Network config supports TLS customization: `verify`, `trust_env`, `ca_file`, `ca_dir`
25 - `validate()` coerces types and clears invalid date formats
26
27 ### Testing Requirements
28 - Tests: `tests/test_config_loader.py`, `tests/test_config_validation.py`
29
30 ### Common Patterns
31 - Deep-merge for nested dicts (`_merge_config`)
32 - Explicit-source tracking for alias conflict resolution (`_is_key_explicit_in_sources`)
33 - Boolean env var parsing with strict true/false value sets
34
35 ## Dependencies
36
37 ### Internal
38 - `utils/cookie_utils.py` — `parse_cookie_header()`, `sanitize_cookies()`
39
40 ### External
41 - `pyyaml` — YAML parsing
42
43 <!-- MANUAL: -->
44
44 lines MARKDOWN