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:
@@ -9,7 +9,7 @@ import psycopg
|
||||
|
||||
from lyra_worker.adapters.base import SourceAdapter
|
||||
from lyra_worker.confidence import score_confidence
|
||||
from lyra_worker.library import album_dir, import_album, staging_dir
|
||||
from lyra_worker.library import album_dir, import_album, list_audio_files, staging_dir
|
||||
from lyra_worker.quality import quality_class
|
||||
from lyra_worker.ranker import rank_candidates
|
||||
from lyra_worker.types import Candidate, MBTarget
|
||||
@@ -186,18 +186,19 @@ def _mark_chosen(conn: psycopg.Connection, job_id: str, source_ref: str) -> None
|
||||
def _import(conn: psycopg.Connection, job_id: str, target: MBTarget,
|
||||
winner: Candidate, path: str) -> None:
|
||||
request_id = _request_id(conn, job_id)
|
||||
track_names = list_audio_files(path) # the real files just imported into the album folder
|
||||
with conn.cursor() as cur:
|
||||
cur.execute(
|
||||
'INSERT INTO "LibraryItem" (id, "requestId", artist, album, path, source, '
|
||||
'format, "qualityClass", "importedAt") '
|
||||
"VALUES (gen_random_uuid()::text, %s, %s, %s, %s, %s, %s, %s, now()) "
|
||||
'format, "qualityClass", "trackNames", "importedAt") '
|
||||
"VALUES (gen_random_uuid()::text, %s, %s, %s, %s, %s, %s, %s, %s, now()) "
|
||||
'ON CONFLICT (artist, album) DO UPDATE SET '
|
||||
' "requestId" = EXCLUDED."requestId", path = EXCLUDED.path, source = EXCLUDED.source, '
|
||||
' format = EXCLUDED.format, "qualityClass" = EXCLUDED."qualityClass", '
|
||||
' "importedAt" = now() '
|
||||
' "trackNames" = EXCLUDED."trackNames", "importedAt" = now() '
|
||||
'WHERE EXCLUDED."qualityClass" > "LibraryItem"."qualityClass"',
|
||||
(request_id, target.artist, target.album, path, winner.source,
|
||||
winner.quality.fmt, quality_class(winner.quality)),
|
||||
winner.quality.fmt, quality_class(winner.quality), track_names),
|
||||
)
|
||||
cur.execute(
|
||||
"UPDATE \"Request\" SET status = 'completed' WHERE id = %s", (request_id,)
|
||||
|
||||
Reference in New Issue
Block a user