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.
List of photo albums with properties
-
I have been playing around with the objc_util module in order to retrieve information about the various photo albums that are defined in the Photos app. These include user albums and smart albums. Properties I'd like to know about these albums are the localized name, the type (shared, smart, regular) and things like the number of photos and videos and the earliest and latest dates of items in an album. The link below shows a module with my results so far:
https://gist.github.com/44f6a49ac858a0cb0917c3dbb79e1c79
Basically all the functionality I mentioned is present and can be used by calling the appropriate functions. The only funky thing I encountered was the fact the the localizedTitle property of a smart album only returns the English version of the album title, not the Dutch one (which I'm interested in): hence the presence of the two functions with __localized in their name, in which I determine the Dutch name of the smart albums. I don't like this setup (not very flexible for other languages than Dutch), but for the moment this is what I came up with.
Next step of course is getting the photos in the albums, but first things first. Besides, I've seen some examples of this, so those will come in handy :-)
I've relatively new to Python, so comments / improvements are very welcome. Thanks!
-
Yesterday's update to the Pythonista 3 beta includes an updated
photos
module, which now allows access to things like albums. If you're interested in that, you can sign up for the beta (I think the signup form is a pinned thread in the forum). If it matters, the docs say that album names are "potentially localized", so internally it probably uses the same APIs as your module. -
@dgelessus Hi, cool that this functionality will be available in Pythonista 3. I haven't signed up for the beta (yet), I'm still very busy with the current version and everything that's possible with it. I don't know whether Pythonista 2 will be updated with iOS modules with extended functionality, but in any case I'm learning a lot by trying to get this Photos functionality to work. Great fun :-)
Interesting that you mention that the docs for the beta say that album names are potentially localized: apparently there really is something funny going on in Apple's Photos API then.
-
Unless I'm mistaken, Pythonista 2 will not be developed much further - Pythonista 3 (despite the name) supports both Python 2 and 3, and at the moment (in the two beta versions) most improvements and features are added to Pythonista 3 only.
-
Yes, the new/improved
photos
module in the Pythonista 3 beta uses the same APIs as your script.Regarding the localization of album names, I assume that you always get English names because Pythonista itself is only available in English, and the APIs return values for the current app. I can't think of a good way to get localized titles in an arbitrary language, unfortunately.
-
@omz In Swift I also didn't find a way to get the correct localization of album names, not in Xcode but also not on a device. The latter has always surprised me, because you would expect to get the correct locale there. Sometimes an API has a will of its own, it appears. I'm really looking forward to Pythonista 3, by the way.