omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    2
    5
    3373
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ?
      A Former User last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        As far as I understand Apple's API, that's by design.

        1 Reply Last reply Reply Quote 0
        • omz
          omz last edited by

          Just looked up Apple's documentation again, and it says about startDate (equivalent to start_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.

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User last edited by A Former User

            @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.

            1 Reply Last reply Reply Quote 0
            • ?
              A Former User last edited by A Former User

              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)
              
              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB Forums | Contributors