Created
July 21, 2016 20:56
-
-
Save jmoreno/ef7d65ed57a0245a76ed2300136b9068 to your computer and use it in GitHub Desktop.
smart_moments.py
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
| 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