mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 08:35:49 +03:00
[GH-ISSUE #1070] sp.recommendation() can't handle >5 artists/songs/genres as input - gives 401 error #630
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#630
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?
Originally created by @macafra on GitHub (Jan 14, 2024).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1070
Describe the bug
When I use sp.recommendations(), the total amount of artists, songs and genres I put in cannot exceed 5 before I get a 401 (no token provided) error. If I put in 5 or less artists/songs/genres, it outputs a recommendation as expected.
Your code
Expected behavior
I expect recommendations() to output a recommendation regardless of list length
Output
HTTP Error for GET to https://api.spotify.com/v1/recommendations with Params: {'limit': 20, 'seed_artists': '2WX2uTcsvV5OnS0inACecP,5pKCCKE2ajJHZ9KAiaK11H,6vWDO969PvNqNYHIOW5v0m,66CXWjxzNUsdJxJ2JdwvnR,1HY2Jd0NmPuamShAr6KMms', 'seed_genres': 'pop,metal', 'seed_tracks': '1NpDnkQO0yWxTtntrC0UNz,4VXIryQMWpIdGgYR4TrjT1'} returned 400 due to invalid request
Traceback (most recent call last):
File "[...]\spotipy\client.py", line 271, in _internal_call
response.raise_for_status()
File "[...]\requests\models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.spotify.com/v1/recommendations?limit=20&seed_artists=2WX2uTcsvV5OnS0inACecP%2C5pKCCKE2ajJHZ9KAiaK11H%2C6vWDO969PvNqNYHIOW5v0m%2C66CXWjxzNUsdJxJ2JdwvnR%2C1HY2Jd0NmPuamShAr6KMms&seed_genres=pop%2Cmetal&seed_tracks=1NpDnkQO0yWxTtntrC0UNz%2C4VXIryQMWpIdGgYR4TrjT1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "[...]\spotipy_test.py", line 72, in
show_recommendations(filter_artist_list(liked_artists), filter_genre_list(liked_genres), filter_song_list(liked_songs))
File "[...]\spotipy_test.py", line 61, in show_recommendations
results = spotify.recommendations(seed_artists=artists, seed_genres=genres, seed_tracks=songs, limit=20)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "[...]\spotipy\client.py", line 1712, in recommendations
return self._get("recommendations", **params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File [...]\spotipy\client.py", line 323, in _get
return self._internal_call("GET", url, payload, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "[...]\spotipy\client.py", line 293, in _internal_call
raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 400, code:-1 - https://api.spotify.com/v1/recommendations?limit=20&seed_artists=2WX2uTcsvV5OnS0inACecP%2C5pKCCKE2ajJHZ9KAiaK11H%2C6vWDO969PvNqNYHIOW5v0m%2C66CXWjxzNUsdJxJ2JdwvnR%2C1HY2Jd0NmPuamShAr6KMms&seed_genres=pop%2Cmetal&seed_tracks=1NpDnkQO0yWxTtntrC0UNz%2C4VXIryQMWpIdGgYR4TrjT1:
invalid request, reason: None
Environment:
Additional context
Add any other context about the problem here.
@macafra commented on GitHub (Jan 14, 2024):
I noticed the intention of the function is max 5 seeds