Getting several tracks audio features returning error 429
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'm working on a web app, I code in Python and using Spotipy. I want to build a large datasets for my saved tracks that retrieves different track features. For that I'm using the audio_features as well. When going through my code line, it returns error code 429 (max retries achieved). I even tried to create a new spotify app and try with new credentials but still. Here's my code below for reference.
def build_saved_tracks_dataset(limit_step=50):
user = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id='client_id',
client_secret='client_secret',
redirect_uri='http://localhost:8080',
scope='user-library-read'))
tracks = list()
offset = 0
while True:
response = user.current_user_saved_tracks(limit=limit_step,
offset=offset)
if len(response['items']) == 0:
break
offset += limit_step
track_ids = [item['track']['id'] for item in response['items']]
artists_id = [item['track']['artists'][0]['id'] for item in response['items']]
audio_features = user.audio_features(track_ids)
artists = user.artists(artists_id)
for track, artist, audio_feature in zip(response['items']['track'], artists, audio_features):
genres = ','.join(genre for genre in artist[0]['genres'])
# tracks.append(id, name, artist, tempo...) Populating my dataset
pass
return tracks
Note that if I delete the audio_features line and ll he parameters in the dict that comes with it, the code works, so its weird that the limitation is only applied to audio_features.
I gave it 24 hours before trying again and same
Any idea on how to resolve this ?
Thanks !
Labels:
- Labels:
-
audio_features
-
Spotipy
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page