Skip to content

Commit 1888464

Browse files
oxon1umclaude
andcommitted
Fix artist search: lookup by MusicBrainz ID instead of foreignArtistId
The search results return MusicBrainz IDs as foreignArtistId, but the API was using foreignArtistId parameter which doesn't work correctly. Now tries mbid parameter first, falls back to foreignArtistId. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 12e1f58 commit 1888464

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/lidarr/client.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,26 @@ export class LidarrClient {
272272
}
273273

274274
async getArtistByForeignId(foreignArtistId: string): Promise<LidarrArtist | null> {
275+
// First try with mbid parameter (MusicBrainz ID lookup)
276+
const encodedMbid = encodeURIComponent(foreignArtistId);
277+
const artistByMbid = await this.tryRequest<LidarrArtist>(`/api/v1/artist/lookup?mbid=${encodedMbid}`);
278+
if (artistByMbid) return artistByMbid;
279+
280+
// Fallback to foreignArtistId parameter
275281
const encoded = encodeURIComponent(foreignArtistId);
276282
return this.tryRequest<LidarrArtist>(`/api/v1/artist/lookup?foreignArtistId=${encoded}`);
277283
}
278284

279285
async getAlbumsByArtistForeignId(foreignArtistId: string): Promise<LidarrArtistAlbum[]> {
280-
const encoded = encodeURIComponent(foreignArtistId);
281-
const albums = await this.tryRequest<LidarrArtistAlbum[]>(`/api/v1/album/lookup?term=${encoded}&artistid=${encodeURIComponent(foreignArtistId)}`);
286+
// Try with mbid parameter first
287+
const encodedMbid = encodeURIComponent(foreignArtistId);
288+
let albums = await this.tryRequest<LidarrArtistAlbum[]>(`/api/v1/album/lookup?mbid=${encodedMbid}`);
289+
290+
if (!albums || albums.length === 0) {
291+
// Fallback to term search
292+
const encoded = encodeURIComponent(foreignArtistId);
293+
albums = await this.tryRequest<LidarrArtistAlbum[]>(`/api/v1/album/lookup?term=${encoded}`);
294+
}
282295

283296
if (!albums || albums.length === 0) {
284297
// Fallback: search by artist name in albums

0 commit comments

Comments
 (0)