Fixed album art not loading for Rekordbox collections

This commit is contained in:
patben8 committed 2026-09-26 11:58:13 +02:00
1 parent bd425f8cd6
commit 2e04bcb9f6
3 files changed
+28 -2

No files matched your search

+2 -1
View File
@@ -851,7 +851,8 @@ that number and nothing else — everything derives from it:
`test_rekordbox_fidelity.py`, end to end through the API, and in Rekordbox 7 `test_rekordbox_fidelity.py`, end to end through the API, and in Rekordbox 7
itself. Research is captured in `.claude/handoffs/rekordbox-adapter.md` §8, itself. Research is captured in `.claude/handoffs/rekordbox-adapter.md` §8,
incl. the verified result that Rekordbox accepts Konduktor-written rows when incl. the verified result that Rekordbox accepts Konduktor-written rows when
USNs are maintained. Remaining gap: **cover art**. **No version history on Rekordbox** — accepted scope decision, USNs are maintained. Remaining gap: **writing cover art** (reading works: the file's embedded art,
else Rekordbox's own `ImagePath` copy under `share/`). **No version history on Rekordbox** — accepted scope decision,
see handoff §11. see handoff §11.
- ✅ **Import a OneLibrary stick into Traktor** — done end to end. A plugged-in - ✅ **Import a OneLibrary stick into Traktor** — done end to end. A plugged-in
drive appears under **Devices** in the sidebar, browses in the ordinary table drive appears under **Devices** in the sidebar, browses in the ordinary table
@@ -407,7 +407,7 @@ class RekordboxAdapter:
self._refuse("Editing cover art") self._refuse("Editing cover art")
def cover_art(self, track_id: str) -> tuple[bytes, str] | None: def cover_art(self, track_id: str) -> tuple[bytes, str] | None:
return None return self._store.cover_art(track_id)
def set_grid_lock(self, track_id: str, locked: bool) -> TrackCues: def set_grid_lock(self, track_id: str, locked: bool) -> TrackCues:
# Rekordbox has no per-track grid lock; capabilities.grid.lockable says so. # Rekordbox has no per-track grid lock; capabilities.grid.lockable says so.
@@ -292,6 +292,31 @@ class RekordboxStore:
return None return None
return self._mapping.apply(Path(str(folder))) return self._mapping.apply(Path(str(folder)))
def cover_art(self, track_id: str) -> tuple[bytes, str] | None:
"""The art embedded in the audio file, else Rekordbox's own copy.
The file comes first because it is what Traktor reads too, so one track
shows the same art on both platforms. Rekordbox's copy (`ImagePath`,
rooted at `share/` like `AnalysisDataPath`) covers files it cannot be
read from — a WAV, or a drive that is not mounted.
"""
from ...core import audio_tags
path = self.audio_path(track_id)
if path is not None and path.is_file():
art = audio_tags.read_cover(path)
if art:
return art
rel = getattr(self.content(track_id), "ImagePath", None)
if not rel:
return None
image = self.path.parent / "share" / str(rel).lstrip("/\\")
try:
data = image.read_bytes()
except OSError:
return None
return data, "image/png" if image.suffix.lower() == ".png" else "image/jpeg"
def all_audio_paths(self) -> list[str]: def all_audio_paths(self) -> list[str]:
return [ return [
str(c.FolderPath) for c in self.iter_content() if getattr(c, "FolderPath", None) str(c.FolderPath) for c in self.iter_content() if getattr(c, "FolderPath", None)