perf: parallelize --repair with a thread pool (--workers, default 8)

Each repaired file is an independent yt-dlp metadata round-trip, so repair is
network-bound; run them concurrently via ThreadPoolExecutor. Adds --workers
(default 8) to cap concurrency and a progress line every 100 files. At ~50k
tracks this turns a ~day-long sequential run into hours. Lower --workers if
YouTube rate-limits (429/403).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 11:13:52 -07:00
parent 0347a638cf
commit 92742b9ad6
3 changed files with 60 additions and 10 deletions

View File

@@ -95,6 +95,7 @@ export LIDARR_API_KEY="your-lidarr-api-key"
| `-o`, `--root PATH` | Output root folder (default `/media/music`). |
| `--search-all` | Search all albums when adding an artist to Lidarr. |
| `--repair` | Re-tag existing downloads under `--root` from source metadata (see below). |
| `--workers N` | Parallel metadata fetches during `--repair` (default 8). |
| `--retag-from-path` | Offline: re-tag artist/title from folder + filename (see below). |
| `-x`, `--exclude NAME` | Folder under `--root` to skip during `--repair`/`--retag-from-path` (repeatable). |
| `--debug` | Verbose output. |
@@ -137,8 +138,11 @@ but it never overwrites a genuine existing artist/title with a channel name or d
title. A bogus `NA [<id>].<ext>` filename is renamed to the recovered title, and a literal
`NA` album with no source album is normalised to `Unknown Album`.
It re-queries the source over the network, so run it occasionally, not constantly. Requires
`mutagen` (a yt-dlp dependency, usually already present). CLI-only — not exposed via the REST API.
Each file is its own yt-dlp network round-trip, so repair runs them in a thread pool;
`--workers N` (default 8) caps concurrency — lower it if YouTube starts rate-limiting
(HTTP 429/403), raise it to go faster on a large library. Progress prints every 100 files.
Requires `mutagen` (a yt-dlp dependency, usually already present). CLI-only — not exposed via
the REST API.
```bash
# Preview what would change (writes nothing)