From 39c67123e710fd22b0dc0042ffb39ed068a27637 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Wed, 4 Feb 2026 20:39:50 -0600 Subject: [PATCH] fix(suggestions): force English locale for genre checking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Qobuz returns localized genre names based on user's registered address, not app language. This caused genre filtering to fail when user sees "América Latina" instead of "Latin". Solution: Pass lang=en explicitly when fetching artist albums for genre verification. This ensures consistent English genre names regardless of user's registration country. Also simplified the incompatible genres list since we only need English now. --- src-tauri/src/api/client.rs | 18 +++++++- src-tauri/src/artist_vectors/suggestions.rs | 49 ++++++++------------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src-tauri/src/api/client.rs b/src-tauri/src/api/client.rs index 1f8dad82f..f923d340a 100644 --- a/src-tauri/src/api/client.rs +++ b/src-tauri/src/api/client.rs @@ -635,9 +635,25 @@ impl QobuzClient { with_albums: bool, limit: Option, offset: Option, + ) -> Result { + self.get_artist_with_pagination_and_locale(artist_id, with_albums, limit, offset, None).await + } + + /// Get artist by ID with album pagination and optional locale override + /// Use locale_override to force a specific language (e.g., "en" for genre checking) + pub async fn get_artist_with_pagination_and_locale( + &self, + artist_id: u64, + with_albums: bool, + limit: Option, + offset: Option, + locale_override: Option<&str>, ) -> Result { let url = endpoints::build_url(paths::ARTIST_GET); - let locale = self.locale().await; + let locale = match locale_override { + Some(l) => l.to_string(), + None => self.locale().await, + }; let mut query = vec![ ("artist_id", artist_id.to_string()), ("lang", locale), diff --git a/src-tauri/src/artist_vectors/suggestions.rs b/src-tauri/src/artist_vectors/suggestions.rs index 5c8026f5e..b7e3d281b 100644 --- a/src-tauri/src/artist_vectors/suggestions.rs +++ b/src-tauri/src/artist_vectors/suggestions.rs @@ -642,46 +642,35 @@ impl SuggestionsEngine { /// Returns true if incompatible, false if compatible or unknown. async fn has_incompatible_genre(&self, client: &QobuzClient, artist_id: u64, artist_name: &str) -> bool { // Incompatible genre keywords - these would never appear in a rock/metal context - // NOTE: Qobuz sends localized genre names, so we need variants in multiple languages + // NOTE: We force English locale when fetching, so only English names needed const INCOMPATIBLE_GENRES: &[&str] = &[ - // Latin/Tropical (English + Spanish + Portuguese) + // Latin/Tropical "bachata", "merengue", "reggaeton", "salsa", "cumbia", "vallenato", - "latin pop", "tropical", "urbano latino", "regional mexicano", - "latin", "latina", "latino", // Generic Latin - "américa latina", "america latina", "latinoamérica", "latinoamerica", - "música latina", "musica latina", - "música tropical", "musica tropical", + "latin pop", "latin music", "tropical", "urbano", "regional mexican", + "latin", // Generic Latin parent genre // Asian pop - "k-pop", "kpop", "j-pop", "jpop", "mandopop", "cantopop", - // European folk/schlager (German + French) - "schlager", "volksmusi", "chanson", "volksmusik", - "variété française", "variete francaise", - // Religious (English + Spanish) - "gospel", "christian", "worship", "religious", - "música cristiana", "musica cristiana", "alabanza", - // Children/Family (English + Spanish + German + French) - "children", "nursery", "lullaby", "kids", "kindermusik", - "infantil", "niños", "para niños", "música infantil", - "comptines", "berceuse", "enfants", + "k-pop", "kpop", "j-pop", "jpop", "mandopop", "cantopop", "c-pop", + // European folk/schlager + "schlager", "chanson", "french chanson", "volksmusik", + // Religious + "gospel", "christian", "worship", "religious", "spiritual", + // Children/Family + "children", "nursery", "lullaby", "kids", // Electronic/Dance (club-oriented) "trance", "techno", "house", "edm", "dubstep", "drum and bass", - "hardstyle", "eurodance", "hands up", "happy hardcore", - "electrónica", "electronica", "électronique", "elektronische", - // Spoken word/Non-music (English + Spanish + German + French) + "hardstyle", "eurodance", "hands up", "happy hardcore", "dance", + // Spoken word/Non-music "audiobook", "spoken word", "podcast", "meditation", "asmr", "relaxation", "sleep", "nature sounds", "white noise", - "comedy", "stand-up", "hörbuch", "hörspiel", - "audiolibro", "libro audio", "meditación", "meditacion", - "livre audio", "méditation", + "comedy", "stand-up", // Country (usually incompatible with metal) - "country", "bluegrass", "americana country", - // New age/Wellness (English + Spanish) - "new age", "healing", "spa", "yoga", "mindfulness", - "nueva era", "bienestar", "relajación", "relajacion", + "country", "bluegrass", "americana", + // New age/Wellness + "new age", "healing", "spa", "yoga", "mindfulness", "wellness", ]; - // Fetch artist with a few albums - match client.get_artist_with_pagination(artist_id, true, Some(5), None).await { + // Fetch artist with a few albums (use English locale for consistent genre names) + match client.get_artist_with_pagination_and_locale(artist_id, true, Some(5), None, Some("en")).await { Ok(artist) => { if let Some(albums) = &artist.albums { for album in &albums.items {