Updated examples [skip ci]

This commit is contained in:
Rhet Turnbull 2022-06-12 21:56:46 -07:00
parent f47aa72165
commit 04c2f6121a

View File

@ -19,20 +19,20 @@ def main():
"""Find all photos with EXIF or XMP rating of 5 and mark them as favorites"""
photosdb = osxphotos.PhotosDB()
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
if photo.exif_info.camera_make != CAMERA_MAKE:
continue
# Photos stores some data in photo.exif but the rating data must be extracted with exiftool
exif = photo.exiftool.asdict()
# I think SONY uses XMP:Rating but also check EXIF:Rating
xmp_rating = exif.get("XMP:Rating", 0)
exif_rating = exif.get("EXIF:Rating", 0)
rating = max(xmp_rating, exif_rating)
if rating == 5:
print(f"Marking {photo.original_filename} ({photo.uuid}) as favorite")
photoscript.Photo(photo.uuid).favorite = True
if exif := photo.exiftool:
# I think SONY uses XMP:Rating but also check EXIF:Rating
xmp_rating = exif.get("XMP:Rating", 0)
exif_rating = exif.get("EXIF:Rating", 0)
rating = max(xmp_rating, exif_rating)
if rating == 5:
print(f"Marking {photo.original_filename} ({photo.uuid}) as favorite")
photoscript.Photo(photo.uuid).favorite = True
if __name__ == "__main__":