【发布时间】:2021-03-08 05:23:08
【问题描述】:
我正在关注 tutorial 以创建 Spotify 播放列表。我已经遵循了每一步,但我遇到了授权问题。
它应该返回一个包含歌曲的列表(稍后我会将它们输入到播放列表中),但我收到此错误:
这是我的代码:
import requests
url = "https://api.spotify.com/v1/recommendations?"
token = "I WILL CREATE A TOKEN GETTER"
#Filtros
limit = input("How many songs? ")
market = "ES"
seed_genres = input("Select the genres: ")
target_energy = int(input("From 0 to 10 how energetic do you want your playlist? "))/10
#Contactar con Spotify
query = f"{url}limit={limit}&market={market}&seed_genres={seed_genres}&target_energy={target_energy}"
response = requests.get(query,
headers = {"Content-Type":"application/json",
"Authorization": f'{token}'})
json_response = response.json()
for i in json_response['tracks']:
uris.append(i)
print(f"\"{i['name']}\" by {i['artists'][0]['name']}")
【问题讨论】: