Skip to content

Instantly share code, notes, and snippets.

@arthurhammer arthurhammer/indexphotos.py Secret
Last active Jan 4, 2019

Embed
What would you like to do?
Index iCloud Photo Library (Pythonista)
import json
import photos
import dialogs
# Run this from within Pythonista on iOS.
types = ["image", "video", "audio", "unknown"]
include_hidden = True
def get_assets(type):
assets = reversed(photos.get_assets(media_type=type, include_hidden=include_hidden))
return [{
"date": p.creation_date.isoformat(),
"type": p.media_type,
"subtypes": p.media_subtypes,
"favorite": p.favorite,
"hidden": p.hidden,
"duration": p.duration,
"width": p.pixel_width,
"height": p.pixel_height
} for p in assets]
result = []
for type in types:
result = result + get_assets(type)
result = sorted(result, key=lambda p: p["date"])
dialogs.share_text(json.dumps(result))
This file has been truncated, but you can view the full file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.