fix: harden --repair against music videos; first-artist folder for single URLs

--repair was clobbering good tags and erroring on real libraries:
- Validate the parsed id per source (YouTube 11-char, SoundCloud numeric) so
  junk ids from bracketed descriptors ([Official Video]) are skipped, not queried.
- Skip files whose source returns no real music metadata (no album/year, e.g.
  music videos) instead of overwriting clean tags with channel/decorated titles.
- Year from release info only (sane 1000-2100), never upload_date (which gave
  wrong years for old songs and bogus values like 6577).
- album/year are authoritative; artist/title are fill-missing-only (no clobber).

Also: download_single now uses the first artist for the folder (matching the
search/playlist paths) so single-URL downloads stop creating multi-artist dirs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 18:53:27 -07:00
parent 1a81f64cc3
commit c6e28a4f75
3 changed files with 140 additions and 58 deletions

View File

@@ -125,10 +125,16 @@ export LIDARR_API_KEY="your-lidarr-api-key"
`--repair` walks `<root>/<artist>/<source>/` (the `youtube`/`soundcloud`/… download
folders — Lidarr album folders are skipped), re-fetches authoritative metadata for each
file using the `[id]` in its filename, and fixes tags (album, year, artist, title). Useful
when downloads landed with missing album or wrong year. 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.
file using the `[id]` in its filename, and fixes tags. Useful when downloads landed with
missing album or wrong year.
It is deliberately **conservative**: it overwrites **album** and **year** (the usual
breakage), but only *fills in* a missing **artist**/**title** — it never overwrites existing
artist/title with channel names or decorated video titles. Files whose source returns no real
music metadata (no album and no release year — e.g. plain music videos) are left untouched.
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.
```bash
# Preview what would change (writes nothing)