fix: album shown 2-3x in "In Library" on the artist page

Deezer returns the same album as several variants (single/EP/album/regional/explicit), and
each variant matched the same Navidrome album, so one owned album rendered 2-3 times
("PIXELATED KISSES" x3).

- Web (detail.js): collapse matched entries to one per owned Navidrome album and one per
  not-owned title before classifying (also avoids duplicate track-count fetches).
- Android (categorizeAlbums): distinctBy(collectionId) missed variants with different ids;
  now also skip an owned album already classified.
SW ns-v58.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Opus 4.8 committed 2026-07-31 17:41:33 +02:00
1 parent cc4d3b72d2
commit fbee695aad
3 files changed
+16 -2

No files matched your search

@@ -68,6 +68,10 @@ fun categorizeAlbums(ndAlbums: List<Album>, iAlbums: List<ItunesItem>): ArtistAl
}
when {
match == null -> notDl.add(ia)
// Deezer returns the same album as several variants (single/EP/album/regional); distinctBy
// above only catches identical ids, so also skip an owned album we've already classified —
// otherwise it shows 2-3x ("PIXELATED KISSES").
match.id in usedNdIds -> Unit
iCount > match.songCount -> {
partial.add(Triple(match, ia, Pair(match.songCount, iCount))); usedNdIds.add(match.id)
}
+1 -1
View File
@@ -1,4 +1,4 @@
const CACHE = 'ns-v57';
const CACHE = 'ns-v58';
const PRECACHE = ['/', 'index.html', 'manifest.json', 'icon.svg'];
const SKIP_PATHS = ['/rest/stream', '/rest/download', '/config.js'];
// Auth token params stripped from cache keys so artwork survives across sessions/token refreshes.
+11 -1
View File
@@ -293,7 +293,7 @@ async function _renderArtistAlbums(el, ndAlbums, iAlbums, artist) {
el.innerHTML = '<div class="spinner"></div>';
// Match each Deezer album to a Navidrome album by normalized name.
const entries = iAlbums.map(ia => {
const allEntries = iAlbums.map(ia => {
const iName = _normAlbum(ia.collectionName);
const match = ndAlbums.find(a => {
const n = _normAlbum(a.name);
@@ -301,6 +301,16 @@ async function _renderArtistAlbums(el, ndAlbums, iAlbums, artist) {
});
return { ia, match };
});
// Deezer returns the same album several times (single/EP/album/regional/explicit variants), which
// rendered one owned album 3× ("PIXELATED KISSES"). Collapse to one entry per owned Navidrome album
// and one per not-owned title.
const entries = [];
const seenNd = new Set(), seenName = new Set();
for (const e of allEntries) {
if (e.match) { if (seenNd.has(e.match.id)) continue; seenNd.add(e.match.id); }
else { const k = _normAlbum(e.ia.collectionName); if (seenName.has(k)) continue; seenName.add(k); }
entries.push(e);
}
// Deezer's /artist/{id}/albums list omits nb_tracks, so the total is unknown here — which made every
// owned album look "incomplete" (e.g. "Moonlight 1 / 0"). Resolve the real track count from the