我使用以下python代码生成了一个Soundcloud轨道ID列表:
import soundcloud
import urllib
client = soundcloud.Client(client_id='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
client_secret='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
username='XXXXXXXXXXXXXXXXXXXXXXXXXX',
password='XXXXXXXXXXXXXXXXXX')
f=open('soundcloud-track-ids', 'w+')
count = 0
while count < 6000:
tracks = client.get('/me/tracks', limit=200, offset=count)
for track in tracks:
print >>f, track.id, "\t", track.title .encode('utf-8')
count += 200
f.close()
然后我运行了一个bash脚本来将整个存档备份到硬盘驱动器的内容:
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
while read line; do
if [ ! -f /mnt/drobo_1/Soundcloud/$(echo $line | cut -f 2- | sed 's,/,\ ,g').mp3 ]; then
wget https://api.soundcloud.com/tracks/"$(echo $line | awk '{print $1}')"/download?oauth_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
-O /mnt/drobo_1/Soundcloud/"$(echo $line | cut -f 2- | sed 's,/,\ ,g').mp3"
fi
done < ./soundcloud-track-ids
IFS=$SAVEIFS
几乎所有的5317首曲目都是私密的,而且大多数都是没有问题的下载,但是大约有600首曲目无法下载,并出现以下错误:
--2015-01-05 12:46:09-- https://api.soundcloud.com/tracks/152288957/download?oauth_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Resolving api.soundcloud.com (api.soundcloud.com)... 93.184.220.127
Connecting to api.soundcloud.com (api.soundcloud.com)|93.184.220.127|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2015-01-05 12:46:10 ERROR 404: Not Found.
有谁知道错误是什么?
答案 0 :(得分:1)
404错误表示在SoundCloud结束时无法找到该文件。它可能是SoundCloud的速率限制器,可以防止你如此抨击它。
请参阅https://developers.soundcloud.com/docs/api/terms-of-use#quotas
如果您稍后尝试下载失败,那么它们有效吗?