Skip to content

Instantly share code, notes, and snippets.

@thzinc
Last active May 10, 2024 05:45
Show Gist options
  • Save thzinc/5709f19e6db1a874b908beab01aef782 to your computer and use it in GitHub Desktop.
Save thzinc/5709f19e6db1a874b908beab01aef782 to your computer and use it in GitHub Desktop.
Download all iCloud Photos

Download all iCloud Photos from your account

Thanks to the super-useful PyiCloud module by @picklepete, this script is a way to download all of your photos from iCloud Photos.

On OS X (macOS?), use the icloud utility to save your iCloud password to your keyring. (This keeps it out of the script.) Update the script with your Apple ID email address and run it to download your photos to the current directory.

from pyicloud import PyiCloudService
import os
api = PyiCloudService('your.email.address@example.com')
for photo in api.photos.all:
filename, ext = os.path.splitext(photo.filename)
output_filename = str.format("{0}-{1}{2}", filename, photo.client_id, ext)
if os.path.isfile(output_filename):
print "File " + output_filename + " already exists"
continue
print "Writing file to " + output_filename
download = photo.download('original');
with open(output_filename, 'wb') as opened_file:
opened_file.write(download.raw.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment