spotipy-dev / spotipy

A light weight Python library for the Spotify Web API
http://spotipy.readthedocs.org
MIT License
5.01k stars 953 forks source link

Recommendation endpoint ignoring seeds #123

Closed eoinmcc closed 3 years ago

eoinmcc commented 8 years ago

It appears that when a list of seeds is provided(genre, artist, track) only the first seed in the array is used by the recommendation api.

It looks like this is as a result of some mismatch between how the requests library unpacks the array as separate params in the GET, and how the Spotify api endpoint expects multiple seeds to be supplied (as a comma separated single param)

Example.... Spotipy's currently implemntation expands to the following request. https://api.spotify.com/v1/recommendations?seed_artists=3dz0NnIZhtKKeXZxLOxCam&seed_artists=3CjlHNtplJyTf9npxaPl5w

but the response reports on 1 seed where 2 were provided... u'seeds': [{u'afterFilteringSize': 250, u'href': u'https://api.spotify.com/v1/artists/3dz0NnIZhtKKeXZxLOxCam', u'initialPoolSize': 250, u'type': u'ARTIST', u'id': u'3dz0NnIZhtKKeXZxLOxCam', u'afterRelinkingSize': 250}]

Passing the 2 seeds as a comma seperated param gives us the expected response. https://api.spotify.com/v1/recommendations?seed_artists=3dz0NnIZhtKKeXZxLOxCam,3CjlHNtplJyTf9npxaPl5w

response reports on 2 seeds... u'seeds': [{u'afterFilteringSize': 250, u'href': u'https://api.spotify.com/v1/artists/3dz0NnIZhtKKeXZxLOxCam', u'initialPoolSize': 250, u'type': u'ARTIST', u'id': u'3dz0NnIZhtKKeXZxLOxCam', u'afterRelinkingSize': 250}, {u'afterFilteringSize': 250, u'href': u'https://api.spotify.com/v1/artists/3CjlHNtplJyTf9npxaPl5w', u'initialPoolSize': 250, u'type': u'ARTIST', u'id': u'3CjlHNtplJyTf9npxaPl5w', u'afterRelinkingSize': 250}]

I've been working around by supplying the seeds as list with 1 item (i.e. ['3dz0NnIZhtKKeXZxLOxCam,3CjlHNtplJyTf9npxaPl5w'].. This gives me the second result above.

Same is true of genre (and I believe the track) seed params. I believe @mkb218 submitted a pull request for this original.

Happy to take a swing at fix if you'd prefer.

ecowan commented 7 years ago

Has this been addressed? I am still seeing this behavior.

jdormuth commented 6 years ago

Yes ^^, also still seeing this problem.

stephanebruckert commented 3 years ago

Closing since this is 4 years old without updates