sta*_*ngo 3 python api spotify python-3.x python-requests
搜索是否已有答案:否
\n1. 总结问题
\nSpotify 引入了获取有关播客和节目信息的功能。详细信息请参见此处。
\n我正在使用 Python“requests”包生成请求 URL,以获取 no_of_followers 等指标(我不确定它们是否可用于播客),所以我尝试获取节目的元数据。
\n我用来获取有关节目信息的端点:GET https://api.spotify.com/v1/shows/{id}
headers = {\n "Authorization": f"Bearer {access_token}"\n}\n# endpoint used "https://api.spotify.com/v1/shows/{id}"\n\nlookup_url = "https://api.spotify.com/v1/shows/3IM0lmZxpFAY7CwMuv9H4g" #"The Daily" podcast example\nprint(lookup_url)\n\nr = requests.get(lookup_url, headers=headers)\nprint(r)\nprint(r.status_code)\nprint(r.json())\nRun Code Online (Sandbox Code Playgroud)\n但是我收到以下错误响应:
\nhttps://api.spotify.com/v1/shows/3IM0lmZxpFAY7CwMuv9H4g\n<Response [404]>\n404\n{\'error\': {\'status\': 404, \'message\': \'non existing id\'}}\nRun Code Online (Sandbox Code Playgroud)\n问题在最后
\n2. 描述您\xe2\x80\x99尝试过的内容
\n我尝试使用搜索端点提取类似的信息,在那里,我确实得到了有效的响应。搜索艺术家时信息丰富且符合预期,但我搜索的展览的响应数据似乎缺失。
\n我用来搜索演出/艺术家的端点:GET https://api.spotify.com/v1/search
使用搜索端点查找有关演出/艺术家的信息:
\nheaders = {\n "Authorization": f"Bearer {access_token}"\n}\nendpoint = "https://api.spotify.com/v1/search"\ndata = urlencode({"q":"the daily","type":"show"})\n# data = urlencode({"q":"drake","type":"artist"})\n\nlookup_url = f"{endpoint}?{data}"\nprint(lookup_url)\n\nr = requests.get(lookup_url, headers=headers)\nprint(r.status_code)\nr.json()\nRun Code Online (Sandbox Code Playgroud)\n获取上面显示的输出:
\nhttps://api.spotify.com/v1/search?q=the+daily&type=show\n200\n{\'shows\': {\'href\': \'https://api.spotify.com/v1/search?query=the+daily&type=show&offset=0&limit=20\',\n \'items\': [None,\n None,\n None,\n None,\n None,\n None,\n None,\n None,\n None,\n None,\n None,\n None,\n None,\n None,\n None,\n None,\n None,\n None,\n None,\n None],\n \'limit\': 20,\n \'next\': \'https://api.spotify.com/v1/search?query=the+daily&type=show&offset=20&limit=20\',\n \'offset\': 0,\n \'previous\': None,\n \'total\': 14755}}\nRun Code Online (Sandbox Code Playgroud)\n如果我尝试搜索艺术家的信息,我会得到很好的结果:
\n{\'artists\': {\'href\': \'https://api.spotify.com/v1/search?query=drake&type=artist&offset=0&limit=20\',\n \'items\': [{\'external_urls\': {\'spotify\': \'https://open.spotify.com/artist/3TVXtAsR1Inumwj472S9r4\'},\n \'followers\': {\'href\': None, \'total\': 48844145},\n \'genres\': [\'canadian hip hop\',\n \'canadian pop\',\n \'hip hop\',\n \'pop rap\',\n \'rap\',\n \'toronto rap\'],\n \'href\': \'https://api.spotify.com/v1/artists/3TVXtAsR1Inumwj472S9r4\',\n \'id\': \'3TVXtAsR1Inumwj472S9r4\',\n \'images\': [{\'height\': 640,\n \'url\': \'https://i.scdn.co/image/60cfab40c6bb160a1906be45276829d430058005\',\n \'width\': 640},\n {\'height\': 320,\n \'url\': \'https://i.scdn.co/image/5ea794cf832550943d5f8122afcf5f23ee9d85b7\',\n \'width\': 320},\n {\'height\': 160,\n \'url\': \'https://i.scdn.co/image/8eaace74aaca82eaccde400bbcab2653b9cf86e1\',\n \'width\': 160}],\n \'name\': \'Drake\',\n \'popularity\': 98,\n \'type\': \'artist\',\n \'uri\': \'spotify:artist:3TVXtAsR1Inumwj472S9r4\'},\n...output clipped for readability\nRun Code Online (Sandbox Code Playgroud)\n3.问题:
\n感谢您的帮助。
\nGet a Show端点似乎确实需要提供Market参数。在该参数的部分中,尽管标记为可选,但它指出:
如果指定了国家/地区代码,则仅返回该市场中可用的节目和剧集。如果请求标头中指定了有效的用户访问令牌,则与用户帐户关联的国家/地区将优先于该参数。注意:如果未提供市场或用户国家/地区,则认为该内容对客户端不可用。
我还遇到了播客节目和剧集的问题,也假设与其他内容一样,当不提供市场参数时,您仍然会得到一些东西,直到我注意到以下内容意味着如果没有它,您将一无所获,这就是您遇到的问题经历、
如果未提供市场或用户国家/地区,则认为该内容对客户端不可用。
该文档确实应该说明,在这种情况下,与歌曲等不同,市场价值不是可选的,可能值得在Spotify 开发者论坛上提出问题
| 归档时间: |
|
| 查看次数: |
4976 次 |
| 最近记录: |