fix: use correct fields from AlbumSummary in musician appearances
AlbumSummary only has id, title, image, and label fields. The code was incorrectly trying to access artist and release_date_original which only exist on the full Album struct. - Use track.performer for artist_name instead of album.artist - Set year to None since AlbumSummary doesn't have release_date - Fix image access since ImageSet is direct field, not Option - Fix title access since String is direct field, not Option
This commit is contained in:
1 parent
e9f67ed1cf
commit
74d2059b8a
1 file changed
+9
-12
@@ -171,24 +171,21 @@ pub async fn get_musician_appearances(
|
|||||||
|
|
||||||
albums.push(AlbumAppearance {
|
albums.push(AlbumAppearance {
|
||||||
album_id: album.id.clone(),
|
album_id: album.id.clone(),
|
||||||
album_title: album.title.clone().unwrap_or_default(),
|
album_title: album.title.clone(),
|
||||||
album_artwork: album
|
album_artwork: album
|
||||||
.image
|
.image
|
||||||
.as_ref()
|
.large
|
||||||
.and_then(|i| i.large.clone())
|
.clone()
|
||||||
.or_else(|| album.image.as_ref().and_then(|i| i.thumbnail.clone()))
|
.or_else(|| album.image.thumbnail.clone())
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
|
// AlbumSummary doesn't have artist field, use track's performer
|
||||||
artist_name: track
|
artist_name: track
|
||||||
.album
|
.performer
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|a| a.artist.as_ref())
|
.map(|p| p.name.clone())
|
||||||
.map(|a| a.name.clone())
|
|
||||||
.unwrap_or_else(|| performer_name.to_string()),
|
.unwrap_or_else(|| performer_name.to_string()),
|
||||||
year: album
|
// AlbumSummary doesn't have release_date_original
|
||||||
.release_date_original
|
year: None,
|
||||||
.as_ref()
|
|
||||||
.and_then(|d| d.split('-').next())
|
|
||||||
.map(|s| s.to_string()),
|
|
||||||
role_on_album: role,
|
role_on_album: role,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user