fix(radio): fetch full track data for album radio
The /radio/album endpoint returns partial track objects without the performer field, causing all tracks to show as "Unknown Artist". Extract track IDs from the response and fetch each via get_track() to get complete data, matching the pattern used by artist/track radio.
This commit is contained in:
1 file changed
+18
-11
@@ -4337,21 +4337,28 @@ pub async fn v2_create_album_radio(
|
||||
.await
|
||||
.map_err(|e| format!("Failed to fetch album radio: {}", e))?;
|
||||
|
||||
let tracks: Vec<crate::api::Track> = radio_response
|
||||
.tracks
|
||||
.items
|
||||
.into_iter()
|
||||
.filter(|track| {
|
||||
// The radio endpoint returns partial track objects (missing performer, etc.).
|
||||
// Extract IDs and fetch full track data individually, same as artist/track radio.
|
||||
let track_ids: Vec<u64> = radio_response.tracks.items.iter().map(|t| t.id).collect();
|
||||
|
||||
if track_ids.is_empty() {
|
||||
return Err("No radio tracks returned for this album".to_string());
|
||||
}
|
||||
|
||||
let mut tracks = Vec::new();
|
||||
for track_id in track_ids {
|
||||
if let Ok(track) = client.get_track(track_id).await {
|
||||
if let Some(ref performer) = track.performer {
|
||||
!blacklist_state.is_blacklisted(performer.id)
|
||||
} else {
|
||||
true
|
||||
if blacklist_state.is_blacklisted(performer.id) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
tracks.push(track);
|
||||
}
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
if tracks.is_empty() {
|
||||
return Err("No radio tracks returned for this album".to_string());
|
||||
return Err("Failed to fetch any radio tracks".to_string());
|
||||
}
|
||||
|
||||
let queue_tracks: Vec<CoreQueueTrack> =
|
||||
|
||||
Reference in new issue
Block a user