使用bash从共享链接下载iCloud文件

发布于 2025-01-23 21:43:03 字数 1123 浏览 3 评论 0 原文

我想从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

sorce:

        "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"
  } ]
}

有什么想法,我可以做什么?

I want to download a file from iCloud. I can share a link to a file. However the file is not directly linked in the urls, but the "real" download url can be retrieved:

#!/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

Sorce: https://gist.github.com/jpillora/702ded79330043e38e8202b5c73835e5

        "fileContent" : {
          "value" : {
...
            "downloadURL" : "https://cvws.icloud-content.com/B/CYo..."
          },

This is, however not working:

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"
  } ]
}

Any ideas, what I can do to make this work?

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

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

发布评论

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

评论(2

酷遇一生 2025-01-30 21:43:03

我通过安装JQ并直接添加ID而不是使用 $ ID 来解决它。只是安装JQ还不够。

brew install jq


#!/bin/bash
# given "https://www.icloud.com/iclouddrive/<ID>#<Filename>

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')
Echo $url
curl "$URL" -o myfile.ext

I solved it by installing jq and adding the ID directly instead of using $id. Just installing jq was not sufficient.

brew install jq


#!/bin/bash
# given "https://www.icloud.com/iclouddrive/<ID>#<Filename>

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')
Echo $url
curl "$URL" -o myfile.ext
缘字诀 2025-01-30 21:43:03

正如@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')

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