搜索异常404
给出这些列表:
owner_ids = []
playlist_name = []
playlist_ids = []
我正在使用以下function
查询Spotify中的search
endpoint
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
但我得到以下错误:
spotipy.client.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/users/12128526200/playlists/1ESwfz8otcu5uk5bNp3Mzq: Not found.
这是一个错误还是我的错误?
看起来您正在搜索不存在的用户和播放列表的组合。=在sp.user_playlist
。 对于循环的每次迭代,您将追加到全局owner_ids
列表中,然后在列表理解中迭代它。 所以在第二次循环迭代时,你会得到没有意义的组合,即不存在的URL(404找不到)。
上一篇: Search Exception 404