diff --git a/core/hydrabase_client.py b/core/hydrabase_client.py index 4dd63aa3..ed3000d7 100644 --- a/core/hydrabase_client.py +++ b/core/hydrabase_client.py @@ -139,6 +139,21 @@ class HydrabaseClient: logger.error(f"Hydrabase query failed ({request_type}, '{query}'): {e}") return None + @staticmethod + def _normalize_artists(artists_raw) -> list: + """Normalize artists to a list of strings (Hydrabase may send dicts or strings).""" + if not artists_raw or not isinstance(artists_raw, list): + return [] + result = [] + for a in artists_raw: + if isinstance(a, str): + result.append(a) + elif isinstance(a, dict): + result.append(a.get('name', '')) + else: + result.append(str(a)) + return [x for x in result if x] + @staticmethod def _normalize_release_date(date_str: str) -> str: """Strip time portion from ISO dates like '1995-01-01T08:00:00Z' -> '1995-01-01'.""" @@ -161,7 +176,7 @@ class HydrabaseClient: tracks.append(Track( id=str(item.get('id', '')), name=item.get('name', ''), - artists=item.get('artists', []), + artists=self._normalize_artists(item.get('artists', [])), album=item.get('album', ''), duration_ms=item.get('duration_ms', 0), popularity=item.get('popularity', 0), @@ -210,7 +225,7 @@ class HydrabaseClient: albums.append(Album( id=str(item.get('soul_id', item.get('id', ''))), name=item.get('name', ''), - artists=item.get('artists', []), + artists=self._normalize_artists(item.get('artists', [])), release_date=self._normalize_release_date(item.get('release_date', '')), total_tracks=item.get('total_tracks', 0), album_type=item.get('album_type', 'album'), @@ -235,7 +250,7 @@ class HydrabaseClient: albums.append(Album( id=str(item.get('soul_id', item.get('id', ''))), name=item.get('name', ''), - artists=item.get('artists', []), + artists=self._normalize_artists(item.get('artists', [])), release_date=self._normalize_release_date(item.get('release_date', '')), total_tracks=item.get('total_tracks', 0), album_type=item.get('album_type', 'album'), @@ -376,7 +391,7 @@ class HydrabaseClient: tracks.append(Track( id=str(item.get('id', '')), name=item.get('name', ''), - artists=item.get('artists', []), + artists=self._normalize_artists(item.get('artists', [])), album=item.get('album', ''), duration_ms=item.get('duration_ms', 0), popularity=item.get('popularity', 0), @@ -504,7 +519,7 @@ class HydrabaseClient: albums.append(Album( id=str(item.get('soul_id', item.get('id', ''))), name=item.get('name', ''), - artists=item.get('artists', []), + artists=self._normalize_artists(item.get('artists', [])), release_date=self._normalize_release_date(item.get('release_date', '')), total_tracks=item.get('total_tracks', 0), album_type=item_type, diff --git a/web_server.py b/web_server.py index 4ff6d69d..89359f84 100644 --- a/web_server.py +++ b/web_server.py @@ -7006,8 +7006,7 @@ def enhanced_search(): # Determine which alternate sources are available (for frontend to fetch async) spotify_available = bool(spotify_client and spotify_client.is_spotify_authenticated()) - hydrabase_available = bool(hydrabase_client and hydrabase_client.is_connected() - and (dev_mode_enabled or config_manager.get('hydrabase.enabled', False))) + hydrabase_available = bool(hydrabase_client and hydrabase_client.is_connected()) alternate_sources = [] if primary_source != 'spotify' and spotify_available: alternate_sources.append('spotify') diff --git a/webui/static/script.js b/webui/static/script.js index c981c7a1..c7f33915 100644 --- a/webui/static/script.js +++ b/webui/static/script.js @@ -7574,7 +7574,7 @@ function initializeSearchModeToggle() { // Fire ALL source fetches immediately in parallel with the primary endpoint. // Don't guess which is primary — the main endpoint response will tell us. // If an alternate duplicates the primary, it just overwrites with same data. - for (const srcName of ['spotify', 'itunes', 'deezer']) { + for (const srcName of ['spotify', 'itunes', 'deezer', 'hydrabase']) { _fetchAlternateSource(srcName, query); }