Updated examples [skip ci]
This commit is contained in:
@@ -19,20 +19,20 @@ def main():
|
|||||||
"""Find all photos with EXIF or XMP rating of 5 and mark them as favorites"""
|
"""Find all photos with EXIF or XMP rating of 5 and mark them as favorites"""
|
||||||
photosdb = osxphotos.PhotosDB()
|
photosdb = osxphotos.PhotosDB()
|
||||||
for photo in photosdb.photos():
|
for photo in photosdb.photos():
|
||||||
# extracting the rating data takes a while so
|
# extracting the rating data takes a while so
|
||||||
# skip photos not taken with the camera we're looking for
|
# skip photos not taken with the camera we're looking for
|
||||||
if photo.exif_info.camera_make != CAMERA_MAKE:
|
if photo.exif_info.camera_make != CAMERA_MAKE:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Photos stores some data in photo.exif but the rating data must be extracted with exiftool
|
# Photos stores some data in photo.exif but the rating data must be extracted with exiftool
|
||||||
exif = photo.exiftool.asdict()
|
if exif := photo.exiftool:
|
||||||
# I think SONY uses XMP:Rating but also check EXIF:Rating
|
# I think SONY uses XMP:Rating but also check EXIF:Rating
|
||||||
xmp_rating = exif.get("XMP:Rating", 0)
|
xmp_rating = exif.get("XMP:Rating", 0)
|
||||||
exif_rating = exif.get("EXIF:Rating", 0)
|
exif_rating = exif.get("EXIF:Rating", 0)
|
||||||
rating = max(xmp_rating, exif_rating)
|
rating = max(xmp_rating, exif_rating)
|
||||||
if rating == 5:
|
if rating == 5:
|
||||||
print(f"Marking {photo.original_filename} ({photo.uuid}) as favorite")
|
print(f"Marking {photo.original_filename} ({photo.uuid}) as favorite")
|
||||||
photoscript.Photo(photo.uuid).favorite = True
|
photoscript.Photo(photo.uuid).favorite = True
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user