2017-05-06 97 views
0

我在我的Windows 10上下载了Spotify App并进行了安装。所以我有一个理想的做法,那就是制作一个需要获得当前正在运行的音乐的软件。有可能得到它吗?它没有必要的代码。我只想知道从哪里开始,因为我没有发现任何关于它的事情。我宁愿用python来做。如何使用python获取Spotify中的实际音乐?

+3

当你说“得到真正的音乐”时,你的意思是 - 你想获得正在播放的实际声音,或者有关正在播放的曲目的信息? – bouteillebleu

+1

Spotify拥有适用于当前正在播放音乐的API https://developer.spotify.com/web-api/user-guide/ –

+0

我想获取关于该曲目的信息,@bouteillebleu – Benedito

回答

1

您可以使用得到用户的当前播放的曲目终点,这里记载:https://developer.spotify.com/web-api/get-the-users-currently-playing-track/

端点将返回JSON,其中包括有关轨道的信息,例如:

{ 
    "context": { 
    "external_urls" : { 
     "spotify" : "http://open.spotify.com/user/spotify/playlist/49znshcYJROspEqBoHg3Sv" 
    }, 
    "href" : "https://api.spotify.com/v1/users/spotify/playlists/49znshcYJROspEqBoHg3Sv", 
    "type" : "playlist", 
    "uri" : "spotify:user:spotify:playlist:49znshcYJROspEqBoHg3Sv" 
    }, 
    "timestamp": 1490252122574, 
    "progress_ms": 44272, 
    "is_playing": true, 
    "item": { 
    "album": { 
     "album_type": "album", 
     "external_urls": { 
     "spotify": "https://open.spotify.com/album/6TJmQnO44YE5BtTxH8pop1" 
     }, 
     "href": "https://api.spotify.com/v1/albums/6TJmQnO44YE5BtTxH8pop1", 
     "id": "6TJmQnO44YE5BtTxH8pop1", 
     "images": [ 
     { 
      "height": 640, 
      "url": "https://i.scdn.co/image/8e13218039f81b000553e25522a7f0d7a0600f2e", 
      "width": 629 
     }, 
     { 
      "height": 300, 
      "url": "https://i.scdn.co/image/8c1e066b5d1045038437d92815d49987f519e44f", 
      "width": 295 
     }, 
     { 
      "height": 64, 
      "url": "https://i.scdn.co/image/d49268a8fc0768084f4750cf1647709e89a27172", 
      "width": 63 
     } 
     ], 
     "name": "Hot Fuss", 
     "type": "album", 
     "uri": "spotify:album:6TJmQnO44YE5BtTxH8pop1" 
    }, 
    "artists": [ 
     { 
     "external_urls": { 
      "spotify": "https://open.spotify.com/artist/0C0XlULifJtAgn6ZNCW2eu" 
     }, 
     "href": "https://api.spotify.com/v1/artists/0C0XlULifJtAgn6ZNCW2eu", 
     "id": "0C0XlULifJtAgn6ZNCW2eu", 
     "name": "The Killers", 
     "type": "artist", 
     "uri": "spotify:artist:0C0XlULifJtAgn6ZNCW2eu" 
     } 
    ], 
    "available_markets": [ 
     "AD", 
     "AR", 
    ... 
     "TW", 
     "UY" 
    ], 
    "disc_number": 1, 
    "duration_ms": 222075, 
    "explicit": false, 
    "external_ids": { 
     "isrc": "USIR20400274" 
    }, 
    "external_urls": { 
     "spotify": "https://open.spotify.com/track/0eGsygTp906u18L0Oimnem" 
    }, 
    "href": "https://api.spotify.com/v1/tracks/0eGsygTp906u18L0Oimnem", 
    "id": "0eGsygTp906u18L0Oimnem", 
    "name": "Mr. Brightside", 
    "popularity": 0, 
    "preview_url": "http://d318706lgtcm8e.cloudfront.net/mp3-preview/f454c8224828e21fa146af84916fd22cb89cedc6", 
    "track_number": 2, 
    "type": "track", 
    "uri": "spotify:track:0eGsygTp906u18L0Oimnem" 
    } 
} 

如果您想要了解关于该曲目的更多信息,您可以使用您从此端点获得的id拨打Track端点中的任意一个:https://developer.spotify.com/web-api/track-endpoints/。有很多有趣的事情可以做,比如音频功能或分析。

相关问题