Created
March 15, 2020 17:10
-
-
Save javiribera/3c1cbb0f2831d42d83bb2473188e3fac to your computer and use it in GitHub Desktop.
Download entire iCloud shared albums icloud-album-download.sh
This file contains hidden or 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) | |
# | |
# Credits: https://gist.github.com/zneak/8f719cd81967e0eb2234897491e051ec | |
# icloud-album-download.sh | |
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") | |
HOST=$(echo $STREAM | jq '.["X-Apple-MMe-Host"]' | cut -c 2- | rev | cut -c 2- | rev) | |
if [ "$HOST" ]; then | |
BASE_API_URL="https://$(echo $HOST)/$(echo $1 | cut -d# -f2)/sharedstreams" | |
STREAM=$(echo '{"streamCtag":null}' | curl_post_json "$BASE_API_URL/webstream") | |
fi | |
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 | to_entries[] | "https://" + .value.url_location + .value.url_path + "&" + .key' \ | |
| 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 |
Quickly wrote a new Powershell script to download iCloud shared album (photos + videos):
https://gist.github.com/GodSaveEarth/9ba8d574d0f5ab789aebdfdb2db59b8df
Works like charm, even 5 years later! Thank you so much!
I know I'm more than 2 years late @SDK665 but in case someone else needs this:
Download the bash file, then open a terminal and navigate to the folder where the script is. First argument is the iCloud Shared Album URL, second argument is the output folder where pictures will be downloaded to. Make sure your output folder exists. So in the terminal type:
cd ~/Downloads
mkdir downloaded_pictures
sh download-icloud-sharedalbum.sh https://www.icloud.com/sharedalbum/#YOUR-FOLDER_ID ~/Downloads/downloaded_pictures
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
I cam across this while trying to find a way to download a shared icloud album.
I have the link to the album but is looking for a method / tool to paste the link in and it download the entire album to my local computer.
This seems to do the job but I don't know how to use this.
Can someone show me please...or point me to where I can learn to use this.
Thank you.