Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only the first 209 albums listed using api.photos.albums #388

Open
aengeringh opened this issue Jul 29, 2022 · 4 comments · May be fixed by #410
Open

Only the first 209 albums listed using api.photos.albums #388

aengeringh opened this issue Jul 29, 2022 · 4 comments · May be fixed by #410

Comments

@aengeringh
Copy link

Only the first 209 albums listed using api.photos.albums

When using:
for album in api.photos.albums

Only the first 209 albums are listed. When I delte 4 albums from iCloud, 4 additional albums I was missing earlier appear. The total of albums remains 209, while I do have more albums in my iCloud account.

from pyicloud import PyiCloudService
api = PyiCloudService(icloud_id)
for album in api.photos.albums:
    print(album)

Environment

pip show pyicloud:
Name: pyicloud
Version: 1.0.0
Summary: PyiCloud is a module which allows pythonistas to interact with iCloud webservices.
Home-page: https://github.com/picklepete/pyicloud
Author: 
Author-email: 
License: MIT
Location: /home/andre/src/icloud-photobackup/venv/lib/python3.10/site-packages
Requires: certifi, click, keyring, keyrings.alt, requests, tzlocal
Required-by:

python -V:
Python 3.10.5

Operating environment:
Fedora 36

Traceback/Error logs

n/a

Additional information

n/a

@gordonaspin
Copy link

I have the same issue. Only 209 albums returned. There must be some pagination functionality in the API. I'm happy to help implement but cannot find documentation of the Photos API anywhere. Where is it ?

@gordonaspin
Copy link

I fixed locally by changing the implementation of _fetch_folders to;

def _fetch_folders(self):
    url = f"{self.service_endpoint}/records/query?{urlencode(self.params)}"
    json_data = (
        '{"query":{"recordType":"CPLAlbumByPositionLive"},'
        '"zoneID":{"zoneName":"PrimarySync"}}'
    )

    request = self.session.post(
        url, data=json_data, headers={"Content-type": "text/plain"}
    )

    response = request.json()

    records = response["records"]
    while 'continuationMarker' in response:
        json_data = (
        '{"query":{"recordType":"CPLAlbumByPositionLive"},'
        '"zoneID":{"zoneName":"PrimarySync"},'
        '"continuationMarker":"' + response['continuationMarker'] + '"}'
        )
        request = self.session.post(
            url, data=json_data, headers={"Content-type": "text/plain"}
        )
        response = request.json()
        records.extend(response["records"])

    return records

@gordonaspin gordonaspin linked a pull request Nov 15, 2022 that will close this issue
12 tasks
@aengeringh
Copy link
Author

@gordonaspin thanks! tested your code using PIP develop mode and it fixed the issue for me locally.

@gordonaspin
Copy link

gordonaspin commented Nov 16, 2022

Great! Checkout my fork of icloud-photos-downloader. I added features to download photos by album name, include or exclude reserved album names (store to local filesystem organized by album name) and updated to use my fork of pyicloud vs pyicloud_ipd and update to python 3.10.6

I use it on Linux mint to download my entire photos library for backup purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants