Last active
March 10, 2025 13:39
-
-
Save fay59/8f719cd81967e0eb2234897491e051ec to your computer and use it in GitHub Desktop.
Download entire iCloud shared albums
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Quickly wrote a new Powershell script to download iCloud shared album (photos + videos):
https://gist.github.com/GodSaveEarth/9b8d574d0f5ab789aebdfdb2db59b8df