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

Download fails when iCloud photo has a filename attribute with strange (empty?) value #935

Closed
MicaelJacobsson opened this issue Aug 15, 2024 · 3 comments
Assignees
Labels

Comments

@MicaelJacobsson
Copy link

Overview

I have photos with a seemingly empty value as filename. I think it came from uploading photos to iCloud causing duplicates. When downloading my entire library each such photo cause an uncaught exception and terminates the download

Steps to Reproduce

Try to download an iCloud photo where the filename shown in the photo Details is empty

Expected Behavior

The filename of the downloaded file should be set to truncated fingerprint by the code below

# Some photos don't have a filename.
        # In that case, just use the truncated fingerprint (hash),
        # plus the correct extension.
        filename = re.sub('[^0-9a-zA-Z]', '_', self.id)[0:12]

Actual Behavior

There is an exception thrown from this piece of code just above:

            _filename = self._service.filename_cleaner(**base64.b64decode(
                fields['filenameEnc']['value']
            )**.decode('utf-8'))

Context

I added a try: except on line 613 in icloud_photos_downloader\src\pyicloud_ipd\services\photos.py around that entire first if-clause, and rebuilt. With that build I could download the entire library, and the file-names of the strange photos were set from the truncated hash.

@AndreyNikiforov
Copy link
Collaborator

Can you try to confirm what attributes are in the response from icloud, please? Is there really no "filenameEnc" and no "filename" attributes or they have some unsupported values? icloud allows uploading assets with duplicate filenames, so I do not expect it to be the cause.

@AndreyNikiforov
Copy link
Collaborator

@MicaelJacobsson v1.23.2 will dump content on which decoding is choking. Should be sufficient to use --dry-run for reproducing your issue. Please try and see what it brings.

@AndreyNikiforov
Copy link
Collaborator

I assume your issue is related to new plain text filename encoding introduced by Apple. Support for that encoding has been added in v1.23.4. You can test if new version fixes your issue with:

docker run --rm -it icloudpd/icloudpd:1.23.4 icloudpd -u [email protected] -d . --dry-run

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

No branches or pull requests

2 participants