Spotify API在尝试获取播客信息时返回404未找到



如果答案已经可用,则搜索:无

1.总结问题

Spotify引入了获取播客和节目信息的功能。详细信息请点击此处。

我正在使用Python";请求";包来生成请求URL,以获取no_of_followers等指标(我不确定它们是否可用于播客(,所以我尝试获取节目的元数据。

我用来获取演出信息的端点:GET https://api.spotify.com/v1/shows/{id}

headers = {
"Authorization": f"Bearer {access_token}"
}
# endpoint used "https://api.spotify.com/v1/shows/{id}"
lookup_url = "https://api.spotify.com/v1/shows/3IM0lmZxpFAY7CwMuv9H4g" #"The Daily" podcast example
print(lookup_url)
r = requests.get(lookup_url, headers=headers)
print(r)
print(r.status_code)
print(r.json())

然而,我收到以下错误响应:

https://api.spotify.com/v1/shows/3IM0lmZxpFAY7CwMuv9H4g
<Response [404]>
404
{'error': {'status': 404, 'message': 'non existing id'}}

最后的问题

2.描述您尝试了什么

我尝试使用搜索端点提取类似的信息,在那里,我确实得到了有效的响应。在搜索艺术家时,信息丰富,不出所料,但我搜索的节目似乎缺少响应数据。

我用来搜索展览/艺术家的端点:GET https://api.spotify.com/v1/search

使用搜索端点查找有关演出/艺术家的信息:

headers = {
"Authorization": f"Bearer {access_token}"
}
endpoint = "https://api.spotify.com/v1/search"
data = urlencode({"q":"the daily","type":"show"})
# data = urlencode({"q":"drake","type":"artist"})
lookup_url = f"{endpoint}?{data}"
print(lookup_url)
r = requests.get(lookup_url, headers=headers)
print(r.status_code)
r.json()

获取上面显示的输出为:

https://api.spotify.com/v1/search?q=the+daily&type=show
200
{'shows': {'href': 'https://api.spotify.com/v1/search?query=the+daily&type=show&offset=0&limit=20',
'items': [None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None],
'limit': 20,
'next': 'https://api.spotify.com/v1/search?query=the+daily&type=show&offset=20&limit=20',
'offset': 0,
'previous': None,
'total': 14755}}

如果我试图搜索艺术家的信息,我会得到很好的结果:

{'artists': {'href': 'https://api.spotify.com/v1/search?query=drake&type=artist&offset=0&limit=20',
'items': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/3TVXtAsR1Inumwj472S9r4'},
'followers': {'href': None, 'total': 48844145},
'genres': ['canadian hip hop',
'canadian pop',
'hip hop',
'pop rap',
'rap',
'toronto rap'],
'href': 'https://api.spotify.com/v1/artists/3TVXtAsR1Inumwj472S9r4',
'id': '3TVXtAsR1Inumwj472S9r4',
'images': [{'height': 640,
'url': 'https://i.scdn.co/image/60cfab40c6bb160a1906be45276829d430058005',
'width': 640},
{'height': 320,
'url': 'https://i.scdn.co/image/5ea794cf832550943d5f8122afcf5f23ee9d85b7',
'width': 320},
{'height': 160,
'url': 'https://i.scdn.co/image/8eaace74aaca82eaccde400bbcab2653b9cf86e1',
'width': 160}],
'name': 'Drake',
'popularity': 98,
'type': 'artist',
'uri': 'spotify:artist:3TVXtAsR1Inumwj472S9r4'},
...output clipped for readability

3.问题:

  1. 我是否试图错误地提取有关某个节目的信息?我试着使用下面提到的搜索端点——它似乎对艺术家或曲目很有效,但对节目却不适用
  2. 有可能获得一个节目的指标吗?比如关注者、播放时间和历史数据

感谢您的帮助。

Get-aShow端点似乎确实需要提供Market参数。在该参数的部分中,尽管标记为可选,但它指出:

如果指定了国家/地区代码,则只会退回该市场上可用的节目和剧集。如果在请求标头中指定了有效的用户访问令牌,则与用户帐户关联的国家/地区将优先于此参数。注:如果未提供市场或用户国家/地区,则视为客户端无法获得该内容。

我也遇到了播客节目剧集的问题,正如其他内容一样,当你不提供市场参数时,你仍然会得到一些东西,直到我注意到以下情况意味着没有它,你什么都得不到,这就是你正在经历的问题,

如果没有提供市场或用户国家/地区,则内容为被认为对客户端不可用。

文档应该真正说明,在这种情况下,与歌曲等不同,市场值不是可选的,可能值得在Spotify开发者论坛上提出一个问题

最新更新