Spotify Apps API:库类不会返回用户播放列表

发布于 2024-12-22 19:16:56 字数 387 浏览 4 评论 0原文

我试图获取一个包含用户库中所有播放列表的数组(http://developer.spotify.com/download/spotify-apps-api/reference/dcdebc652c.html)。

其他类属性(专辑、艺术家、starredPlaylist、曲目)没有问题,但不知何故,“播放列表”属性无法使用,

var allPlaylists = models.library.playlists;

var allArtists= models.library.artists;

工作得很好!(两者都使用 document.write(var) )

有什么建议吗?谢谢你!

I'm trying to get an array containing all Playlists in the users Library (http://developer.spotify.com/download/spotify-apps-api/reference/dcdebc652c.html).

No problems with the other class properties (albums, artists, starredPlaylist, tracks), but somehow the "Playlists" property won't work using

var allPlaylists = models.library.playlists;

whereas

var allArtists= models.library.artists;

works just fine!( Both using document.write(var) )

Any suggestions? thank you!

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

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

发布评论

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

评论(3

━╋う一瞬間旳綻放 2024-12-29 19:16:57

官方答案如下:

不幸的是,出于隐私原因,在 Spotify Apps API 中获取用户播放列表的功能已被删除。这是在最后一刻完成的,并且文档没有及时更新。我们将很快发布反映此更改的新版本客户端和文档。

Here's the official answer:

Unfortunately, the ability to get the user's playlists in the Spotify Apps API has been removed for privacy reasons. This was done very last-minute, and the documentation wasn't updated in time. We'll be releasing a new build of the client and documentation that reflects this change soon.

眼眸 2024-12-29 19:16:57

我看起来 sp.core.library.getPlaylists 在 中被禁用。
0.8.0–701-gc2d793a

I looks like sp.core.library.getPlaylists got disabled in .
0.8.0–701-gc2d793a

断肠人 2024-12-29 19:16:57

我认为这是 API 的一个错误。

sp = getSpotifyAPI(1);
models = sp.require('sp://import/scripts/api/models')
models.library.playlists;

> TypeError: Cannot read property 'length' of undefined

try { models.library.playlists } catch(err) { console.log(err.stack) }

> TypeError: Cannot read property 'length' of undefined
    at map (sp:216:20)
    at Library.<anonymous> (eval at evalModule (sp:55:46))
    at unknown source
    at Object._evaluateOn (unknown source)
    at Object._evaluateAndWrap (unknown source)
    at Object.evaluate (unknown source)

深入 models.js 文件,我们看到 Library 使用 sp.core.library.getPlaylists() 来获取播放列表,它应该返回一个数组,但返回未定义:

sp.core.library.getPlaylists()

> undefined

sp.core.library.getPlaylists

> function getPlaylists() { [native code] }

由于 sp.core.library.getPlaylists 是本机代码,我无法深入兔子洞看看它在做什么。因此,除非 Spotify 开发人员说这是期望的行为,否则我的结论是这是一个错误。

I'm thinking it's a bug with the API.

sp = getSpotifyAPI(1);
models = sp.require('sp://import/scripts/api/models')
models.library.playlists;

> TypeError: Cannot read property 'length' of undefined

try { models.library.playlists } catch(err) { console.log(err.stack) }

> TypeError: Cannot read property 'length' of undefined
    at map (sp:216:20)
    at Library.<anonymous> (eval at evalModule (sp:55:46))
    at unknown source
    at Object._evaluateOn (unknown source)
    at Object._evaluateAndWrap (unknown source)
    at Object.evaluate (unknown source)

Digging in the models.js file we see that Library uses sp.core.library.getPlaylists() to get the playlists, which should return an Array but returns undefined:

sp.core.library.getPlaylists()

> undefined

sp.core.library.getPlaylists

> function getPlaylists() { [native code] }

Since sp.core.library.getPlaylists is native code I am unable to go deeper down the rabbit hole to see what it is doing. So unless the spotify devs say it is the desired behaviour my conclusion is that it is a bug.

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