You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The search function for tracks sometimes results in an empty array even though the songs are available on Spotify.
Your code
songURIList = [] # List to store the URIs
for idx,_ in tqdm(dfBillbaords[0:10].iterrows()):
artist = dfBillbaords['Artist'][idx]
track = dfBillbaords['Song'][idx]
year = dfBillbaords['Year'][idx]
searchResults = sp.search(q=f"artist: {artist} track: {track} year: {year}",type='track')
if len(searchResults['tracks']['items'])>0:
songURI = searchResults['tracks']['items'][0]['uri'] #Getting the URI of the first track in search result
else:
songURI = 'Unavailable' #Assigning URI as 'Unavailable'
songURIList.append(songURI)
time.sleep(5)
Expected behavior
The search result should be the same every time.
However the search result changes every time I run. It is not reproducible.
Output
Case 1:
Case 2:
Notice the difference in outputs between the two cases above,
The output is quite erratic and changing with every re-run.
The search function is failing to fetch the songs even if they're available.
Environment:
OS: Windows 11
Python version: 3.8.8
spotipy version: 2.2
IDE : Jupyter Notebook IDE
The text was updated successfully, but these errors were encountered:
I believe this is an Spotify API issue with the single quotes (') in the track names. If you remove the single quote from the track titles, you should be good.
Describe the bug
The search function for tracks sometimes results in an empty array even though the songs are available on Spotify.
Your code
Expected behavior
The search result should be the same every time.
However the search result changes every time I run. It is not reproducible.
Output
Case 1:
Case 2:
Notice the difference in outputs between the two cases above,
The output is quite erratic and changing with every re-run.
The search function is failing to fetch the songs even if they're available.
Environment:
The text was updated successfully, but these errors were encountered: