使用bash从共享链接下载iCloud文件
我想从iCloud下载文件。我可以共享指向文件的链接。但是,该文件未直接链接在URL中,但是可以检索“真实”下载URL:
#!/bin/bash
# given "https://www.icloud.com/iclouddrive/<ID>#<Filename>
ID="...."
URL=$(curl 'https://ckdatabasews.icloud.com/database/1/com.apple.cloudkit/production/public/records/resolve' \
--data-raw '{"shortGUIDs":[{"value":"$ID"}]}' --compressed \
jq -r '.results[0].rootRecord.fields.fileContent.value.downloadURL')
curl "$URL" -o myfile.ext
"fileContent" : {
"value" : {
...
"downloadURL" : "https://cvws.icloud-content.com/B/CYo..."
},
这是不起作用的:
rl: (6) Could not resolve host: jq
curl: (3) nested brace in URL position 17:
{
"results" : [ {
"shortGUID" : {
"value" : "$ID",
"shouldFetchRootRecord" : true
},
"reason" : "shortGUID cannot be null or empty",
"serverErrorCode" : "BAD_REQUEST"
} ]
}
有什么想法,我可以做什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通过安装JQ并直接添加ID而不是使用
$ ID
来解决它。只是安装JQ还不够。I solved it by installing jq and adding the ID directly instead of using
$id
. Just installing jq was not sufficient.正如@dan提到的,
jq
不是curl参数,它是单独的命令。因此,您需要|
将其输送而不是\
。因此该命令看起来像这样:
url = $(curl'https://ckdatabasews.icloud.com/database/1/com.apple.cloudkit/production/public/public/records/records/records/resolve'\ - -data -raw'{“ shortguids”:[{“ value”:“ $ id”}]}' - 压缩| JQ -R'.Results [0] .rootrecord.fields.fields.fileconts.filecontent.value.value.value.downloadurl')
as @dan mentioned,
jq
is not a curl argument, its a separate command. hence you would need to|
pipe it instead of\
.So the command would look something like this:
URL=$(curl 'https://ckdatabasews.icloud.com/database/1/com.apple.cloudkit/production/public/records/resolve' \ --data-raw '{"shortGUIDs":[{"value":"$ID"}]}' --compressed | jq -r '.results[0].rootRecord.fields.fileContent.value.downloadURL')