Reputation: 21
I'm trying to build a program with spotipy that will create a custom spotify playlist. I succeeded to get three lists with the current_user_recently_played() function that contain the recently played genres, artists and tracks. according to that three lists i'm trying to use the spotipy.client.Spotify.recommendations in order to get recommendations by those three parameters. the func description from the spotipy documentation
this is the code:
recommendations = spotify.recommendations(seed_artists=artists, seed_genres=genres, seed_tracks=tracks)
when:
artists = ['5eAWCfyUhZtHHtBdNk56l1', '6mdiAmATAx73kdxrNrnlao', '0epOFNiUfyON9EYx7Tpr6V']
tracks = ['31RTFPrB7wmYBhlkM2ILXG', '3nlGByvetDcS1uomAoiBmy', '55N8cxpE1QDoeaaNqUnoZ2']
genres = ['rock', 'metal', 'punk', 'grunge', 'pop']
When i'm runing the code I get this error:
HTTP Error for GET to https://api.spotify.com/v1/recommendations returned 400 due to invalid request
Traceback (most recent call last):
File "C:\Users\itama\AppData\Local\Programs\Python\Python37-32\lib\site-packages\spotipy\client.py", line 172, in _internal_call
response.raise_for_status()
File "C:\Users\itama\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\models.py", line 940, 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=5eAWCfyUhZtHHtBdNk56l1%2C6mdiAmATAx73kdxrNrnlao%2C0epOFNiUfyON9EYx7Tpr6V%2C7oPftvlwr6VrsViSDV7fJY&seed_genres=rock%2Cmetal%2Cpunk%2Cgrunge&seed_tracks=31RTFPrB7wmYBhlkM2ILXG%2C3nlGByvetDcS1uomAoiBmy%2C55N8cxpE1QDoeaaNqUnoZ2%2C3LRJbFT9rKoKv4aW7PuBJC
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\itama\Desktop\recommendation_playlist.py", line 50, in <module>
print(spotify.recommendations(seed_artists=artists[:4], seed_genres=genres[:4], seed_tracks=tracks[:4],))
File "C:\Users\itama\AppData\Local\Programs\Python\Python37-32\lib\site-packages\spotipy\client.py", line 1219, in recommendations
return self._get("recommendations", **params)
File "C:\Users\itama\AppData\Local\Programs\Python\Python37-32\lib\site-packages\spotipy\client.py", line 207, in _get
return self._internal_call("GET", url, payload, kwargs)
File "C:\Users\itama\AppData\Local\Programs\Python\Python37-32\lib\site-packages\spotipy\client.py", line 187, in _internal_call
headers=response.headers,
spotipy.exceptions.SpotifyException: http status: 400, code:-1 - https://api.spotify.com/v1/recommendations?limit=20&seed_artists=5eAWCfyUhZtHHtBdNk56l1%2C6mdiAmATAx73kdxrNrnlao%2C0epOFNiUfyON9EYx7Tpr6V%2C7oPftvlwr6VrsViSDV7fJY&seed_genres=rock%2Cmetal%2Cpunk%2Cgrunge&seed_tracks=31RTFPrB7wmYBhlkM2ILXG%2C3nlGByvetDcS1uomAoiBmy%2C55N8cxpE1QDoeaaNqUnoZ2%2C3LRJbFT9rKoKv4aW7PuBJC:
invalid request
any way to solve this? thank you
Upvotes: 1
Views: 4775