From f8b774e22dfd93e7b575fb48da767d4d09d375bb Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Thu, 2 Apr 2026 18:08:17 -0700 Subject: [PATCH] Fetch master release details for accurate track counts and album types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Master releases now fetch /masters/{id} to get actual tracklist, genres, styles, and images — fixes 0/0 track count display - Album type re-evaluated with real track count: 1-3 = single, 4-6 = EP, 7+ = album - Cover art from master detail used when search results have none - Tested: Kendrick Lamar shows correct track counts, proper types, and images for all albums --- core/discogs_client.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/core/discogs_client.py b/core/discogs_client.py index b7e27f3f..5983831d 100644 --- a/core/discogs_client.py +++ b/core/discogs_client.py @@ -522,8 +522,43 @@ class DiscogsClient: for item in ordered: try: + # For master releases, fetch detail to get tracklist and proper metadata + if item.get('type') == 'master': + master_detail = self._api_get(f'/masters/{item["id"]}') + if master_detail: + # Merge master detail into the item for better parsing + tracklist = [t for t in master_detail.get('tracklist', []) + if t.get('type_', '') == 'track' or not t.get('type_')] + item['_track_count'] = len(tracklist) + # Carry over genres/styles from master + if master_detail.get('genres'): + item['genre'] = master_detail['genres'] + if master_detail.get('styles'): + item['style'] = master_detail['styles'] + if master_detail.get('images'): + primary = next((img for img in master_detail['images'] if img.get('type') == 'primary'), None) + item['cover_image'] = (primary or master_detail['images'][0]).get('uri') + album = Album.from_discogs_release(item) + # Override track count from master detail if available + if item.get('_track_count'): + album = Album( + id=album.id, name=album.name, artists=album.artists, + release_date=album.release_date, total_tracks=item['_track_count'], + album_type=album.album_type, image_url=album.image_url or item.get('cover_image'), + external_urls=album.external_urls, + ) + # Re-evaluate album type with actual track count + if album.total_tracks <= 3: + album = Album(id=album.id, name=album.name, artists=album.artists, + release_date=album.release_date, total_tracks=album.total_tracks, + album_type='single', image_url=album.image_url, external_urls=album.external_urls) + elif album.total_tracks <= 6: + album = Album(id=album.id, name=album.name, artists=album.artists, + release_date=album.release_date, total_tracks=album.total_tracks, + album_type='ep', image_url=album.image_url, external_urls=album.external_urls) + # Deduplicate by normalized title dedup_key = album.name.lower().strip() if dedup_key in seen_titles: