python - 在 spotipy 搜索方法中显示带有 preview_url 和曲目名称和图像的歌曲
问题描述
如何显示所有曲目及其 preview_urls 以及图像和曲目名称与 django 应用程序中的 spotipy 中的搜索查询匹配。
我正在尝试在下面执行此操作:
sp = client_credentials_manager=SpotifyClientCredentials()
track = sp.search("My Heart Will Go On", limit=10, offset=0, type='track', market=None)
现在如何从这个跟踪变量中检索上述信息。
解决方案
请注意有关如何授权您的 sp 客户端的文档
然后你可以使用搜索方法:
例子
client_id = 'your-client-id'
client_secret = 'your-client-secret'
auth_manager = SpotifyClientCredentials(client_id, client_secret)
sp = spotipy.Spotify(auth_manager=auth_manager)
track = sp.search("My Heart Will Go On", limit=10, offset=0, type='track', market=None)
tracks = track['tracks']
for item in tracks['items']:
print(item['preview_url'])
推荐阅读
- reactjs - 错误:应用程序(...):渲染没有返回任何内容。这通常意味着缺少返回语句
- swift - 如何从 macOS 应用程序中的文件系统读取图像
- unity3d - 使用 Hololens 1 和 Optitrack Trio bar 匹配对象位置和方向
- .net-core - 没有注册类型“Polly.Registry.IReadOnlyPolicyRegistry`1[System.String]”的服务
- sql-server - 插入更新触发器
- html - 如何为固定的背景图像位置启用滚动
- c++ - Boost:ASIO 接受器在数小时/数天后将套接字堆叠为 CLOSE_WAIT 状态
- android - Android 推送通知无法解析一些 html 代码,如 MsoNormal
- android - 单击通知后最小化应用程序时无法到达特定屏幕
- javascript - 在节点 js 中处理 json