fix: config page

This commit is contained in:
xoconoch
2025-08-30 10:35:56 -06:00
parent 3ff6134712
commit 46af6b518d
3 changed files with 218 additions and 107 deletions

View File

@@ -1305,11 +1305,35 @@ def _fetch_artist_discography_page(artist_id: str, limit: int, offset: int) -> d
for key in ("album_group", "single_group", "compilation_group", "appears_on_group"):
grp = artist.get(key)
if isinstance(grp, list):
all_items.extend(grp)
# Check if items are strings (IDs) or dictionaries (metadata)
if grp and isinstance(grp[0], str):
# Items are album IDs as strings, fetch metadata for each
for album_id in grp:
try:
album_data = client.get_album(album_id, include_tracks=False)
if album_data:
# Add the album_group type for filtering
album_data["album_group"] = key.replace("_group", "")
all_items.append(album_data)
except Exception as e:
logger.warning(f"Failed to fetch album {album_id}: {e}")
else:
# Items are already dictionaries (album metadata)
for item in grp:
if isinstance(item, dict):
# Ensure album_group is set for filtering
if "album_group" not in item:
item["album_group"] = key.replace("_group", "")
all_items.append(item)
elif isinstance(grp, dict):
items = grp.get("items") or grp.get("releases") or []
if isinstance(items, list):
all_items.extend(items)
for item in items:
if isinstance(item, dict):
# Ensure album_group is set for filtering
if "album_group" not in item:
item["album_group"] = key.replace("_group", "")
all_items.append(item)
total = len(all_items)
start = max(0, offset or 0)
end = start + max(1, limit or 50)