python - 在 Spotify 上获取当前播放的歌曲
问题描述
我正在尝试使用 Python 在 Spotify 上获取当前播放的歌曲:
def get_currently_played_song():
response = requests.post(
'https://accounts.spotify.com/api/token',
data={
'grant_type': 'client_credentials'
},
auth=(SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET)
)
access_token = response.json()['access_token']
current_song = requests.get(
'https://api.spotify.com/v1/me/player/currently-playing',
headers={
'Authorization': f'Bearer {access_token}'
}
)
print(current_song)
但是,我得到了 404。我认为端点是错误的,但我不确定是否应该替换 URL 中的某些内容。我尝试用我的 Spotify 用户名替换“我”,但问题仍然存在。
解决方案
推荐阅读
- c++ - 从类中打印变量
- java - 从动态更新的 Application.properties 中读取
- javascript - 使用 getText() 的量角器中的断言错误
- powerbi - 从两个切片器中查找最大月份
- r - 过滤R中的记录
- php - 在 Symfony 3.4 中上传文件 - 更新操作 - 我应该如何编程 editAction?
- angular - 变量未定义的可观察打字稿
- c# - 团队构建期间设置的 wixtool 获取 light.exe System.UnauthorizedAccessException:访问路径
- grafana - 如何将视频/流添加到 Grafana 仪表板?
- android - webview的iframe下拉刷新