fixed an issue wher ecollaborating artists would have the album listed as their own on library and artist page.
This commit is contained in:
parent
2ab52a340b
commit
7b6e94772e
2 changed files with 13 additions and 14 deletions
|
|
@ -145,6 +145,7 @@ class Album:
|
||||||
album_type: str
|
album_type: str
|
||||||
image_url: Optional[str] = None
|
image_url: Optional[str] = None
|
||||||
external_urls: Optional[Dict[str, str]] = None
|
external_urls: Optional[Dict[str, str]] = None
|
||||||
|
artist_ids: Optional[List[str]] = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_spotify_album(cls, album_data: Dict[str, Any]) -> 'Album':
|
def from_spotify_album(cls, album_data: Dict[str, Any]) -> 'Album':
|
||||||
|
|
@ -161,7 +162,8 @@ class Album:
|
||||||
total_tracks=album_data.get('total_tracks', 0),
|
total_tracks=album_data.get('total_tracks', 0),
|
||||||
album_type=album_data.get('album_type', 'album'),
|
album_type=album_data.get('album_type', 'album'),
|
||||||
image_url=image_url,
|
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
|
@dataclass
|
||||||
|
|
|
||||||
|
|
@ -5462,17 +5462,10 @@ def get_artist_discography(artist_id):
|
||||||
continue
|
continue
|
||||||
seen_albums.add(album.id)
|
seen_albums.add(album.id)
|
||||||
|
|
||||||
# Handle artist matching for both Spotify (objects) and iTunes (strings) formats
|
# Skip albums where this artist isn't the primary (first-listed) artist
|
||||||
if hasattr(album, 'artists') and album.artists:
|
if hasattr(album, 'artist_ids') and album.artist_ids:
|
||||||
first_artist = album.artists[0]
|
if album.artist_ids[0] != artist_id:
|
||||||
# Check if artists are objects (Spotify) or strings (iTunes)
|
continue
|
||||||
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
|
|
||||||
|
|
||||||
album_data = {
|
album_data = {
|
||||||
"id": album.id,
|
"id": album.id,
|
||||||
|
|
@ -25336,6 +25329,10 @@ def get_spotify_artist_discography(artist_name):
|
||||||
singles = []
|
singles = []
|
||||||
|
|
||||||
for album in all_albums:
|
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
|
# Use the Album object properties
|
||||||
track_count = album.total_tracks
|
track_count = album.total_tracks
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue