Spotify搜索API随机时间抛出404个错误

发布于 2025-02-13 17:57:26 字数 1064 浏览 1 评论 0原文

这种行为对我来说感觉很不错...

我正在使用Spotify API搜索艺术家,如果Spotify找不到我正在搜索的内容,我的代码正在抛出404错误...但是这感觉很不错。我。搜索端点的全部要点应该是请参见如果Spotify具有资源,如果没有资源,则可以将我返回一个空列表。通常,如果我的搜索没有结果,他们 do 如果我的搜索没有结果。但是在过去的几周中,有时会出现错误例外。

这是一个例子。

# Just assume this is a spotipy instance that works
spotify = initSpotifyClient()

# The name is a bit strange, but nonetheless, this works correctly
name = 'Blak Twang And Breis And Cons And Creed And Donovan Kingjay And Hill St Soul And Karl Hinds And Navi'
results = spotify.search(name, limit=20, type='artist')

在此示例中,一切都按预期工作。但是,如果我只能在我要搜索的名称的开头添加“ the”,那么Spotipy客户端将抛出404个例外。

例如:

# Just assume this is a spotipy instance that works
spotify = initSpotifyClient()

# The only difference is that the name now starts with "The "
name = 'The Blak Twang And Breis And Cons And Creed And Donovan Kingjay And Hill St Soul And Karl Hinds And Navi'
results = spotify.search(name, limit=20, type='artist') # THIS THROWS AN ERROR

这不应该只是返回一个空列表而不是抛出404例外吗?这对我来说很奇怪。

This behavior feels very wrong to me...

I'm using the spotify api to search for artists and my code is throwing a 404 error if spotify can't find what I'm searching for... but this feels very wrong to me. The whole point of a search endpoint should be to see if spotify has the resource, and if they don't, they can just return me an empty list. And often, they do return me an empty list if my search has no results. But in the past couple weeks, it will sometimes throw an error exception.

Here's an example.

# Just assume this is a spotipy instance that works
spotify = initSpotifyClient()

# The name is a bit strange, but nonetheless, this works correctly
name = 'Blak Twang And Breis And Cons And Creed And Donovan Kingjay And Hill St Soul And Karl Hinds And Navi'
results = spotify.search(name, limit=20, type='artist')

In this example, everything works as expected. However, if I do nothing more than add "The " at the beginning of the name that I'm searching then the spotipy client will throw a 404 exception.

For example:

# Just assume this is a spotipy instance that works
spotify = initSpotifyClient()

# The only difference is that the name now starts with "The "
name = 'The Blak Twang And Breis And Cons And Creed And Donovan Kingjay And Hill St Soul And Karl Hinds And Navi'
results = spotify.search(name, limit=20, type='artist') # THIS THROWS AN ERROR

Shouldn't this just return an empty list rather than throwing a 404 exception? This feels very strange to me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光暖心i 2025-02-20 17:57:27

可以,对于任何找到此问题的人,搜索端点的字符限制为100个字符。如果您有更多的东西,端点将引发异常。

Ok for anyone who found this, the search endpoint has a character limit of 100 characters. If you have any more than that, the endpoint will throw an exception.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文