feat: show real on-disk tracklist in the Library album modal (#9)

The Library modal showed MusicBrainz's canonical tracklist, hiding incomplete
downloads / edition or track-order mismatches, and showed nothing for albums
without an rgMbid. Now it shows the REAL files on disk.

- LibraryItem gains trackNames String[] (migration add_library_track_names):
  the album's on-disk "## Title.ext" audio filenames.
- Captured at import (pipeline._import lists the final album folder) and at scan
  (scan._record_owned now also refreshes trackNames on re-scan via ON CONFLICT
  DO UPDATE + xmax=0 to preserve the newly-imported flag). New shared
  library.list_audio_files() helper.
- /api/library exposes trackNames; the AlbumModal prefers on-disk tracks when
  present (parsed "## Title" → position/title, zero network, labeled "On disk ·
  N tracks"), falling back to the MusicBrainz listing otherwise. Items imported
  before this column show the MB fallback until re-scanned.

worker 221 tests / 7-skip, web 153, tsc + build clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan
2026-07-14 12:55:54 +02:00
parent 746d61b264
commit dcf0bb0696
10 changed files with 89 additions and 12 deletions
+14
View File
@@ -26,6 +26,20 @@ _COVER_STEMS = {"cover", "folder", "front"}
_COVER_EXT = {".jpg", ".jpeg", ".png"}
def list_audio_files(folder: str) -> list[str]:
"""The album's on-disk audio filenames (basenames, sorted) — captured into
LibraryItem.trackNames so the UI can show the real tracks on disk. Top-level only
(albums are one flat folder here); returns [] if the folder is missing/unreadable."""
try:
names = [
n for n in os.listdir(folder)
if os.path.isfile(os.path.join(folder, n)) and os.path.splitext(n)[1].lower() in _AUDIO_EXT
]
except OSError:
return []
return sorted(names)
def staging_dir(staging_root: str, job_id: str) -> str:
"""A per-job download staging directory under `staging_root`. The staging root may be a
volume separate from the library (e.g. local disk while the library is an SMB share):