Skip to content

Instantly share code, notes, and snippets.

@fay59
Last active March 10, 2025 13:39
Show Gist options
  • Save fay59/8f719cd81967e0eb2234897491e051ec to your computer and use it in GitHub Desktop.
Save fay59/8f719cd81967e0eb2234897491e051ec to your computer and use it in GitHub Desktop.
Download entire iCloud shared albums
#!/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
@andrewzung
Copy link

andrewzung commented May 1, 2024

Would someone be able to help me out... I've used this app in the past, but having issues today when trying to run it again. Using Windows 11 with Git installed (jq as well)

./icloud-album-download.sh: line 18: rev: command not found
./icloud-album-download.sh: line 18: rev: command not found
Grabbing Large File Checksums
jq: error (at :1): Cannot iterate over null (null)
Adding Checksums to Array
Total Downloads: 0
Unique Downloads: 0
Streaming All Assets
jq: error (at :1): Cannot iterate over null (null)

@Uj947nXmRqV2nRaWshKtHzTvckUUpD
Copy link

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented May 1, 2024

Would someone be able to help me out... I've used this app in the past, but having issues today when trying to run it again. Using Windows 11 with Git installed (jq as well)

./icloud-album-download.sh: line 18: rev: command not found
./icloud-album-download.sh: line 18: rev: command not found
Grabbing Large File Checksums
jq: error (at :1): Cannot iterate over null (null)
Adding Checksums to Array
Total Downloads: 0
Unique Downloads: 0
Streaming All Assets
jq: error (at :1): Cannot iterate over null (null)

i updated the comment above. apparently rev command is not recognized by git bash. Just use cygwin instead. It's pretty easy to setup. Download the setup from https://www.cygwin.com/.

@andrewzung
Copy link

Thanks.

For anyone else who's technologically challenged, I used cd /cygdrive/<the path to your file>, ie. cd /cygdrive/c/Users/<your_user>/Desktop to navigate to where the file is located

@Gr8z
Copy link

Gr8z commented May 13, 2024

Lifesaver! - I didn't want to download 500 images by hand.

@Stecnica
Copy link

Work perfectly on a MacOS;
installed jq with
brew install jq
then copied this script in an only-text document of TextEdit (command shift T to made a txt.only document and command shift w to made a full page view)
using cd and chmod to change executability from /Applications/Utility/Terminal.app
cd /path/in/the/folder/you/have/saved/the/script/from/textedit
chmod +x ./icloud-album-download.sh
then, in iPhoto copy the album link like https://www.icloud.com/sharedalbum/it-it/#NuMbErOfAlBuM

@intjonathan
Copy link

Uj947nXmRqV2nRaWshKtHzTvckUUpD yours worked perfectly - thank you!

@VSimpact
Copy link

VSimpact commented Sep 10, 2024

I'm new to this but I found my way around it after some time

I used powershell to install chocolatey and then jq
I saved the latest script on my desktop with Notepadd++ on Unix format as 'icloud-album-download.sh'
I installed cygwin
I ran the following lines:

cd c:/Users/'my user'/Desktop
chmod +x ./icloud-album-download.sh
./icloud-album-download.sh 'shared icloud album link'

Seems like everything runs without errors but nothing downloads, I get this on cygwin command window:

Getting iCloud Stream
Grabbing Large File Checksums
Adding Checksums to Array
Total Downloads: 0
Unique Downloads: 0
Streaming All Assets

@GodSaveEarth
Copy link

GodSaveEarth commented Nov 15, 2024

Quickly wrote a new Powershell script to download iCloud shared album (photos + videos):
https://gist.github.com/GodSaveEarth/9b8d574d0f5ab789aebdfdb2db59b8df

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment