Fix Amazon artist detail: album art and singles missing

Two bugs in the library artist detail page when Amazon is the source:

1. No album art: get_artist_albums returned Album dataclasses with
   image_url=None — it collected ASINs but never called _fetch_album_metas.
   Now fetches metas for up to 10 albums (same cap as search_albums),
   populating image_url, release_date, and total_tracks on each Album.

2. No singles: Album.from_search_hit hardcodes album_type="album" and
   T2Tunes exposes no release type in search results. Added inference:
   total_tracks==1 → album_type="single", which routes them to the
   singles bucket in the discography categorizer.

Also passes album_name through _strip_edition and artist through
_primary_artist in get_artist_albums (parity with search_albums).

3. amazon_id missing from artist_source_ids in get_artist_detail:
   the discography lookup never received the stored Amazon slug so
   it always fell back to name search. Added 'amazon': artist_info.
   get('amazon_id') to the dict alongside spotify/deezer/itunes/etc.
pull/617/head
Broque Thomas 1 week ago
parent 786c576b80
commit 376aaa4cc9

@ -576,7 +576,7 @@ class AmazonClient:
items = self.search_raw(f"{search_name} album", types="track,album")
except AmazonClientError:
return []
albums: List[Album] = []
album_candidates: List[tuple] = [] # (Album, asin)
seen_asins: set = set()
name_lower = search_name.lower()
for item in items:
@ -588,13 +588,33 @@ class AmazonClient:
if album_asin in seen_asins:
continue
seen_asins.add(album_asin)
albums.append(Album.from_search_hit({
album = Album.from_search_hit({
"albumAsin": album_asin,
"albumName": item.album_name or item.title,
"artistName": item.artist_name,
}))
if len(albums) >= limit:
"albumName": _strip_edition(item.album_name or item.title),
"artistName": _primary_artist(item.artist_name),
})
album_candidates.append((album, album_asin))
if len(album_candidates) >= limit:
break
# Fetch metadata for art, release_date, track_count, and type inference.
# Cap at 10 parallel fetches — discography views don't need full coverage.
asins_to_fetch = [a for _, a in album_candidates[:10]]
metas = self._fetch_album_metas(asins_to_fetch)
albums: List[Album] = []
for album, asin in album_candidates:
meta = metas.get(asin, {})
if meta:
album.image_url = meta.get("image")
album.release_date = str(meta.get("release_date") or meta.get("releaseDate") or "")
total = int(meta.get("trackCount") or 0)
album.total_tracks = total
# T2Tunes doesn't expose release type — infer from track count.
# 1-track releases are singles; keep default "album" otherwise.
if total == 1:
album.album_type = "single"
albums.append(album)
return albums
def get_track_features(self, track_id: str) -> Optional[Dict[str, Any]]:

@ -7411,6 +7411,7 @@ def get_artist_detail(artist_id):
'itunes': artist_info.get('itunes_artist_id'),
'discogs': artist_info.get('discogs_id'),
'hydrabase': artist_info.get('soul_id'),
'amazon': artist_info.get('amazon_id'),
}
artist_detail_discography = _get_artist_detail_discography(

Loading…
Cancel
Save