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
|
.await
|
||||||
.map_err(|e| format!("Failed to fetch album radio: {}", e))?;
|
.map_err(|e| format!("Failed to fetch album radio: {}", e))?;
|
||||||
|
|
||||||
let tracks: Vec<crate::api::Track> = radio_response
|
// The radio endpoint returns partial track objects (missing performer, etc.).
|
||||||
.tracks
|
// Extract IDs and fetch full track data individually, same as artist/track radio.
|
||||||
.items
|
let track_ids: Vec<u64> = radio_response.tracks.items.iter().map(|t| t.id).collect();
|
||||||
.into_iter()
|
|
||||||
.filter(|track| {
|
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 {
|
if let Some(ref performer) = track.performer {
|
||||||
!blacklist_state.is_blacklisted(performer.id)
|
if blacklist_state.is_blacklisted(performer.id) {
|
||||||
} else {
|
continue;
|
||||||
true
|
}
|
||||||
|
}
|
||||||
|
tracks.push(track);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
if tracks.is_empty() {
|
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> =
|
let queue_tracks: Vec<CoreQueueTrack> =
|
||||||
|
|||||||
Reference in new issue
Block a user