#!/bin/bash | |
# requires jq | |
# arg 1: iCloud web album URL | |
# arg 2: folder to download into (optional) | |
function curl_post_json { | |
curl -sH "Content-Type: application/json" -X POST -d "@-" "$@" | |
} | |
BASE_API_URL="https://p23-sharedstreams.icloud.com/$(echo $1 | cut -d# -f2)/sharedstreams" | |
pushd $2 > /dev/null | |
STREAM=$(echo '{"streamCtag":null}' | curl_post_json "$BASE_API_URL/webstream") | |
CHECKSUMS=$(echo $STREAM | jq -r '.photos[] | [(.derivatives[] | {size: .fileSize | tonumber, value: .checksum})] | max_by(.size | tonumber).value') | |
echo $STREAM \ | |
| jq -c "{photoGuids: [.photos[].photoGuid]}" \ | |
| curl_post_json "$BASE_API_URL/webasseturls" \ | |
| jq -r '.items[] | "https://" + .url_location + .url_path' \ | |
| while read URL; do | |
for CHECKSUM in $CHECKSUMS; do | |
if echo $URL | grep $CHECKSUM > /dev/null; then | |
curl -sOJ $URL & | |
break | |
fi | |
done | |
done | |
popd > /dev/null | |
wait |
This comment has been minimized.
This comment has been minimized.
When running in Terminal OSX I get following errors |
This comment has been minimized.
This comment has been minimized.
No longer seems to work. :-/ You probably need to replace "p23" by "p43", but even then the call to "webasserturls" doesn't work. |
This comment has been minimized.
This comment has been minimized.
I make few changes.
Works for me. Lets try
|
This comment has been minimized.
This comment has been minimized.
Where do you put the URL? |
This comment has been minimized.
This comment has been minimized.
Last version working for me thanks ! @jeffuu in terminal, you have to enter : |
This comment has been minimized.
This comment has been minimized.
Thank you very much, working for me ! |
This comment has been minimized.
This comment has been minimized.
This is really cool. Do you know if there is a way to get the comments? |
This comment has been minimized.
This comment has been minimized.
Do you know what's was wrong here? |
This comment has been minimized.
This comment has been minimized.
Hi @gwu888 |
This comment has been minimized.
This comment has been minimized.
some of the error occur because jq is missing.
|
This comment has been minimized.
This didn't work for me for an album that had >300 items. I came across other similar script written in python (https://github.com/VMannello/iCloud-PS-Download/blob/master/iCloudBD.py) that was doing batches of 20 items requests to
/webassetsurls
endpoint. That seemed to do the trick.That said I don't really know how I would implement batching with
jq
so just leaving a comment here in case someone faces this issue and wonders wtf.