在 spotipy 搜索方法中显示带有 preview_url 的歌曲以及曲目名称和图像

Display song with preview_url and track name and image in spotipy search method

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

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

注意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'])