From bbaa897cd26d6453efe5e52a6d9f2d2d0e2b6f86 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Fri, 10 Apr 2026 10:43:45 -0700 Subject: [PATCH] Fix Deezer metadata cache storing incomplete album and track data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deezer's /artist/{id}/albums endpoint returns albums without an artist field, causing 98% of cached Deezer albums to have empty artist_name. Now injects the known artist before caching. Also fixes get_track_details cache validation — was trusting search result cache (which has isrc but no track_position), returning track_number=0. Now only trusts cache entries with track_position. --- core/deezer_client.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/deezer_client.py b/core/deezer_client.py index 38c1b4cc..5b89f868 100644 --- a/core/deezer_client.py +++ b/core/deezer_client.py @@ -636,7 +636,17 @@ class DeezerClient: albums.append(album) cache = get_metadata_cache() - entries = [(str(ad.get('id', '')), ad) for ad in data['data'] if ad.get('id')] + # Deezer's /artist/{id}/albums endpoint doesn't include artist info on each album. + # Inject it so cached album entities have artist_name for discover page display. + artist_stub = None + if albums and albums[0].artists: + artist_stub = {'id': int(artist_id) if artist_id.isdigit() else 0, 'name': albums[0].artists[0]} + entries = [] + for ad in data['data']: + if ad.get('id'): + if artist_stub and not ad.get('artist'): + ad['artist'] = artist_stub + entries.append((str(ad['id']), ad)) if entries: cache.store_entities_bulk('deezer', 'album', entries, skip_if_exists=True)