AppWorld Spotify: sum song durations, not song counts
When a playlist must cover a time-based duration requirement, do not use the
number of song_ids as a proxy for total time.
Rules
- Playlist search/library endpoints expose
song_idsbut not per-song durations. For each candidate playlist, callshow_songfor eachsong_idand sum the durations. - Print one sample
show_songresponse first and use only the duration field actually returned/documented there; do not assume its name.
total = sum(
apis.spotify.show_song(song_id=sid)["<duration_field>"]
for sid in candidate["song_ids"]
)
- Only select or start a playlist whose summed duration meets or exceeds the required duration.
Verification
Before answering, confirm every candidate was compared by summed show_song
durations, not by len(song_ids). If any candidate was compared by count,
recompute its total duration from actual song durations and re-check the
requirement.