icloudpy icon indicating copy to clipboard operation
icloudpy copied to clipboard

feat: add support for libraries that are shared with the user

Open rhaidiz opened this issue 2 months ago • 0 comments

This PR tries to address issue https://github.com/mandarons/icloudpy/issues/115.

I looked at the current structure of the Photos service. From my understanding, the way that the code is structured at the moment is such that PhotosService not only acts as the 'Photos' iCloud service, but behaves like the user's primary library. In doing so, the assumption is that this service is tied to a specific API end-point specified in init. However, the libraries that are shared with me are available on a different end-point.

My initial hope was to change the service so that I could do something like api.photos.libraries and obtain the list of all my libraries, the ones I own and the ones I am shared with. However, I could not find a way to achieve this while reusing as much of the current code as possible and also maintaining compatibility without introducing braking changes. So here are my 2 cents: I am not sure why PhotosService inherit from PhotosLibrary, it feel conceptually wrong. I do understand that it might make it nice to have PhotosService behave like the user's primary library, but since this also ties the service to a specific end-point I really could not find a way to work around it.

This PR is the best solution that I could think of while trying to follow the current philosophy of one service tied to one end-point: a new service, SharedPhotosService, which essentially behaves like PhotosService but is dedicated to the library shared with the user.

Note: unlike for queries to the private library, queries to the shared library need to have the ownerRecordName specified, which means that it is not possible to initialize SharedPhotosService the same way as you would with PhotosService which does not require ownerRecordName.

Let me know what you think of this solution, I can also add some pytests to cover it and update the README to clarify the difference in the two services.

rhaidiz avatar Nov 04 '25 16:11 rhaidiz