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
2.16k stars 99 forks source link

query --missing --add-to-album doesn't populate an album with results #1078

Open rajscode opened 1 year ago

rajscode commented 1 year ago

Issue: osxphotos query --missing --add-to-album doesn't populate an album with results even though it has located items.

Environment: osxphotos, version 0.60.1 Python 3.11.3 (main, Apr 7 2023, 20:13:31) [Clang 14.0.0 (clang-1400.0.29.202)] macOS 13.4.0, arm64

Actual command issued: osxphotos query --missing --add-to-album "missing"

Result: Will create the album but does not populate it or give an error or feedback. It does launch Photos App if not running. On the command line it does provide output of having found 70 objects that match the query and lists them out (summarized in table below for key atttributes).

Summary of result of the --missing --add-to-album "missing" Attribute TRUE / NOT Blank FALSE / Blank
ismissing 66 4
albums (name / Blank) 66 4
hasadjustments 0 70
shared 66 4
burst 0 70
live_photo 0 70
iscloudasset 69 1
incloud (TRUE / Blank) 3 67
intrash 0 70

Subset of the resultant rows from osxphotos output to the terminal. CSV file

RhetTbull commented 1 year ago

This should work as you expected it to with one exception: shared photos (which very likely may be missing as they're not downloaded by default) cannot be added to albums (this is true in Photos itself -- you would need to first import the shared photo then add it to an album). Try again with --not-shared:

osxphotos query --missing --not-shared --add-to-album "missing"

The code in question is:

https://github.com/RhetTbull/osxphotos/blob/d30314bedccf580c0e746bcddb2989a29fd918f5/osxphotos/cli/query.py#L139-L156

rajscode commented 1 year ago

Ran

osxphotos query --missing --not-shared --add-to-album "abcmissing"

Didn't populate the abcmissing album with any content. Did produce output on the terminal though of 4 rows (attached as a CSV file).

the attributes of all of those 4 rows that might be of interest are: ismissing: FALSE shared: FALSE burst: FALSE live_photo: FALSE iscloudasset: 3 TRUE and 1 FALSE incloud: 3 TRUE and 1 BLANK type of object: 1 jpeg, 2 mov, 1 heic results of - osxphotots query --missing --not-shared --add-to-album.csv

RhetTbull commented 1 year ago

Ran osxphotos query --missing --not-shared --add-to-album "abcmissing"

I tried this and was able to reproduce your results -- the album "abcmissing" was created but not populated

RhetTbull commented 1 year ago

I use "Keep originals on this Mac" but have a small number (~78) images marked as "missing". I have checked these and they all appear to be photos in the "Shared with you" album which are syndicated photos shared by contacts via Messages. These are shown in the library but like the classic "shared albums" they are not actually imported into the library. See #1054. osxphotos does not yet support these images but it does find them as referenced in the library and marked as missing because it can't find the original image. Until osxphotos can work with these images (I believe it's possible to actually extract them from Messages) I think we should have a --no-syndication flag to skip these photos (internally, Photos uses the term syndication to reference these).

Are you running on Ventura? AFAIK, Ventura is when these first appeared.

RhetTbull commented 1 year ago

Assuming you're on Ventura, here's something you can try to verify the missing photos are actually syndicated (shared from Messages or another app):

Launch osxphotos repl which will open an interactive osxphotos console.

In the console, type the following lines at the >>> prompt:

missing = [p for p in photos if p.ismissing]
for p in missing:
    print(p.uuid, p.tables().ZADDITIONALASSETATTRIBUTES.ZSYNDICATIONIDENTIFIER)

Which should produce output like this:

>>> missing = [p for p in photos if p.ismissing]
>>> for p in missing:
...     print(p.uuid, p.tables().ZADDITIONALASSETATTRIBUTES.ZSYNDICATIONIDENTIFIER)
1336176F-E14E-4C2B-A474-5217D355CFCC
('at_1_600C9AFE-DF02-4F5E-87A9-20FC277BDB22',)
59E798AA-F2C6-4F68-8D6D-80F133A9B58C
('at_1_F516D6B0-E716-4FA1-A453-BD9B43711FF7',)
0BAE073F-E778-4F06-87E2-90345394CAA0
('at_0_EFBCD22C-BB69-4CA3-8002-9A6EA10515A8',)

If your missing photos show a ZSYNDICATIONIDENTIFIER that looks like ('at_0_EFBCD22C-BB69-4CA3-8002-9A6EA10515A8',)) then they are syndicated and that's why osxphotos can't add them to an album.

rajscode commented 1 year ago

I use "Keep originals on this Mac" but have a small number (~78) images marked as "missing". I have checked these and they all appear to be photos in the "Shared with you" album which are syndicated photos shared by contacts via Messages. These are shown in the library but like the classic "shared albums" they are not actually imported into the library. See #1054. osxphotos does not yet support these images but it does find them as referenced in the library and marked as missing because it can't find the original image. Until osxphotos can work with these images (I believe it's possible to actually extract them from Messages) I think we should have a --no-syndication flag to skip these photos (internally, Photos uses the term syndication to reference these).

Are you running on Ventura? AFAIK, Ventura is when these first appeared.

Yup ... 13.4

In the console, type the following lines at the >>> prompt:

missing = [p for p in photos if p.ismissing]
for p in missing:
    print(p.uuid, p.tables().ZADDITIONALASSETATTRIBUTES.ZSYNDICATIONIDENTIFIER)

Produced the following: 22AD4E9A-60A9-41AE-91EE-E00D7D36BCB9 (None,) CFEC737C-51BD-4669-B064-50C93575655C ('at_0_ADE16139-BE63-47CE-93B1-3CA1F0165B64',) 80E694AD-113F-4C83-AF1D-643CDE7FD30F (None,) 5857EB79-A17D-42D9-8DEE-FAE54117F734 (None,) 4A13C45F-D342-4986-897F-B8D9C431D37B (None,) BDC13F2D-9452-43AE-A92A-C8FA1EA85D08 (None,) DB8D56CE-D952-4B69-84FA-28E6BBC32870 (None,) 1FFFD0CB-DB3A-4124-B580-DCEBC9FA14FA (None,) 9D66B459-8F43-4E0A-A5D0-35D30F605E6D (None,) 075E41A4-DE74-4C4F-A8E7-658A64DB9064 (None,) CEB71E10-E19E-449D-849E-649F9B5492B8 (None,) 193353F7-7F8D-4F1A-8524-85EE23EDD161 (None,) 5B3C27EC-7172-497A-BCF4-9A7EEC7501D3 (None,) E9650EBC-E909-4832-ACE9-E67711422E72 (None,) E92947AF-153A-4100-BDAE-EF191AB76CBE (None,) 37D30A26-37C7-489B-9CA8-695216725025 (None,) 12ED9AE4-6931-4680-9C41-2A27D747E363 (None,) CBE6D1BA-FD6B-4B17-B226-E45236C7F9E7 (None,) A08E9A43-3848-4B5D-AFFC-DE06A31277F2 (None,) 7FFC2A4C-F85B-48E3-9E5A-172AA4963281 (None,) 150080B5-570C-4955-B16D-CF27F05F1A4C (None,) 2E863FAC-D66E-4249-A3A5-14AF7F36B82E (None,) 6815EA8E-4E37-4D8C-B4DB-C9F48C43A788 (None,) 6DB933FA-CB10-4920-8DB1-ABBE39E91CE1 (None,) 08D9750D-53EE-4ACC-BA94-BE916371EE78 (None,) A893DBEA-06D1-4FEE-B6BA-2E1CF63841DF (None,) 89BB3D97-7967-45FC-B29F-03375565D187 (None,) AB29204A-FFA2-4813-85A7-1887FCEEC313 (None,) 622DF178-99AE-4DF6-B1A4-D7BC1D22115E (None,) C024D1D7-D871-422D-914D-77CFAA1A48DD (None,) B36DD5FE-8BE8-4941-91E4-3E0A857EB762 (None,) 4F7744C7-0B8B-46D7-B03C-552811014CD3 (None,) DD6A65F3-1305-4BCB-9461-6B017C1FDCF2 (None,) DD220E09-4B74-4FF9-8D31-7B498943FA0B (None,) D2618984-C27D-4B44-832A-940DF40A50CF (None,) D99EEB4F-B4FA-4ED7-845E-E038FEE7EE3C (None,) 5FC98739-A52F-41AC-B7D5-032B39077B0E (None,) F796C46E-D958-4312-91A7-89C34B12FD50 (None,) FC57DEA0-91E6-4FC9-90A8-42500CDA0706 (None,) 33F3F045-7D91-4F1B-BEFD-0DE69FF8303F (None,) 0F9DB3CA-561B-4996-97F3-C5442EFECC1D (None,) C7574EED-570D-42B5-9B2C-FA20F319E365 (None,) 2B9ABD42-06E4-4B5E-A680-1962139A153A (None,) FC9D102B-5E4C-4BF2-8837-C8857DE91F86 (None,) 18D65367-D6A5-4299-847A-CBA9939B6DEC (None,) EB2FCA71-3DC9-4CFB-BF18-611ACBB3D2FF (None,) AEA8FBD3-F0E6-4D4A-AFBE-AFBB4B2FA10D (None,) CDE878EE-3602-4E40-B063-FA79E8E9A5B3 (None,) 340266AE-5887-4EAD-8707-78EAC925A0DA (None,) 9AA8CDAF-E4DD-4526-AC58-21C91F1B0182 (None,) A8E12A4E-ABD2-409F-B6AC-C8B3EDB13027 (None,) 6ADE8569-CF8B-4DD0-8A30-4F0F0C383C06 (None,) 24F44AC4-2D07-457D-BFCD-A97728EA565F (None,) 83F1E179-1217-4C24-B2D6-EC40A470675A (None,) F47578BD-4A3B-49C0-987D-0EEF5DE3367D (None,) 9F7199FD-15CA-4DD7-9030-AC61F7F7B397 (None,) 60F2C751-ABB2-469E-A354-D9FC2E27C349 (None,) 2D3E0674-3B84-419D-891B-5B8633BCE941 (None,) 8598CCC5-E226-40A9-8752-AD558DC121A5 (None,) 60E59A30-A335-4614-A24D-09B8A4623902 (None,) E403FDF1-4D09-40BA-B5A4-0DB2641BB6CE (None,) AB13AFEB-7DB7-4A3E-9F8C-DE9C1E5AD5ED (None,) 2CA04596-C37D-42FB-B0E4-DECD0E4A9226 (None,) E04DF94B-8938-44B0-8748-6772DAA9A7B6 (None,) A942A783-52E2-484B-A739-18B37244DB55 (None,) 239F726E-4EA4-45EA-AA53-5369A460B317 (None,) 8DC8E74A-0145-4BC5-94BA-94F2A7470D63 (None,)

RhetTbull commented 1 year ago

Interesting -- looks like only one of these is a missing syndication item. Will have to keep digging on this. (In the mean time, I've made progress on adding support for these syndication items #1054)