【问题标题】:Get Track Image in Spotipy在 Spotipy 中获取轨道图像
【发布时间】:2022-11-10 13:53:57
【问题描述】:

我正在尝试将当前播放的曲目的封面放在单独的窗口上。我正在使用 Spotipy,但我似乎无法找到如何获取曲目的图像。有没有办法使用 Spotipy 获得封面?

【问题讨论】:

    标签: python spotipy


    【解决方案1】:

    我从未使用过 spotipy,但我快速查看了文档,Getting Started 页面上的第二个示例显示了如何获取专辑图片的 URL。下一个示例显示如何获取给定艺术家的图像。我将展示一个引用专辑封面的:

    import spotipy
    from spotipy.oauth2 import SpotifyClientCredentials
    
    lz_uri = 'spotify:artist:36QJpDe2go2KgaRleHCDTp'
    
    spotify = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
    results = spotify.artist_top_tracks(lz_uri)
    
    for track in results['tracks'][:10]:
        print('track    : ' + track['name'])
        print('audio    : ' + track['preview_url'])
        print('cover art: ' + track['album']['images'][0]['url'])
        print()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-21
      • 1970-01-01
      • 1970-01-01
      • 2021-05-05
      相关资源
      最近更新 更多