【问题标题】:Spotify API, desktop appSpotify API,桌面应用程序
【发布时间】:2019-01-22 09:40:46
【问题描述】:

我想在 Python 中创建 Spotify 桌面应用程序,但我阅读了 API 文档,但我找不到任何关于让歌曲流在我的应用程序中播放的信息。在文档中有声明说 API 响应始终采用 json 格式。那么有没有办法通过API播放歌曲呢?

【问题讨论】:

  • 查看他们的 API 页面,不,它说:Based on simple REST principles, the Spotify Web API endpoints return JSON metadata about music artists, albums, and tracks, directly from the Spotify Data Catalogue。所以元数据,与歌曲无关。
  • 正如我所想,但我看过一些流或 yt 视频,其中有人正在用 C++ 制作他的 Spotify 客户端,但我找不到它

标签: python rest api spotify


【解决方案1】:

我没有使用过 spotify api,但快速浏览一下 API 文档,您应该可以使用这个 https://developer.spotify.com/documentation/web-api/reference/tracks/get-track/

将 is_playable 设置为 True 并且您应该可以播放它。

我会做的代码:

import requests

headers = {
    'Authorization': 'Bearer {your access token}',
}

response = requests.get('https://api.spotify.com/v1/tracks/11dFghVXANMlKmJXsNCbNl', headers=headers)

is_playable 字段将在 GET 调用中返回。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-19
    • 2021-03-18
    • 2014-08-09
    • 2022-11-28
    • 2020-12-21
    • 1970-01-01
    • 2017-07-28
    • 1970-01-01
    相关资源
    最近更新 更多