RhetTbull/PhotoScript

Accessing "shared with you" photos on macOS 14.2.1 by uuid raises invalid uuid exception

Opened this issue · 1 comments

disaac commented

Describe the bug
Currently when processing photos in my Photos Library via the API an exception is raised on a small subset of photos that I attempt to fetch by the uuid. I experienced an exception in the following methods when attempting to access the photo by its uuid.

photoscript Photo

from photoscript import Photo, PhotosLibrary
photos = PhotosDB().photos(movies=False)
for photo in photos:
	photo_ = Photo(photo.uuid)
...

photoscript PhotosLibrary

from photoscript import Photo, PhotosLibrary
selection = PhotosLibrary().selection if selected else []

There are only 3 out of my entire library that have this issue and all three are "Shared with You" photos in my library.

To Reproduce
Steps to reproduce the behavior:

  1. With shared with you photos in your photo library execute the following code once you have a uuid for one of those photos.
from photoscript import Photo
photo_ = Photo('A6D366D2-5889-431F-A09C-82A17254FA10')
  1. Observe the following exception will be raised
│                                                                                                  │
│    993 │   │   │   self.id = id_                                                                 │
│    994 │   │   │   self._uuid = uuid                                                             │
│    995 │   │   else:                                                                             │
│ ❱  996 │   │   │   raise ValueError(f"Invalid photo id: {uuid}")          
Invalid photo id: A6D366D2-5889-431F-A09C-82A17254FA10

Expected behavior
When referencing a photo that osxphotos cli can query and return information on using the Photo or photolibrary should not return an exception attempting to access the photo by the same uuid.

successfully returns photo information

osxphotos query --uuid A6D366D2-5889-431F-A09C-82A17254FA10 --json

Desktop (please complete the following information):

  • OS: macOS 14.2.1, arm64
  • osxphotos version
osxphotos, version 0.67.0
Python 3.11.6 (main, Oct 31 2023, 09:42:07) [Clang 15.0.0 (clang-1500.0.40.1)]
macOS 14.2.1, arm64

Additional context

  • I verified if I take the same photo and duplicate it so its not shared the issue is not seen. This issue is likely isolated to "Shared with You" photos.
  • I can provide the debug output from below command privately if helpful or anonymize fields as applicable if needed publicly.
osxphotos debug-dump --dump photos --uuid A6D366D2-5889-431F-A09C-82A17254FA10

Thanks for the detailed report. This should really go on the photoscript repo so I'll cross-post there.

Unfortunately, there's nothing osxphotos or photoscript can do about this as it's how the Photos AppleScript interface behaves. Photos in shared albums and in "Shared for You" show up in the library but they are note really in the library (e.g. assets under management of Photos and iCloud) until they are imported to the main library. The Photos AppleScript interface, which is used by photoscript to interact with Photos, cannot access photos in the "Shared with you" or shared albums. That's an Apple issue and not one that osxphotos or photoscript can work around.

You can access these photos via osxphotos and export them, get the path, etc. but you cannot access them via AppleScript or photoscript. If a Shared with you photo has been imported to the library then you can access it as you've demonstrated.