给出这些清单:
owner_ids = []
playlist_name = []
playlist_ids = []
我使用以下search
endpoint
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
但是我收到以下错误:
spotipy.client.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/users/12128526200/playlists/1ESwfz8otcu5uk5bNp3Mzq:
Not found.
这是一个错误还是我的错误?
答案 0 :(得分:0)
您似乎正在搜索不存在的用户和播放列表组合。= sp.user_playlist
。对于循环的每次迭代,您将附加到全局owner_ids
列表,然后在列表解析中迭代它。因此,在第二次循环迭代中,您将获得无意义的组合,即不存在的URL(未找到404)。