【问题标题】:Retrieve cover artwork using Spotify API使用 Spotify API 检索封面图稿
【发布时间】:2012-04-24 19:30:08
【问题描述】:

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

【问题讨论】:

    标签: api spotify


    【解决方案1】:

    2014 年 6 月 17 日:

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

    现在很容易检索封面插图,因为 all endpoints 包含一个 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
    ...
        } ],
    ...
      }
    }
    

    旧答案:


    您可以通过调用 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:artist:7ae4vgLLhir2MCjyhgbGOQ
    使用 JSONP:
    https://embed.spotify.com/oembed/?url=spotify: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>"
    }
    

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

    /cover/ 代表缩略图的大小。
    可用尺寸:6085120140160165230300320640

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

    【讨论】:

    • 很好的解决方案!!没有关于此的文档(我认为)。一个技巧:不要忘记包含一个“&callback=?”在您使用 getJSON() 调用 oembed api 使其成为 JSONP(它对我有用)之后,如果不是,您可能会收到:_XMLHttpRequest cannot load embed.spotify.com/oembed/?url=...... Origin http:.... is not allowed通过访问控制允许来源。 _
    • @jeraldov 元数据 API 不会将 URL 返回到任何端点中的封面(/search/lookup)。您必须使用专辑或艺术家的hrefws.spotify.com 中的任何内容,然后使用上述方法。
    【解决方案2】:

    有计划实施它,例如,我们希望它在那里,但没有人致力于它。这主要是使用条款的法律问题。

    从技术上讲,当然可以通过解析 html 来计算并访问例如 open.spotify.com 使用的相同图像。这当然是不允许的,但从技术上讲,没有什么可以阻止访问。

    (我在 Spotify 工作)

    【讨论】:

    • 感谢 jooon(抱歉回复晚了),但我希望有一个官方的方式来做到这一点。 rdio 或grooveshark 等类似服务通过他们的api 提供对封面艺术作品的访问,所以我希望spotify 也能提供这个。
    • 如果您有权访问 App API(在 Spotify 桌面播放器中运行),您可以通过在 spotify URI 的字符串表示上调用“toSpotifyURL()”来检索图像。例如,“spotify:image:f599d6e88c79432ddb2cf4743d0ba69b8014c5ba”变成this
    【解决方案3】:
    猜你喜欢
    • 1970-01-01
    • 2012-03-20
    • 2012-06-05
    • 1970-01-01
    • 1970-01-01
    • 2014-06-18
    相关资源
    最近更新 更多