Fixed original_filename for older database versions

This commit is contained in:
Rhet Turnbull
2019-11-24 08:46:02 -08:00
parent 6abd10eddf
commit 8b4a386c13
3 changed files with 5 additions and 7 deletions

View File

@@ -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. Returns the universally unique identifier (uuid) of the photo. This is how Photos keeps track of individual photos within the database.
#### `filename()` #### `filename()`
Returns the filename of the photo on disk Returns the current filename of the photo on disk. See also `original_filename()`
#### `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()` #### `date()`
Returns the date of the photo as a datetime.datetime object Returns the date of the photo as a datetime.datetime object

View File

@@ -487,7 +487,7 @@ class PhotosDB:
+ "RKVersion.lastmodifieddate, RKVersion.imageDate, RKVersion.mainRating, " + "RKVersion.lastmodifieddate, RKVersion.imageDate, RKVersion.mainRating, "
+ "RKVersion.hasAdjustments, RKVersion.hasKeywords, RKVersion.imageTimeZoneOffsetSeconds, " + "RKVersion.hasAdjustments, RKVersion.hasKeywords, RKVersion.imageTimeZoneOffsetSeconds, "
+ "RKMaster.volumeId, RKMaster.imagePath, RKVersion.extendedDescription, RKVersion.name, " + "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 " + "from RKVersion, RKMaster where RKVersion.isInTrash = 0 and RKVersion.type = 2 and "
+ "RKVersion.masterUuid = RKMaster.uuid and RKVersion.filename not like '%.pdf'" + "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]["masterUuid"] = row[2]
self._dbphotos[uuid]["filename"] = row[3] 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: try:
self._dbphotos[uuid]["lastmodifieddate"] = datetime.fromtimestamp( self._dbphotos[uuid]["lastmodifieddate"] = datetime.fromtimestamp(
row[4] + td row[4] + td
@@ -525,6 +522,7 @@ class PhotosDB:
self._dbphotos[uuid]["extendedDescription"] = row[12] self._dbphotos[uuid]["extendedDescription"] = row[12]
self._dbphotos[uuid]["name"] = row[13] self._dbphotos[uuid]["name"] = row[13]
self._dbphotos[uuid]["isMissing"] = row[14] self._dbphotos[uuid]["isMissing"] = row[14]
self._dbphotos[uuid]["originalFilename"] = row[15]
conn.close() conn.close()

View File

@@ -38,7 +38,7 @@ with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
setup( setup(
name="osxphotos", name="osxphotos",
version="0.14.1", version="0.14.2",
description="Manipulate (read-only) Apple's Photos app library on Mac OS X", description="Manipulate (read-only) Apple's Photos app library on Mac OS X",
long_description=long_description, long_description=long_description,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",