From 2f2e5ddbd0374c06583a53d5e0837ce02f1b9c40 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Mon, 20 Apr 2026 09:15:09 -0700 Subject: [PATCH] Fix album track lookup hardcoded to Spotify on Artists page The /api/artist/{id}/album/{id}/tracks endpoint was hardcoded to use spotify_client and returned 401 if Spotify wasn't authenticated, even when the user's primary source was Deezer or iTunes. Now uses the configured primary metadata source via _get_metadata_fallback_client with Spotify as fallback. Also gives a clearer error message when no metadata source is available at all. --- web_server.py | 18 ++++++++++++++---- webui/static/helper.js | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/web_server.py b/web_server.py index 51af3fb6..ef56c7a8 100644 --- a/web_server.py +++ b/web_server.py @@ -11602,12 +11602,9 @@ def get_artist_album_tracks(artist_id, album_id): except Exception as e: logger.warning(f"Hydrabase album_tracks failed for '{album_id}', falling back to Spotify: {e}") - if not spotify_client or not spotify_client.is_authenticated(): - return jsonify({"error": "Spotify not authenticated"}), 401 - # Source override: when user navigated from a specific search tab source_override = request.args.get('source', '') - client = spotify_client + client = None if source_override == 'itunes': client = _get_itunes_client() elif source_override == 'hydrabase': @@ -11621,6 +11618,18 @@ def get_artist_album_tracks(artist_id, album_id): elif source_override == 'discogs': client = _get_discogs_client() + # No source override — use the primary metadata source + if not client: + try: + client = _get_metadata_fallback_client() + except Exception: + pass + # Fall back to Spotify if available + if not client and spotify_client and spotify_client.is_authenticated(): + client = spotify_client + if not client: + return jsonify({"error": "No metadata source available. Configure Spotify, Deezer, or iTunes in Settings."}), 401 + logger.debug( "Fetching tracks for album %s by artist %s (source=%s)", album_id, @@ -22626,6 +22635,7 @@ def get_version_info(): "• Fix library page crash on All filter — non-string soul_id broke card rendering", "• Auto Wing It fallback for failed discovery — unmatched tracks download via Soulseek with raw metadata", "• Lidarr download source now production-ready — full orchestrator integration", + "• Fix album track lookup hardcoded to Spotify — now uses configured primary source", "• Fix M3U showing all tracks as missing — regenerate with real paths after post-processing", "• Fix AcoustID retag not writing corrected tags to audio file", "• Fix wishlist albums cycle stuck at 1 concurrent worker instead of configured value", diff --git a/webui/static/helper.js b/webui/static/helper.js index 0eeaed04..a3d25b33 100644 --- a/webui/static/helper.js +++ b/webui/static/helper.js @@ -3603,6 +3603,7 @@ const WHATS_NEW = { // --- April 19, 2026 --- { date: 'April 19, 2026' }, { title: 'Fix Wishlist Albums Cycle Stuck at 1 Concurrent', desc: 'Auto-wishlist processing during the "albums" cycle was limited to 1 concurrent download even with higher configured settings. The max_concurrent=1 restriction is only needed for Soulseek folder-based album grabs, not individual wishlist track downloads. Albums cycle now uses the configured concurrency like singles' }, + { title: 'Fix Album Track Lookup Hardcoded to Spotify', desc: 'Clicking an album on the Artists page to download tracks was hardcoded to use Spotify even when the user\'s primary metadata source was Deezer or iTunes. Now uses the configured primary source with Spotify as fallback' }, { title: 'Fix Wishlist Splitting Albums by Track Artist', desc: 'Adding a multi-artist album (like a soundtrack) to wishlist was creating separate entries per track artist instead of keeping all tracks under the album artist. Now uses the album-level artist context when available to keep tracks grouped correctly' }, { title: 'Fix Artist Search Case Sensitivity', desc: 'Artist search on the Artists page now normalizes all-lowercase queries to title case before hitting metadata APIs. Some APIs return fewer or no results for lowercase queries like "foreigner" vs "Foreigner"' }, { title: 'Lidarr Download Source Now Production-Ready', desc: 'Lidarr is now a fully functional download source with complete orchestrator integration. Downloads appear in the UI, status polling works, cancellation works, and cleanup on shutdown works. Error messages are now visible in the download list. Removed "(Development)" label' },