【问题标题】:How can I search for albums with generic titles using the Spotify Web API?如何使用 Spotify Web API 搜索具有通用标题的专辑?
【发布时间】:2013-03-04 11:41:30
【问题描述】:

可以使用Spotify Web API在 Spotify 目录中按名称搜索专辑。

但是,如果专辑名称是常用词或短语,则搜索响应可能包含数千个结果。我找不到按艺术家姓名缩小搜索范围的方法。

这里是一个例子:搜索艺术家Giant Panda Guerilla Dub Squad的专辑Country。

API 请求是:

http://ws.spotify.com/search/1/album?q=country

回复是:

<?xml version="1.0" encoding="UTF-8"?>
<albums xmlns="http://www.spotify.com/ns/music/1" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
  <opensearch:Query role="request" startPage="1" searchTerms="country" />
  <opensearch:totalResults>11861</opensearch:totalResults>
  <opensearch:startIndex>0</opensearch:startIndex>
  <opensearch:itemsPerPage>100</opensearch:itemsPerPage>
  <album href="spotify:album:1Wcnyz2zYWLIPZ1K63RXdW">
    <name>How Country Feels</name>
    <artist href="spotify:artist:56x8mYvS3cyDGAi8N2FxbB">
      <name>Randy Houser</name>
    </artist>
    <id type="upc">886443789852</id>
    <popularity>0.73964</popularity>
    <availability>
      <territories>CA US</territories>
    </availability>
  </album>
  ...more albums...
</albums>

有11861条结果,分页,每页100张专辑。可以发出请求以获取下一页,但如果我要查找的专辑在最后一页上,我将不得不向 API 发出 118 次单独的请求,然后才能找到它。

有没有更好的办法?

【问题讨论】:

    标签: api search spotify


    【解决方案1】:

    您可以使用高级搜索查询语言来提供帮助,尤其是在您事先认识艺术家的情况下。例如:

    http://ws.spotify.com/search/1/album?q=artist:Giant Panda Guerilla Dub Squad

    ...将搜索限制为该艺术家的专辑。

    http://ws.spotify.com/search/1/album?q=artist:Giant Panda Guerilla Dub Squad Country

    ...将只返回您想要的专辑。

    完整的高级搜索参考目前在 Spotify 重新设计的混乱中不可用,但您可以在 Wayback 机器 here 中找到它。

    【讨论】:

    • 完美,谢谢。最好在文档中提及高级搜索语法。
    猜你喜欢
    • 2013-04-18
    • 1970-01-01
    • 1970-01-01
    • 2016-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多