Soundcloud API无法通过Python返回播放列表中的所有曲目

2024-09-30 16:23:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我最近开始使用Soundcloud API开发一个简单的应用程序,可以将数据保存在播放列表中。然而,在我看来,并不是所有播放列表中的曲目都会被返回。在

我正在使用以下代码:

import soundcloud, shelve, time

client = soundcloud.Client(client_id=CLIENT_ID,
                           client_secret=CLIENT_SECRET,
                           username=E-MAIL,
                           password=PASSWORD)

playlists = client.get('/users/24196709/playlists', limit=1)

tracknames = []
trackids= []

for pl in playlists:
    for track in pl.tracks:
        print(track['title'])
        tracknames.append(track['title'])
        trackids.append(track['id'])

print(tracknames)

在包含13首曲目的播放列表:https://soundcloud.com/michiel-tammeling/sets/icecubes上使用它,但是代码只返回11首。在

任何帮助都将不胜感激。在


Tags: 代码inclientidfortitletrack播放列表
1条回答
网友
1楼 · 发布于 2024-09-30 16:23:43

不幸的是,这无法解决。关于这个问题的话题已经很多了。问题是playlistapi返回播放列表中的所有曲目,而tracks API只返回不受保护的曲目。既然你已经知道哪两个音轨丢失了,我验证了这一点,当你尝试使用track API时,它们都返回了403。所以这两个音轨在某种程度上是无法使用track API访问的。在

更多背景:

SoundCloud Playlist tracks is empty

SoundCloud emailed back saying they have introduced an option for right holders to disable all API access to tracks by default, returning this 403 error when requested. They also said it's understandable that this is a confusing feature, and that they hope to make it more clear.

@nickf the tech lead of soundcloud says:

Yep there's many reasons that a track might not show up to you. It could be taken down by the rightsholder of the track, made private or deleted by the uploader, or (and this is the tricky one) blocked in certain territories. Calculating the policies of all of the tracks of a user every time it is fetched isn't quite feasible, so sometimes this number will be inaccurate (depending on who is asking and where they are). – nickf Apr 14 at 22:37

相关问题 更多 >