soulsync/core/repair_jobs
Broque Thomas 78fa83c8ac Add $cdnum template variable for multi-disc filenames
New smart template variable that emits "CD01" / "CD02" etc. in filenames
on multi-disc albums, and expands to empty string on single-disc albums
so mixed libraries don't end up with "CD01" on every single.

Template behaviour:
- total_discs > 1 -> "CD{disc:02d}" (zero-padded, CD prefix)
- total_discs <= 1 -> empty string
- Both $cdnum and ${cdnum} bracket form supported
- Empty value collapses cleanly via existing double-dash regex plus new
  leading-dash cleanup pass

Wiring:
- _apply_path_template in web_server.py (download pipeline)
- _apply_path_template in core/repair_jobs/library_reorganize.py
  (Reorganize repair job)
- total_discs added to every album-mode template context:
  * download pipeline album branch (uses resolved total_discs even for
    single-track downloads from search)
  * per-album Reorganize preview + apply endpoints (pre-scan all track
    tags once, take max disc_number)
  * Library Reorganize repair job (already had album_total_discs map,
    just added to context dict)

Leading-dash cleanup added to _get_file_path_from_template (web_server)
and _build_path_from_template (library_reorganize) so templates like
"$cdnum - $track - $title" don't leave "- 05 - Title" on single-disc
albums.

UI:
- Template hint in Settings -> File Organization documents $cdnum
- Template validation variable list includes $cdnum
- Reorganize modal variable reference shows $cdnum with example "CD01"

Verified:
- Multi-disc disc 1 -> "CD01 - 05 - Track"
- Multi-disc disc 2 -> "CD02 - 05 - Track"
- Single-disc      -> "05 - Track" (no leading dash)
- Templates without $cdnum behave unchanged
- 276/276 tests pass
2026-04-21 22:55:37 -07:00
..
__init__.py Add Discography Backfill maintenance job 2026-04-20 22:04:38 -07:00
acoustid_scanner.py Fix null-pointer error in acoustid_scanner 2026-04-17 19:17:24 +03:00
album_completeness.py Share metadata source priority 2026-04-15 07:48:25 +03:00
album_tag_consistency.py Fix Album Tag Consistency job: add missing _get_settings method 2026-03-24 06:38:05 -07:00
base.py Improve graceful shutdown and rollback safety 2026-04-12 15:17:18 +03:00
cache_evictor.py Add metadata cache maintenance and health monitoring 2026-03-30 07:40:20 -07:00
dead_file_cleaner.py Fix dead file cleaner false positives from transfer path resolution failure 2026-03-17 09:51:31 -07:00
discography_backfill.py Rebuild Discography Backfill: auto-wishlist, Fix All, section UI 2026-04-21 18:44:43 -07:00
duplicate_detector.py Clean up 286 ruff lint errors to unblock CI and fix 10 latent bugs 2026-04-21 13:30:52 -07:00
fake_lossless_detector.py Enrich repair findings with album art, artist images & live job progress 2026-03-15 14:08:26 -07:00
library_reorganize.py Add $cdnum template variable for multi-disc filenames 2026-04-21 22:55:37 -07:00
live_commentary_cleaner.py Fix watchlist content filters: live false positives + auto-scan bypass 2026-04-21 19:16:25 -07:00
lossy_converter.py Add independent Blasphemy Mode setting for lossy converter job 2026-03-22 08:08:47 -07:00
mbid_mismatch_detector.py Fix MBID Mismatch Detector comparing MB title against DB title (filename) instead of embedded tag 2026-04-14 12:19:41 -07:00
metadata_gap_filler.py Make metadata gap filler source-aware 2026-04-15 21:35:57 +03:00
missing_cover_art.py Respect source preference in cover art repair job 2026-04-15 21:28:12 +03:00
orphan_file_detector.py Fix dismissed findings reappearing and reduce false orphan detections 2026-04-10 17:42:39 -07:00
single_album_dedup.py Fix bulk Fix All ignoring Single/Album Dedup findings and expand version keywords 2026-03-19 08:53:14 -07:00
track_number_repair.py Clean up 286 ruff lint errors to unblock CI and fix 10 latent bugs 2026-04-21 13:30:52 -07:00
unknown_artist_fixer.py Fix unknown_artist_fixer crash on missing deezer_track_id column 2026-04-20 16:29:38 -07:00