From fbe101050a7aba5d56413f0a171e9e3bd777b148 Mon Sep 17 00:00:00 2001 From: trentisiete Date: Fri, 3 Apr 2026 13:55:56 +0200 Subject: [PATCH] fix: filter albums and tracks by artist ID to prevent showing wrong same-name artists --- js/api.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/js/api.js b/js/api.js index 5808a83..0c7c919 100644 --- a/js/api.js +++ b/js/api.js @@ -1073,11 +1073,11 @@ export class LosslessAPI { entries.forEach((entry) => scan(entry, visited)); scan(primaryData, visited); + const numericArtistId = Number(artistId); if (!options.lightweight) { try { const videoSearch = await this.searchVideos(artist.name); if (videoSearch && videoSearch.items) { - const numericArtistId = Number(artistId); for (const item of videoSearch.items) { const itemArtistId = item.artist?.id; const matchesArtist = @@ -1094,7 +1094,11 @@ export class LosslessAPI { } } - const rawReleases = Array.from(albumMap.values()); + const rawReleases = Array.from(albumMap.values()).filter((album) => { + const albumArtistId = album.artist?.id; + return albumArtistId === numericArtistId || + (Array.isArray(album.artists) && album.artists.some((a) => a.id === numericArtistId)); + }); const allReleases = this.deduplicateAlbums(rawReleases).sort( (a, b) => new Date(b.releaseDate || 0) - new Date(a.releaseDate || 0) ); @@ -1103,6 +1107,11 @@ export class LosslessAPI { const albums = allReleases.filter((a) => !eps.includes(a)); const topTracks = Array.from(trackMap.values()) + .filter((track) => { + const trackArtistId = track.artist?.id; + return trackArtistId === numericArtistId || + (Array.isArray(track.artists) && track.artists.some((a) => a.id === numericArtistId)); + }) .sort((a, b) => (b.popularity || 0) - (a.popularity || 0)) .slice(0, 15);