fixed an issue wher ecollaborating artists would have the album listed as their own on library and artist page.

This commit is contained in:
Broque Thomas 2026-02-18 17:11:53 -08:00
parent 2ab52a340b
commit 7b6e94772e
2 changed files with 13 additions and 14 deletions

View file

@ -145,14 +145,15 @@ class Album:
album_type: str
image_url: Optional[str] = None
external_urls: Optional[Dict[str, str]] = None
artist_ids: Optional[List[str]] = None
@classmethod
def from_spotify_album(cls, album_data: Dict[str, Any]) -> 'Album':
# Get the largest image URL if available
image_url = None
if album_data.get('images') and len(album_data['images']) > 0:
image_url = album_data['images'][0]['url']
return cls(
id=album_data['id'],
name=album_data['name'],
@ -161,7 +162,8 @@ class Album:
total_tracks=album_data.get('total_tracks', 0),
album_type=album_data.get('album_type', 'album'),
image_url=image_url,
external_urls=album_data.get('external_urls')
external_urls=album_data.get('external_urls'),
artist_ids=[artist['id'] for artist in album_data['artists']]
)
@dataclass

View file

@ -5462,17 +5462,10 @@ def get_artist_discography(artist_id):
continue
seen_albums.add(album.id)
# Handle artist matching for both Spotify (objects) and iTunes (strings) formats
if hasattr(album, 'artists') and album.artists:
first_artist = album.artists[0]
# Check if artists are objects (Spotify) or strings (iTunes)
if hasattr(first_artist, 'id'):
# Spotify format: artist is an object with .id and .name
primary_artist_id = first_artist.id
# Skip if the primary artist doesn't match our requested artist
if primary_artist_id and primary_artist_id != artist_id:
continue
# iTunes format: artist is a string, can't verify ID match so include all
# Skip albums where this artist isn't the primary (first-listed) artist
if hasattr(album, 'artist_ids') and album.artist_ids:
if album.artist_ids[0] != artist_id:
continue
album_data = {
"id": album.id,
@ -25336,6 +25329,10 @@ def get_spotify_artist_discography(artist_name):
singles = []
for album in all_albums:
# Skip albums where this artist isn't the primary (first-listed) artist
if album.artist_ids and album.artist_ids[0] != spotify_artist_id:
continue
# Use the Album object properties
track_count = album.total_tracks