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

albumNameEnc error? #150

Closed
iambenmitchell opened this issue May 17, 2020 · 21 comments · Fixed by icloud-photos-downloader/pyicloud#4
Closed

albumNameEnc error? #150

iambenmitchell opened this issue May 17, 2020 · 21 comments · Fixed by icloud-photos-downloader/pyicloud#4

Comments

@iambenmitchell
Copy link

Hello, I just did a fresh install of windows 10, I also tried this on centos. Both give the same error bellow:

Traceback (most recent call last):
  File "icloudpd.py", line 5, in <module>
    main()
  File "C:\Users\Provision\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\Provision\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Users\Provision\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\Provision\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\Provision\Desktop\icloud_photos_downloader-master\icloudpd\base.py", line 276, in main
    photos = icloud.photos.albums[album]
  File "C:\Users\Provision\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pyicloud_ipd\services\photos.py", line 194, in albums
    folder['fields']['albumNameEnc']['value']).decode('utf-8')
KeyError: 'albumNameEnc'
@pensphreak
Copy link

I'm having the same issue. Ubuntu 20.04

./icloudpd.py -d ~/iCloudPhotos --username=xxxxx --password=xxxxx
2020-06-24 09:19:04 DEBUG Authenticating...
Traceback (most recent call last):
File "./icloudpd.py", line 5, in
main()
File "/home/pens/.local/lib/python3.8/site-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/home/pens/.local/lib/python3.8/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/home/pens/.local/lib/python3.8/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/pens/.local/lib/python3.8/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/pens/icloud_photos_downloader/icloudpd/base.py", line 276, in main
photos = icloud.photos.albums[album]
File "/home/pens/.local/lib/python3.8/site-packages/pyicloud_ipd/services/photos.py", line 194, in albums
folder['fields']['albumNameEnc']['value']).decode('utf-8')
KeyError: 'albumNameEnc'

@pensphreak
Copy link

Turns out I had a weird ‘Untitled’/null album with no name and no photos in it. I deleted that and everything seems to be running now.

@peiel
Copy link

peiel commented Jul 6, 2020

I hava the same issues, win10.

Traceback (most recent call last):
  File "c:\users\administrator\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\administrator\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Administrator\Anaconda3\Scripts\icloudpd.exe\__main__.py", line 9, in <module>
  File "c:\users\administrator\anaconda3\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\administrator\anaconda3\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\users\administrator\anaconda3\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\administrator\anaconda3\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\users\administrator\anaconda3\lib\site-packages\icloudpd\base.py", line 276, in main
    photos = icloud.photos.albums[album]
  File "c:\users\administrator\anaconda3\lib\site-packages\pyicloud_ipd\services\photos.py", line 194, in albums
    folder['fields']['albumNameEnc']['value']).decode('utf-8')
KeyError: 'albumNameEnc'

@cravussin
Copy link

cravussin commented Jul 6, 2020

same here, Catalina 10.15.4

Traceback (most recent call last):
  File "/usr/local/bin/icloudpd", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/icloudpd/base.py", line 276, in main
    photos = icloud.photos.albums[album]
  File "/usr/local/lib/python3.7/site-packages/pyicloud_ipd/services/photos.py", line 194, in albums
    folder['fields']['albumNameEnc']['value']).decode('utf-8')
KeyError: 'albumNameEnc'

@DeastinY
Copy link

While I don't know the origin of the error a fix is rather simple:
Open "/usr/local/lib/python3.7/site-packages/pyicloud_ipd/services/photos.py", line 194 and change it from
folder['fields']['albumNameEnc']['value']).decode('utf-8') to

try:
    folder['fields']['albumNameEnc']['value']).decode('utf-8')
except KeyError:
    continue

this will skip the folder with the bad name.

@dariks
Copy link

dariks commented Aug 4, 2020

@DeastinY I have tried your workaround, you seem to have an issue there.
Trying with your suggestion leads to an Syntax Error.
But i got it working:

try:                   
    folder_name = base64.b64decode(
        folder['fields']['albumNameEnc']['value']).decode('utf-8')
except KeyError:              
    continue

@maxexcloo
Copy link

@dariks thanks for the fix!

1 similar comment
@genfersee
Copy link

@dariks thanks for the fix!

@madrubbishcat
Copy link

While I don't know the origin of the error a fix is rather simple:
Open "/usr/local/lib/python3.7/site-packages/pyicloud_ipd/services/photos.py", line 194 and change it from
folder['fields']['albumNameEnc']['value']).decode('utf-8') to

try:
    folder['fields']['albumNameEnc']['value']).decode('utf-8')
except KeyError:
    continue

this will skip the folder with the bad name.

i tried to do this but it said permission denied...

@DeastinY
Copy link

try editing the file with admin rights

@maldeS
Copy link

maldeS commented Sep 25, 2020

While I don't know the origin of the error a fix is rather simple:
Open "/usr/local/lib/python3.7/site-packages/pyicloud_ipd/services/photos.py", line 194 and change it from
folder['fields']['albumNameEnc']['value']).decode('utf-8') to

try:
    folder['fields']['albumNameEnc']['value']).decode('utf-8')
except KeyError:
    continue

this will skip the folder with the bad name.

Heyho,
the script checks for '----Root-Folder----'

if folder['recordName'] == '----Root-Folder----' or \

Within my data there was '----Project-Root-Folder----' as well. With e.g.:

if folder['recordName'] == '----Project-Root-Folder----' or folder['recordName'] == '----Root-Folder----' or \

it works for me.

Regards

@takelley1
Copy link

Are there any plans to create a pull request for this fix?

@ndbroadbent
Copy link
Collaborator

+1, unfortunately I don't have much time to work on this project, but I'm definitely happy to merge a PR and release a new version if all the tests are passing

@boredazfcuk
Copy link
Contributor

I'd be interested in a fix for this, however, there isn't a "fix" as yet, is there?

It was my understanding that the workaround detailed here, only skips the files that present the problem, rather than provide a solution which enables their download.

@Appelg
Copy link
Contributor

Appelg commented Sep 29, 2020

@maldeS solution worked for me too. Guess that's the most clean solution since the one where we ignore exceptions might give us other problems....

@Vlad1mir-D
Copy link

@ndbroadbent
Can you please check this PR: icloud-photos-downloader/pyicloud#4 ?
Thanks!

@menkej
Copy link
Collaborator

menkej commented Sep 29, 2020

Can you please check this PR: ndbroadbent/pyicloud#4 ?
Works for me.

@ndbroadbent
Copy link
Collaborator

Thanks @Vlad1mir-D! I merged your PR and released a new version of icloudpd: 1.6.1. Please try that out and let me know if it fixes the issue

@Vlad1mir-D
Copy link

Thank you, @ndbroadbent!
Everything's fine.

@maldeS
Copy link

maldeS commented Sep 29, 2020

cool, works for me as well! thx.

@Monsterbacke007
Copy link

Monsterbacke007 commented Oct 5, 2020

@DeastinY I have tried your workaround, you seem to have an issue there.
Trying with your suggestion leads to an Syntax Error.
But i got it working:

try:                   
    folder_name = base64.b64decode(
        folder['fields']['albumNameEnc']['value']).decode('utf-8')
except KeyError:              
    continue

With this I get 'continue not properly in loop'

`@property
def albums(self):
if not self._albums:
self._albums = {name: PhotoAlbum(self, name, **props)
for (name, props) in self.SMART_FOLDERS.items()}

        for folder in self._fetch_folders():
            # FIXME: Handle subfolders
            if folder['recordName'] in ('----Root-Folder----',
                '----Project-Root-Folder----') or \
                (folder['fields'].get('isDeleted') and
                 folder['fields']['isDeleted']['value']):
                continue

            folder_id = folder['recordName']
            folder_obj_type = \
                "CPLContainerRelationNotDeletedByAssetDate:%s" % folder_id
        try:
            folder_name = base64.b64decode(
                folder['fields']['albumNameEnc']['value']).decode('utf-8')
        except KeyError:
            continue
        
            query_filter = [{
                "fieldName": "parentId",
                "comparator": "EQUALS",
                "fieldValue": {
                    "type": "STRING",
                    "value": folder_id
                }
            }]

            album = PhotoAlbum(self, folder_name,
                               'CPLContainerRelationLiveByAssetDate',
                               folder_obj_type, 'ASCENDING', query_filter)
            self._albums[folder_name] = album

    return self._albums`

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.