【发布时间】: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 次单独的请求,然后才能找到它。
有没有更好的办法?
【问题讨论】: