Skip to content

Commit

Permalink
Look for and use OriginalPath if exists - sometimes ImagePath wasn't …
Browse files Browse the repository at this point in the history
…found.
  • Loading branch information
kathryn committed May 7, 2013
1 parent 81457ba commit 7e0e387
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions exportiphoto.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(self, albumDir, destDir, use_album=False, use_date=False,
major_version = 2
minor_version = 0
interesting_image_keys = [
'ImagePath', 'Rating', 'Keywords', 'Caption', 'Comment', 'Faces',
'OriginalPath', 'ImagePath', 'Rating', 'Keywords', 'Caption', 'Comment', 'Faces',
'face key'
]
apple_epoch = 978307200
Expand Down Expand Up @@ -342,7 +342,10 @@ def copyImage(self, imageId, folderName, folderDate):
"Can't create %s: %s" % (folderName, why[1])
self.status(" Created %s\n" % folderName)

mFilePath = image["ImagePath"]
if "OriginalPath" in image:
mFilePath = image["OriginalPath"]
else:
mFilePath = image["ImagePath"]
basename = os.path.basename(mFilePath)

# Deconflict ouput filenames
Expand Down Expand Up @@ -388,8 +391,13 @@ def writePhotoMD(self, imageId, filePath=None):
image = self.images[imageId]
except KeyError:
raise iPhotoLibraryError, "Can't find image #%s" % imageId

if not filePath:
filePath = image['ImagePath']
if "OriginalPath" in image:
filePath = image["OriginalPath"]
else:
filePath = image["ImagePath"]


caption = image.get("Caption", None)
rating = image.get("Rating", None)
Expand Down

0 comments on commit 7e0e387

Please sign in to comment.