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"
This commit is contained in:
vicrodh committed 2026-01-25 23:14:59 -06:00
1 parent fbc1938838
commit 078f33085f
1 file changed
+12 -7
+12 -7
View File
@@ -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
);