mirror of
https://github.com/ramsayleung/rspotify.git
synced 2026-04-26 07:55:55 +03:00
[PR #422] [MERGED] Update tracks_features data model to more accurately reflect API response #444
Labels
No labels
Stale
bug
discussion
enhancement
good first issue
good first issue
help wanted
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/rspotify#444
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ramsayleung/rspotify/pull/422
Author: @caass
Created: 5/31/2023
Status: ✅ Merged
Merged: 5/31/2023
Merged by: @ramsayleung
Base:
master← Head:master📝 Commits (4)
b275dfdUpdate tracks_features data model to more accurately reflect API response872ca76Add test for known featureless trackf46b546Update changelog779d4ccNote breaking change📊 Changes
4 files changed (+9 additions, -3 deletions)
View changed files
📝
CHANGELOG.md(+2 -0)📝
rspotify-model/src/audio.rs(+1 -1)📝
src/clients/base.rs(+4 -2)📝
tests/test_with_credential.rs(+2 -0)📄 Description
Description
When querying
tracks_features, the Spotify API will sometimes returnnullinstead ofAudioFeaturesfor a track, resulting in a deserialization error. This PR updates the internalAudioFeaturesPayloadtype to be aVec<Option<AudioFeature>>rather than aVec<AudioFeature>to avoid breaking on deserialization.Motivation and Context
When getting audio features for several thousand tracks, I could consistently get rspotify to choke on a
nullresult for one of the IDs (6z99LwRS28wga9xc2u09Po). Here's the response I get:I figured it'd be best to avoid breaking the
tracks_featuresAPI by changing the return type fromOption<Vec<AudioFeature>>toOption<Vec<Option<AudioFeature>>>, so there's now a flattening step in between receiving the API response and returning the list of audio features. This means that you won't be able to 1:1 map a result fromtracks_featuresto the input tracks, but I don't think that was guaranteed anyway.Dependencies
None.
Type of change
Please delete options that are not relevant.
How has this been tested?
I added "spotify:track:6z99LwRS28wga9xc2u09Po" as a test case to
test_audios_features, which is a spotify track (https://open.spotify.com/track/6z99LwRS28wga9xc2u09Po) that returnsnullwhen querying for audio features.Is this change properly documented?
I stuck it in the changelog, but I don't think there needs to be any doc updates.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.