使用Spotify API检索封面图稿

idl*_*erg 19 api spotify

目前无法使用Spotify的Web API检索封面图稿.是否有计划实施这些或任何变通方法?

Min*_*God 32

2014年6月17日:

今天Spotify发布了一个新的Web API.

现在可以轻松检索封面图稿,因为所有端点都包含一个images适用于每个端点的数组item.


搜索示例:
curl -X GET "https://api.spotify.com/v1/search?q=tania%20bowra&type=artist"

{
  "artists" : {
...
    "items" : [ {
...
      "images" : [ {
        "height" : 640,
        "url" : "https://d3rt1990lpmkn.cloudfront.net/original/f2798ddab0c7b76dc2d270b65c4f67ddef7f6718",
        "width" : 640
      }, {
        "height" : 300,
        "url" : "https://d3rt1990lpmkn.cloudfront.net/original/b414091165ea0f4172089c2fc67bb35aa37cfc55",
        "width" : 300
      }, {
        "height" : 64,
        "url" : "https://d3rt1990lpmkn.cloudfront.net/original/8522fc78be4bf4e83fea8e67bb742e7d3dfe21b4",
        "width" : 64
...
    } ],
...
  }
}
Run Code Online (Sandbox Code Playgroud)

旧答案:


您可以通过调用Spotify的oEmbed服务获取封面艺术的URL:

https://embed.spotify.com/oembed/?url=spotify:track:6bc5scNUVa3h76T9nvpGIH
https://embed.spotify.com/oembed/?url=spotify:album:5NCz8TTIiax2h1XTnImAQ2
https://embed.spotify.com/ oembed /?url = spotify:艺术家:7ae4vgLLhir2MCjyhgbGOQ
使用JSONP:https ://embed.spotify.com/oembed/?url = spark:artist:7ae4vgLLhir2MCjyhgbGOQ &callback = callme

http://open.spotify.com/ 网址也有效:

https://embed.spotify.com/oembed/?url=http://open.spotify.com/track/6bc5scNUVa3h76T9nvpGIH

{
    "provider_url": "https:\/\/www.spotify.com",
    "version": "1.0",
    "thumbnail_width": 300,
    "height": 380,
    "thumbnail_height": 300,
    "title": "Gusgus - Within You",
    "width": 300,
    "thumbnail_url": "https:\/\/d3rt1990lpmkn.cloudfront.net\/cover\/f15552e72e1fcf02484d94553a7e7cd98049361a",
    "provider_name": "Spotify",
    "type": "rich",
    "html": "<iframe src=\"https:\/\/embed.spotify.com\/?uri=spotify:track:6bc5scNUVa3h76T9nvpGIH\" width=\"300\" height=\"380\" frameborder=\"0\" allowtransparency=\"true\"><\/iframe>"
}
Run Code Online (Sandbox Code Playgroud)

请注意thumbnail_url:https:
//d3rt1990lpmkn.cloudfront.net/cover/f15552e72e1fcf02484d94553a7e7cd98049361a

/cover/表示缩略图的大小.
可用的大小:60,85,120,140,160,165,230,300,320,和640.

例如:https://d3rt1990lpmkn.cloudfront.net/640/f15552e72e1fcf02484d94553a7e7cd98049361a

  • 好方案!没有关于此的文件(我认为).一招:别忘了加入"&callback =?" 用你的oembed api调用getJSON()使它成为JSONP(它对我有用),如果不是你可能会收到:_XMLHttpRequest无法加载https://embed.spotify.com/oembed/?url = .... ..原点http:....不允许使用Access-Control-Allow-Origin._ (3认同)

joo*_*oon 17

有计划实施它,因为我们希望它在那里,但没有人在努力.这主要是使用条款的法律问题.

从技术上讲,当然可以通过解析html来计算并访问open.spotify.com使用的相同图像.当然不允许这样做,但技术上没有任何东西可以阻止访问.

(我在Spotify工作)