【问题标题】:Display song with preview_url and track name and image in spotipy search method在 spotipy 搜索方法中显示带有 preview_url 和曲目名称和图像的歌曲
【发布时间】:2020-10-02 03:18:29
【问题描述】:

如何显示所有曲目及其 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)

现在如何从这个跟踪变量中检索上述信息。

【问题讨论】:

    标签: python django spotipy


    【解决方案1】:

    关注documentation如何授权你的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'])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-31
      • 1970-01-01
      • 1970-01-01
      • 2018-12-25
      相关资源
      最近更新 更多