我正在帮助那些需要从他们的soundcloud帐户中提取元数据的人(跟踪标题,说明,发布日期,大小,持续时间,媒体网址等)。不幸的是,它们有超过1500多首曲目,所以仅使用rss feed是不够的,它只限于200或250首曲目。
soundcloud不再为其API提供客户端ID。我在github项目中找到了一个客户端ID。然后使用在此https://github.com/soundcloud/soundcloud-python找到的soundcloud python包装器,我尝试使用此跟踪元数据
import soundcloud
client = soundcloud.Client(client_id=CLIENT_ID_REDACTED)
tracks = client.get('/users/9999999/tracks/', limit=5000)
print(len(tracks))
唉,它只会返回最多200首曲目,所以这没有帮助。
如果我在帐户中注册了实际的客户ID,是否存在此200个跟踪限制?获取这些数据有什么希望吗?
提前致谢
答案 0 :(得分:1)
在初始请求中添加?linked_partitioning = 1,响应将包含一个名为next_href的属性,该属性为您提供下一页结果的URL。
答案 1 :(得分:0)
linked_partitioning是关键。感谢@nickf
顺便说一句,soundcloud API文档错误或引用旧API
import soundcloud
client = soundcloud.Client(client_id='clientidhere')
page_size = 200
# get first page of tracks
tracks = client.get('/users/999999/tracks', limit=page_size,
linked_partitioning=1)
c = 1
for track in tracks.collection:
print(c,track.title)
c += 1
# .next_href exists means there are more pages
while hasattr(tracks, 'next_href'):
# pass .next_href to get next page
tracks = client.get(tracks.next_href, limit=page_size,
linked_partitioning=1)
for track in tracks.collection:
print(c,track.title)
c += 1