From 8b4a386c13e7633d6a0eb49332d5423d56702b01 Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Sun, 24 Nov 2019 08:46:02 -0800 Subject: [PATCH] Fixed original_filename for older database versions --- README.md | 4 ++-- osxphotos/__init__.py | 6 ++---- setup.py | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4f3dc48c..f880455d 100644 --- a/README.md +++ b/README.md @@ -287,10 +287,10 @@ PhotosDB.photos() returns a list of PhotoInfo objects. Each PhotoInfo object re Returns the universally unique identifier (uuid) of the photo. This is how Photos keeps track of individual photos within the database. #### `filename()` -Returns the filename of the photo on disk +Returns the current filename of the photo on disk. See also `original_filename()` #### `original_filename()` -Returns the original filename of the photo when it was imported to Photos. Photos 5.0+ renames the photo when it adds the file to the library using UUID. For Photos 4.0 and below, filename() == original_filename() +Returns the original filename of the photo when it was imported to Photos. Note: Photos 5.0+ renames the photo when it adds the file to the library using UUID. See also `filename()` #### `date()` Returns the date of the photo as a datetime.datetime object diff --git a/osxphotos/__init__.py b/osxphotos/__init__.py index 1cc527be..7a999cee 100644 --- a/osxphotos/__init__.py +++ b/osxphotos/__init__.py @@ -487,7 +487,7 @@ class PhotosDB: + "RKVersion.lastmodifieddate, RKVersion.imageDate, RKVersion.mainRating, " + "RKVersion.hasAdjustments, RKVersion.hasKeywords, RKVersion.imageTimeZoneOffsetSeconds, " + "RKMaster.volumeId, RKMaster.imagePath, RKVersion.extendedDescription, RKVersion.name, " - + "RKMaster.isMissing " + + "RKMaster.isMissing, RKMaster.originalFileName " + "from RKVersion, RKMaster where RKVersion.isInTrash = 0 and RKVersion.type = 2 and " + "RKVersion.masterUuid = RKMaster.uuid and RKVersion.filename not like '%.pdf'" ) @@ -501,9 +501,6 @@ class PhotosDB: self._dbphotos[uuid]["masterUuid"] = row[2] self._dbphotos[uuid]["filename"] = row[3] - # TODO: Photos 5 has filename and originalFilename, is there equiv for older database formats? - self._dbphotos[uuid]["originalFilename"] = row[3] - try: self._dbphotos[uuid]["lastmodifieddate"] = datetime.fromtimestamp( row[4] + td @@ -525,6 +522,7 @@ class PhotosDB: self._dbphotos[uuid]["extendedDescription"] = row[12] self._dbphotos[uuid]["name"] = row[13] self._dbphotos[uuid]["isMissing"] = row[14] + self._dbphotos[uuid]["originalFilename"] = row[15] conn.close() diff --git a/setup.py b/setup.py index 4299394e..fd4e1987 100755 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ with open(path.join(this_directory, "README.md"), encoding="utf-8") as f: setup( name="osxphotos", - version="0.14.1", + version="0.14.2", description="Manipulate (read-only) Apple's Photos app library on Mac OS X", long_description=long_description, long_description_content_type="text/markdown",