From 8ada2e3f514d51b32de4c5e795e8b07061bf0216 Mon Sep 17 00:00:00 2001 From: BeardedBear Date: Mon, 23 Feb 2026 12:45:30 +0100 Subject: [PATCH 1/4] fix(artist): Prefer name search, handle homonyms searchMusicBrainzArtistId now returns all matching artists instead of a single result or null. ArtistStore now performs a name-based search first and resolves ambiguous results by using a Spotify URL lookup when a Spotify ID is available. This improves accuracy for artists with the same name. BREAKING CHANGE: searchMusicBrainzArtistId signature changed from Promise to Promise; update any callers accordingly --- src/helpers/musicbrainz.ts | 11 +++++------ src/views/artist/ArtistStore.ts | 14 +++++++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/helpers/musicbrainz.ts b/src/helpers/musicbrainz.ts index d6c7d605..bab0423a 100644 --- a/src/helpers/musicbrainz.ts +++ b/src/helpers/musicbrainz.ts @@ -168,13 +168,13 @@ export async function getIdsFromMusicBrainz( } /** - * Search for an artist by name in MusicBrainz (fallback when Spotify URL lookup fails) + * Search for artists by name in MusicBrainz * @param artistName - The name of the artist to search for - * @returns Promise resolving to the first matching MusicBrainzArtist or null + * @returns Promise resolving to all matching MusicBrainzArtist with the same name, or empty array */ export async function searchMusicBrainzArtistId( artistName: string, -): Promise { +): Promise { const data = await fetchFromMusicBrainz("artist", { limit: 10, query: `artist:"${artistName}"`, @@ -182,13 +182,12 @@ export async function searchMusicBrainzArtistId( if (data && data.artists && data.artists.length > 0) { const normalizedSearchName = normalizeName(artistName); - const filtered = data.artists.filter( + return data.artists.filter( (artist) => normalizeName(artist.name) === normalizedSearchName, ); - return filtered[0]; } - return null; + return []; } /** diff --git a/src/views/artist/ArtistStore.ts b/src/views/artist/ArtistStore.ts index 06443b2f..01aa1595 100644 --- a/src/views/artist/ArtistStore.ts +++ b/src/views/artist/ArtistStore.ts @@ -139,11 +139,15 @@ export const useArtist = defineStore("artist", { this.wikidataArtist = null; this.wikipediaExtract = null; try { - // Try exact match via Spotify URL, fallback to name search - const artist = spotifyId - ? ((await searchMusicBrainzBySpotifyId(spotifyId)) - ?? (await searchMusicBrainzArtistId(artistName))) - : await searchMusicBrainzArtistId(artistName); + // Search by name first; if multiple homonyms found and Spotify ID available, + // use Spotify URL lookup for exact match + const nameResults = await searchMusicBrainzArtistId(artistName); + const artist + = nameResults.length === 1 + ? nameResults[0] + : nameResults.length > 1 && spotifyId + ? ((await searchMusicBrainzBySpotifyId(spotifyId)) ?? nameResults[0]) + : nameResults[0] ?? null; if (!artist?.id) return; From 39ef51e915f28df3cfc3f6e59567e0fccd962a17 Mon Sep 17 00:00:00 2001 From: BeardedBear Date: Mon, 23 Feb 2026 13:04:06 +0100 Subject: [PATCH 2/4] style(artist): Tidy template formatting --- src/components/artist/ArtistProfile.vue | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/components/artist/ArtistProfile.vue b/src/components/artist/ArtistProfile.vue index 350bddf1..7194dda8 100644 --- a/src/components/artist/ArtistProfile.vue +++ b/src/components/artist/ArtistProfile.vue @@ -10,11 +10,8 @@