Retrieving a user's top songs
I'm new to using the Spotify API and am struggling with pulling the selected user's top songs in the short term. I'm using Spotipy and flask to run my program on a local server. I get prompted to sign into Spotify and I've managed to pull my saved songs, but every time I try to pull my top songs I get this error in my terminal:
line 73, in topTracks
track = item['track']
KeyError: 'track'
Here are the lines that are causing the error:
curGroup = sp.current_user_top_tracks(limit=20, offset=offset, time_range='short_term')['items']
for idx, item in enumerate(curGroup):
track = item['track']
If someone could tell me what I need to change I would greatly appreciate it. Thanks!