Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Photos module - album start date / end date
-
The updated photos-module in the new Pythonista versions is great, but I wonder about the start and end date you can now retrieve for an album (regular, smart, moments). I notice that I only get valid dates back for moments, not for regular albums or smart albums: in the latter two cases the return value is None. Is this by design (I know Apple's API works the same way) or is this a small glitch in Pythonista's implementation?
-
As far as I understand Apple's API, that's by design.
-
Just looked up Apple's documentation again, and it says about
startDate
(equivalent tostart_date
in Pythonista):This property applies only to asset collections whose type is PHAssetCollectionTypeMoment. For other asset collection types, this property’s value is nil.
-
@omz Thanks for your answer, good to know. Using the assets list of a regular or smart album in combination with the creation_date of an asset it's easy to get the start date and end date of any album: for moments there's also the other alternative.
-
So this is what I'm using to get the start date and end date of any album, works great and takes advantage of the fact that the assets list is ordered in ascending order by date:
def get_album_dates(album:photos.AssetCollection) -> (datetime.datetime, datetime.datetime): assets = album.assets if len(assets) == 0: return (None, None) else: return (assets[0].creation_date, assets[-1].creation_date)