Search Exception 404
given these lists:
owner_ids = []
playlist_name = []
playlist_ids = []
I am querying the search
endpoint
in Spotify, using the following function
def query_playlists(query):
results = sp.search(q=query, type='playlist')
playlist_items = results['playlists']['items']
for item in playlist_items:
playlist_name.append(item['name'])
playlist_ids.append(item['id'])
owner = item['owner']
owner_ids.append(owner['id'])
results = [[sp.user_playlist(username, playlist_id) for username in owner_ids] for playlist_id in playlist_ids]
print results
but I get the following error:
spotipy.client.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/users/12128526200/playlists/1ESwfz8otcu5uk5bNp3Mzq: Not found.
Is this a bug or my mistake?
Looks like you are searching for combinations of users and playlists that don't exist.= in sp.user_playlist
. for each iteration of the loop, you are appending to a global owner_ids
list and then iterating over it in the list comprehension. So at the second loop iteration, you will get combos that don't make sense, ie URLs that don't exist (404 not found).
下一篇: 搜索异常404