diff --git a/dogsheep_photos/cli.py b/dogsheep_photos/cli.py index 9147cd9..cc88b34 100644 --- a/dogsheep_photos/cli.py +++ b/dogsheep_photos/cli.py @@ -17,6 +17,7 @@ CONTENT_TYPES, get_all_keys, osxphoto_to_row, + osxphoto_to_score_row, to_uuid, s3_upload, hash_and_size_path, @@ -205,40 +206,37 @@ def apple_photos(db_path, library, image_url_prefix, image_url_suffix): db["apple_photos_scores"].drop() db.conn.execute( """ - create table apple_photos_scores as select - ZGENERICASSET.ZUUID, - ZGENERICASSET.ZOVERALLAESTHETICSCORE, - ZGENERICASSET.ZCURATIONSCORE, - ZGENERICASSET.ZPROMOTIONSCORE, - ZGENERICASSET.ZHIGHLIGHTVISIBILITYSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZBEHAVIORALSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZFAILURESCORE, - ZCOMPUTEDASSETATTRIBUTES.ZHARMONIOUSCOLORSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZIMMERSIVENESSSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZINTERACTIONSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZINTERESTINGSUBJECTSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZINTRUSIVEOBJECTPRESENCESCORE, - ZCOMPUTEDASSETATTRIBUTES.ZLIVELYCOLORSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZLOWLIGHT, - ZCOMPUTEDASSETATTRIBUTES.ZNOISESCORE, - ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTCAMERATILTSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTCOMPOSITIONSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTLIGHTINGSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTPATTERNSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTPERSPECTIVESCORE, - ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTPOSTPROCESSINGSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTREFLECTIONSSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTSYMMETRYSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZSHARPLYFOCUSEDSUBJECTSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZTASTEFULLYBLURREDSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZWELLCHOSENSUBJECTSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZWELLFRAMEDSUBJECTSCORE, - ZCOMPUTEDASSETATTRIBUTES.ZWELLTIMEDSHOTSCORE - from - attached.ZGENERICASSET - join attached.ZCOMPUTEDASSETATTRIBUTES on - attached.ZGENERICASSET.Z_PK = attached.ZCOMPUTEDASSETATTRIBUTES.ZASSET; - """ + CREATE TABLE apple_photos_scores( + ZUUID TEXT, + ZOVERALLAESTHETICSCORE REAL, + ZCURATIONSCORE REAL, + ZPROMOTIONSCORE REAL, + ZHIGHLIGHTVISIBILITYSCORE REAL, + ZBEHAVIORALSCORE REAL, + ZFAILURESCORE REAL, + ZHARMONIOUSCOLORSCORE REAL, + ZIMMERSIVENESSSCORE REAL, + ZINTERACTIONSCORE REAL, + ZINTERESTINGSUBJECTSCORE REAL, + ZINTRUSIVEOBJECTPRESENCESCORE REAL, + ZLIVELYCOLORSCORE REAL, + ZLOWLIGHT REAL, + ZNOISESCORE REAL, + ZPLEASANTCAMERATILTSCORE REAL, + ZPLEASANTCOMPOSITIONSCORE REAL, + ZPLEASANTLIGHTINGSCORE REAL, + ZPLEASANTPATTERNSCORE REAL, + ZPLEASANTPERSPECTIVESCORE REAL, + ZPLEASANTPOSTPROCESSINGSCORE REAL, + ZPLEASANTREFLECTIONSSCORE REAL, + ZPLEASANTSYMMETRYSCORE REAL, + ZSHARPLYFOCUSEDSUBJECTSCORE REAL, + ZTASTEFULLYBLURREDSCORE REAL, + ZWELLCHOSENSUBJECTSCORE REAL, + ZWELLFRAMEDSUBJECTSCORE REAL, + ZWELLTIMEDSHOTSCORE REAL + ); + """ ) db["apple_photos_scores"].create_index(["ZUUID"]) @@ -258,6 +256,9 @@ def apple_photos(db_path, library, image_url_prefix, image_url_suffix): db["apple_photos"].insert( photo_row, pk="uuid", replace=True, alter=True, ) + score_row = osxphoto_to_score_row(photo) + db["apple_photos_scores"].insert(score_row, pk="ZUUID", replace=True, alter=True + ) # Ensure indexes for column in ("date", "sha256"): try: diff --git a/dogsheep_photos/utils.py b/dogsheep_photos/utils.py index f9c0d93..11cde48 100644 --- a/dogsheep_photos/utils.py +++ b/dogsheep_photos/utils.py @@ -98,6 +98,39 @@ def osxphoto_to_row(sha256, photo): row["place_{}".format(key)] = value return row +def osxphoto_to_score_row(photo): + score = photo.score + return { + "ZUUID": photo.uuid, + "ZOVERALLAESTHETICSCORE": score.overall, + "ZCURATIONSCORE": score.curation, + "ZPROMOTIONSCORE": score.promotion, + "ZHIGHLIGHTVISIBILITYSCORE": score.highlight_visibility, + "ZBEHAVIORALSCORE": score.behavioral, + "ZFAILURESCORE": score.failure, + "ZHARMONIOUSCOLORSCORE": score.harmonious_color, + "ZIMMERSIVENESSSCORE": score.immersiveness, + "ZINTERACTIONSCORE": score.interaction, + "ZINTERESTINGSUBJECTSCORE": score.interesting_subject, + "ZINTRUSIVEOBJECTPRESENCESCORE": score.intrusive_object_presence, + "ZLIVELYCOLORSCORE": score.lively_color, + "ZLOWLIGHT": score.low_light, + "ZNOISESCORE": score.noise, + "ZPLEASANTCAMERATILTSCORE": score.pleasant_camera_tilt, + "ZPLEASANTCOMPOSITIONSCORE": score.pleasant_composition, + "ZPLEASANTLIGHTINGSCORE": score.pleasant_lighting, + "ZPLEASANTPATTERNSCORE": score.pleasant_pattern, + "ZPLEASANTPERSPECTIVESCORE": score.pleasant_perspective, + "ZPLEASANTPOSTPROCESSINGSCORE": score.pleasant_post_processing, + "ZPLEASANTREFLECTIONSSCORE": score.pleasant_reflection, + "ZPLEASANTSYMMETRYSCORE": score.pleasant_symmetry, + "ZSHARPLYFOCUSEDSUBJECTSCORE": score.sharply_focused_subject, + "ZTASTEFULLYBLURREDSCORE": score.tastefully_blurred, + "ZWELLCHOSENSUBJECTSCORE": score.well_chosen_subject, + "ZWELLFRAMEDSUBJECTSCORE": score.well_framed_subject, + "ZWELLTIMEDSHOTSCORE": score.well_timed_shot, + } + def to_utc_isoformat(dt): if not dt: diff --git a/setup.py b/setup.py index ea777fa..e23dd2b 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ def get_long_description(): install_requires=[ "sqlite-utils>=2.7", "boto3>=1.12.41", - "osxphotos>=0.28.13 ; sys_platform=='darwin'", + "osxphotos>=0.38.6 ; sys_platform=='darwin'", ], extras_require={"test": ["pytest"]}, tests_require=["dogsheep-photos[test]"],