From 078f33085fe4f875b82f3366abfa1b8b74528f27 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 25 Jan 2026 23:14:59 -0600 Subject: [PATCH] fix: check studio albums count, not total albums The previous logic checked total album count (< 10) to decide whether to compare "X" vs "The X" variants. This failed for artists like "Traveling Wilburys" (19 total albums, but 0 studio albums). Now we: 1. Always count studio albums for the initial match 2. If studio albums < 10, search for "The X" variant 3. Compare studio album counts Example fix: - "Traveling Wilburys": 19 total, 0 studio albums - "The Traveling Wilburys": 17 total, 6 studio albums - Now correctly prefers "The Traveling Wilburys" --- src-tauri/src/commands/musician.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src-tauri/src/commands/musician.rs b/src-tauri/src/commands/musician.rs index d9b9fd032..70e878788 100644 --- a/src-tauri/src/commands/musician.rs +++ b/src-tauri/src/commands/musician.rs @@ -64,23 +64,28 @@ pub async fn resolve_musician( } } - // If we have a match but it has few albums, check if "The X" has more STUDIO albums + // Always check if "The X" variant has more STUDIO albums + // Total album count is misleading (tributes, compilations inflate it) if let Some(ref current) = best_match { - let current_total = current.albums_count.unwrap_or(0); - if current_total < 10 { - // Search specifically for "The X" to compare + // Count studio albums for current match + let current_studio = count_studio_albums(&client, current.id).await; + log::info!( + "Match '{}' has {} studio albums (total: {})", + current.name, current_studio, current.albums_count.unwrap_or(0) + ); + + // If few studio albums, check "The X" variant + if current_studio < 10 { let the_name = format!("The {}", name); if let Ok(the_results) = client.search_artists(&the_name, 5, 0, None).await { for artist in the_results.items { let artist_lower = artist.name.to_lowercase(); let the_name_lower = the_name.to_lowercase(); if artist_lower == the_name_lower { - // Compare studio album counts for better accuracy - let current_studio = count_studio_albums(&client, current.id).await; let the_studio = count_studio_albums(&client, artist.id).await; log::info!( - "Comparing studio albums: '{}' has {} studio albums, 'The {}' has {} studio albums", + "Comparing studio albums: '{}' has {} studio, 'The {}' has {} studio", current.name, current_studio, name, the_studio );