Skip to content

Instantly share code, notes, and snippets.

@jmoreno
Created July 21, 2016 20:56
Show Gist options
  • Select an option

  • Save jmoreno/ef7d65ed57a0245a76ed2300136b9068 to your computer and use it in GitHub Desktop.

Select an option

Save jmoreno/ef7d65ed57a0245a76ed2300136b9068 to your computer and use it in GitHub Desktop.
smart_moments.py
import photos
import dialogs
all_moments = photos.get_moments()
titles = set()
for moment in all_moments:
if moment.title:
titles.add(moment.title)
sorted_titles = list(titles)
sorted_titles.sort()
items_datasource = []
for title in sorted_titles:
items_datasource.append({'title' : title})
selected_moments = dialogs.list_dialog(title="Moments", items=items_datasource, multiple=True)
if selected_moments:
album_title = dialogs.input_alert("Album Title", "", selected_moments[0]['title'])
if album_title:
new_album = photos.create_album(album_title)
for selected_moment in selected_moments:
for moment in all_moments:
if moment.title == selected_moment['title']:
new_album.add_assets(moment.assets)
dialogs.hud_alert("Album created", "success")
else:
dialogs.hud_alert("Album canceled", "error")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment