RhetTbull / osxphotos

Python app to work with pictures and associated metadata from Apple Photos on macOS. Also includes a package to provide programmatic access to the Photos library, pictures, and metadata.
MIT License
1.98k stars 94 forks source link

osxphotos sync to also consider --merge location and folder structure #1639

Open oPromessa opened 1 month ago

oPromessa commented 1 month ago

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

Describe alternatives you've considered

Additional context

RhetTbull commented 1 month ago

Good suggestions.

For location, it obviously can't be merged so the behavior would need to be determined for what happens if user uses --merge location. Currently the code doesn't have separate lists of properties for --set or --merge. I would recommend the behavior be the same as it is for favorite: if --merge and property is set in the destination then no action is taken; if property is not set in the destination but is set in the source, then the value is copied to destination.

The location field would need to be added to SYNC_IMPORT_TYPES:

https://github.com/RhetTbull/osxphotos/blob/9a07c29e50dd45c178eba5d890314729fa048997/osxphotos/cli/sync.py#L52-L58

Then the import_metadata_for_photo function would need to be updated to handle this, either in a separate block like albums are handled:

https://github.com/RhetTbull/osxphotos/blob/9a07c29e50dd45c178eba5d890314729fa048997/osxphotos/cli/sync.py#L372C1-L375C79

Or in _set_metadata_for_photo and _merge_metadata_for_photo functions.

The folders/albums feature will take a bit more work and I'll have to dig in a bit more when I get a chance.

oPromessa commented 1 month ago
oPromessa commented 1 month ago

FYI only....

While trying to run --tests-sync I bumped into the get_os_version code in tests/conftest.py expecting to get my current OS version Sonoma's 14.6.1. I got 10.16 instead!!. Explained here: pythons-platform-mac-ver-reports-incorrect-macos-version.

I'm pretty sure you @RhetTbull are aware of SYSTEM_VERSION_COMPAT mode variable:

$ SYSTEM_VERSION_COMPAT=0 python3.11 -c 'import platform; print(platform.mac_ver())'
('14.6.1', ('', '', ''), 'x86_64')
$ SYSTEM_VERSION_COMPAT=1 python3.11 -c 'import platform; print(platform.mac_ver())'
('10.16', ('', '', ''), 'x86_64')

For now I'll edit tests/conftest.py to also accept OS_VER[1] == 16 to allow me to run the --tests-sync option locally. https://github.com/RhetTbull/osxphotos/blob/9a07c29e50dd45c178eba5d890314729fa048997/tests/conftest.py#L70-L72

oPromessa commented 1 month ago
RhetTbull commented 1 month ago

Great! I'll take a look at the failing tests when I get a chance. I responded to #1641 -- I don't believe it's actually a bug but intended behavior.

oPromessa commented 4 weeks ago

--set / --merge location feature added via #1642

RhetTbull commented 4 weeks ago

Thanks! Should be merged in 0.68.5. I will work on the folder path part as I have time. Currently working on some changes to date handling so OSXPhotos can access the original date of an image even if it's been changed by the user in Photos.

oPromessa commented 4 weeks ago

Thanks! Should be merged in 0.68.5. I will work on the folder path part as I have time. Currently working on some changes to date handling so OSXPhotos can access the original date of an image even if it's been changed by the user in Photos.

Cool. Now that you mention dates; I was also thinking if sync should also set dates coming from the original database ?

RhetTbull commented 4 weeks ago

Yes that's a good idea.

RhetTbull commented 3 weeks ago

I'll work on adding the date + folder structure soon. Finishing some re-factoring of the date/time code to allow retrieval of the original date even if user has changed it. (Will allow osxphotos timewarp to reset dates, for example). I need to finish that code first.

My plan at the moment is to have albums or all sync folder structure by default as this avoids conflicts if user has Folder1/Album1 in one library and Album1 as a top level album in another -- photos get synced to the "right" album. With the code I posted to #1650 I could also remove photos from albums...make make that a separate option.