GithubHelp home page GithubHelp logo

icloud-photos-downloader / icloud_photos_downloader Goto Github PK

View Code? Open in Web Editor NEW
5.9K 5.9K 516.0 19.76 MB

A command-line tool to download photos from iCloud

License: MIT License

Python 96.00% Shell 3.11% Dockerfile 0.20% JavaScript 0.67% jq 0.03%

icloud_photos_downloader's People

Contributors

andreynikiforov avatar appelg avatar artemryzhov avatar avouspierre avatar bexelbie avatar boredazfcuk avatar brunodoamaral avatar cclauss avatar chadj avatar dependabot[bot] avatar eana avatar elvis-epx avatar fnordahl avatar fver avatar gneitzke avatar harryzcy avatar jdahdah avatar jfsimoneau avatar kovaacs avatar ltm avatar matrixdai avatar menkej avatar ndbroadbent avatar nicoh88 avatar numshub avatar nurikk avatar scaraebeus avatar svisser avatar tkallevik avatar undefined-landmark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

icloud_photos_downloader's Issues

SyntaxError: invalid syntax

It looks like the line >>> icloud [email protected] is entered on the python shell, but following the steps outlined in the Readme I receive the following error:
File "<stdin>", line 1 icloud [email protected] ^ SyntaxError: invalid syntax

This is for Python version 2.7.12 (default, Jul 1 2016, 15:12:24) [GCC 5.4.0 20160609] on linux2

Installing requirements does not work

Hi,
I am facing an issue with the requirements installation after having launched this command:sudo pip install -r requirements.txt, see out put below.

I do not know exactly what to do :-((.
I am running El Capitan.

I would like to thank you in advance for your help,

Yop.

Requirement already satisfied: docopt in /Library/Python/2.7/site-packages (from -r requirements.txt (line 1)) Requirement already satisfied: schema in /Library/Python/2.7/site-packages (from -r requirements.txt (line 2)) Requirement already satisfied: click in /Library/Python/2.7/site-packages (from -r requirements.txt (line 3)) Requirement already satisfied: python-dateutil in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from -r requirements.txt (line 4)) Requirement already satisfied: requests in /Library/Python/2.7/site-packages (from -r requirements.txt (line 5)) Requirement already satisfied: tqdm>=4.5.0 in /Library/Python/2.7/site-packages (from -r requirements.txt (line 6)) Collecting pyicloud from git+https://github.com/torarnv/pyicloud.git@photos-update#egg=pyicloud (from -r requirements.txt (line 7)) Cloning https://github.com/torarnv/pyicloud.git (to photos-update) to /private/tmp/pip-build-Q820bR/pyicloud Requirement already satisfied: keyring<9.0,>=8.0 in /Library/Python/2.7/site-packages (from pyicloud->-r requirements.txt (line 7)) Requirement already satisfied: keyrings.alt<2.0,>=1.0 in /Library/Python/2.7/site-packages (from pyicloud->-r requirements.txt (line 7)) Collecting six>=1.9.0 (from pyicloud->-r requirements.txt (line 7)) Using cached six-1.10.0-py2.py3-none-any.whl Collecting tzlocal (from pyicloud->-r requirements.txt (line 7)) Using cached tzlocal-1.4.tar.gz Collecting certifi (from pyicloud->-r requirements.txt (line 7)) Using cached certifi-2017.4.17-py2.py3-none-any.whl Collecting bitstring (from pyicloud->-r requirements.txt (line 7)) Using cached bitstring-3.1.5.zip Collecting future (from pyicloud->-r requirements.txt (line 7)) Using cached future-0.16.0.tar.gz Requirement already satisfied: pytz in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from tzlocal->pyicloud->-r requirements.txt (line 7)) Installing collected packages: six, tzlocal, certifi, bitstring, future, pyicloud Found existing installation: six 1.4.1 DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project. Uninstalling six-1.4.1: Exception: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run prefix=options.prefix_path, File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install requirement.uninstall(auto_confirm=True) File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall paths_to_remove.remove(auto_confirm) File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove renames(path, new_path) File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames shutil.move(old, new) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move copy2(src, real_dst) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2 copystat(src, dst) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat os.chflags(dst, st.st_flags) OSError: [Errno 1] Operation not permitted: '/tmp/pip-5vu5B1-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

A few images not downloaded from iCloud

I'm testing this (wonderful) script. Works very well but I noticed an inconsistency on the number of images downloaded from my iCloud account: 827 images on iCloud, 825 images downloaded.

So started to investigate and discovered:

  • if I go to "Recently discarded" album (iPhone) and recover one picture, wait for sync to iCloud, the same picture remains in the "Recently discarded" album on iCloud web UI and this script does not get it
  • if I go to "Recently discarded" album (iCloud web UI) and recover one picture here, this script gets it

I then reviewed all pictures and found the two missing pictures (present on iCloud, missing locally): they where pictures older than a few months, that for sure I did discard and recover after a few days.

So it seems to me (and I'd like others to comment if already seen):

  • when I discard a picture on the iPhone, and recover that picture, the same does not gets immediatly recovered on iCloud
  • (perhaps) after the recovery time the picture starts being visible in iCloud but still not downloaded

Failed to establish a new connection: [Errno -2] Name or service not known',))

Signing in...
Updating photos...
Traceback (most recent call last):
File "./download_photos.py", line 231, in
download()
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "./download_photos.py", line 55, in download
updatePhotos(icloud)
File "./download_photos.py", line 155, in updatePhotos
icloud.photos.update()
File "/usr/local/lib/python2.7/dist-packages/pyicloud/base.py", line 306, in photos
self.params
File "/usr/local/lib/python2.7/dist-packages/pyicloud/services/photos.py", line 35, in init
params=self.params
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 487, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pyicloud/base.py", line 67, in request
response = super(PyiCloudSession, self).request(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 585, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 467, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='p34-photosws.icloud.com', port=443): Max retries exceeded with url: /ph/startup?clientBuildNumber=14E45&dsid=1372480800&clientId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7ff37510df50>: Failed to establish a new connection: [Errno -2] Name or service not known',))

help me please

AttributeError: 'PyiCloudService' object has no attribute 'requires_2sa'

I'm running ./download_photos.py with username argument. The username in question is in the keyring. The account of the username does not have 2FA enabled. I get the following error:

AttributeError: 'PyiCloudService' object has no attribute 'requires_2sa'

When I comment out the "if icloud.requires_2sa:" in the authentication.py module, I get the following error:

AttributeError: 'NoneType' object has no attribute 'photos'

extra augment

File "./download_photos.py", line 231, in
download()
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "./download_photos.py", line 54, in download
icloud = authenticate(username, password)
File "./download_photos.py", line 128, in authenticate
icloud = pyicloud.PyiCloudService(username, password)
File "/usr/local/lib/python2.7/dist-packages/pyicloud/base.py", line 169, in init
self.authenticate()
File "/usr/local/lib/python2.7/dist-packages/pyicloud/base.py", line 192, in authenticate
raise PyiCloudFailedLoginException(msg, error)
pyicloud.exceptions.PyiCloudFailedLoginException: ('Invalid email/password combination.', PyiCloudAPIResponseError('Misdirected Request',))

iOS 11 - Photos in HEIC Format

Hi, since iOS 11 Photos are save as HEIC Format in iCloud and also downloaded as such.

ios11-heic

This is completly useless for windows / linux... Maybe convert themautomatically to jpg could be a solution?

ImportError: No module named pyicloud

Hi,

I have an error ImportError: No module named pyicloud when launching my command.
I am a bit lost, any help appreciated.

Thanks in advance,
kr,

yop

please, add an options for keyring password

Hello,

if you store your iCloud password in the keyring, you must to set a password for the keyring. When calling "./download_photos.py" you must enter the password of keyring - so it is not possible to run the job regularly via cron.

Please add an option for a keyring password.

Thank you

Bad Request on update Photos

Hi,
first: THANK YOU for creating this wonderful tool! It will finally give me peace of mind when my photos are finally backed up locally too!

Unfortunately I am experiencing an API Error. Here is my log:

Signing in... Updating photos... Traceback (most recent call last): File "./download_photos.py", line 207, in <module> download() File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in __call__ return self.main(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke return callback(*args, **kwargs) File "./download_photos.py", line 51, in download icloud.photos.update() File "/usr/local/lib/python2.7/dist-packages/pyicloud/services/photos.py", line 95, in update data=data File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 500, in post return self.request('POST', url, data=data, json=json, **kwargs) File "/usr/local/lib/python2.7/dist-packages/pyicloud/base.py", line 101, in request raise api_error pyicloud.exceptions.PyiCloudAPIResponseError: Bad Request (400)

Do you have any idea, what is going on here?

Get rid of "Your Apple-ID has been used..." Mail notifications?

Hi,

is there a way to get rid of these E-Mail notifications? It seems that Apple does send them like every 5-10 days or so. Two factor is disabled. I do not know a lot about iCloud, just set this up to backup photos for my mother.
The notifications talk about "Webbrowser". Does Apple send these notifications always, even for people using a regular browser to access their iCloud stuff? Or is there maybe a cookie (or something) the app could save (and obviously set during http requests) to make apple think it knows the browser and all is fine?
Do you have any insights into this?

KeyError: u'resJPEGMedRes'

Hi there,

I was using the following command:

~/icloud_photos_downloader/./download_photos.py ./ --username=[email protected] --size=original --download-videos

and received the following error lines after 93% of all files downloaded:

Traceback (most recent call last):
File "/Users/unger/icloud_photos_downloader/./download_photos.py", line 255, in
download()
File "/Library/Python/2.7/site-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/Library/Python/2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Library/Python/2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Python/2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/unger/icloud_photos_downloader/./download_photos.py", line 158, in download
download_photo(photo, download_path, size, force_size, download_dir, progress_bar)
File "/Users/unger/icloud_photos_downloader/./download_photos.py", line 222, in download_photo
if size not in photo.versions and not force_size and size != 'original':
File "/Library/Python/2.7/site-packages/pyicloud/services/photos.py", line 487, in versions
'size': f['%sRes' % prefix]['value']['size'],
KeyError: u'resJPEGMedRes'

Does anybody have suggestions how to solve this?

Many thanks,

Kristian

How to get pictures from PhotoStream?

Hi.
How do I get pictures from photo stream for continuous back up purposes?
Tried to use download_photos, but it tells me 'Downloading 0 original photos'.

thanks.

When running through Docker, 2SA kicks in every time

I'm running the scripts through Docker, exactly as the provided example.

But I'm not getting any two month period before the 2SA kicks in again - it always forces me to fill in the 2SA code. I'm assuming the Dockerization is to blame. Any thoughts?

2fa after each reboot?

I have to run 2fa each time my server reboots (e.g. after maintenance). As it's setup as cron job, this is not woking without doing this step manually in advance. Am I missing something ..?

AttributeError: 'PyiCloudService' object has no attribute 'requires_2fa'

I'm getting a crash when trying to download photos:

$ ./download_photos.py my-photos --username [email protected] --password REDACTED
Traceback (most recent call last):
  File "./download_photos.py", line 252, in <module>
    download()
  File "/home/hugo/.local/share/virtualenvs/icloud/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/hugo/.local/share/virtualenvs/icloud/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/hugo/.local/share/virtualenvs/icloud/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/hugo/.local/share/virtualenvs/icloud/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "./download_photos.py", line 91, in download
    smtp_username, smtp_password, smtp_host, smtp_port, smtp_no_tls, notification_email)
  File "/home/hugo/tmp/icloud_photos_downloader/authentication.py", line 10, in authenticate
    icloud = PyiCloudService(username, password)
  File "/home/hugo/.local/share/virtualenvs/icloud/lib/python3.6/site-packages/pyicloud/base.py", line 192, in __init__
    self.authenticate()
  File "/home/hugo/.local/share/virtualenvs/icloud/lib/python3.6/site-packages/pyicloud/base.py", line 211, in authenticate
    data=json.dumps(data)
  File "/home/hugo/.local/share/virtualenvs/icloud/lib/python3.6/site-packages/requests/sessions.py", line 555, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/home/hugo/.local/share/virtualenvs/icloud/lib/python3.6/site-packages/pyicloud/base.py", line 100, in request
    self._raise_error(code, reason)
  File "/home/hugo/.local/share/virtualenvs/icloud/lib/python3.6/site-packages/pyicloud/base.py", line 105, in _raise_error
    if self.service.requires_2fa and \
AttributeError: 'PyiCloudService' object has no attribute 'requires_2fa'

My env:

certifi==2017.7.27.1
chardet==3.0.4
click==6.7
docopt==0.6.2
future==0.16.0
idna==2.6
keyring==8.7
keyrings.alt==1.3
pyicloud==0.9.1
python-dateutil==2.6.1
pytz==2017.2
requests==2.18.4
schema==0.6.6
six==1.11.0
tqdm==4.17.1
tzlocal==1.4
urllib3==1.22

[Errno 27] File too large

I received the following when including some large movies to download.

File "./download_photos.py", line 255, in
download()
File "/Library/Python/2.7/site-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/Library/Python/2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Library/Python/2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Python/2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "./download_photos.py", line 158, in download
download_photo(photo, download_path, size, force_size, download_dir, progress_bar)
File "./download_photos.py", line 236, in download_photo
file.write(chunk)
IOError: [Errno 27] File too large

Windows 10 + Python 2.7NO JSON object could be decoded.

Any ideas on the bellow issue? Running windows 2.7.2 bulid of python.
Updating photos...
Traceback (most recent call last):
File "download_photos.py", line 231, in
download()
File "c:\Python27\lib\site-packages\click\core.py", line 722, in call
return self.main(*args, **kwargs)
File "c:\Python27\lib\site-packages\click\core.py", line 697, in main
rv = self.invoke(ctx)
File "c:\Python27\lib\site-packages\click\core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\Python27\lib\site-packages\click\core.py", line 535, in invoke
return callback(*args, **kwargs)
File "download_photos.py", line 55, in download
updatePhotos(icloud)
File "download_photos.py", line 155, in updatePhotos
icloud.photos.update()
File "c:\Python27\lib\site-packages\pyicloud\base.py", line 306, in photos
self.params
File "c:\Python27\lib\site-packages\pyicloud\services\photos.py", line 37, in init
response = request.json()
File "c:\Python27\lib\site-packages\requests\models.py", line 878, in json
self.content.decode(encoding), **kwargs
File "c:\Python27\lib\json_init_.py", line 339, in loads
return _default_decoder.decode(s)
File "c:\Python27\lib\json\decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "c:\Python27\lib\json\decoder.py", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Failed to verify verification code

Output:

Two-factor authentication required. Your trusted devices are:
0: SMS to ********29
Which device would you like to use? [0]:
Please enter validation code: 852568
Failed to verify verification code

And yes, I'm 100% sure I have entered the correct code ;).
Any hints what is going wrong here?

AttributeError: 'PhotosService' object has no attribute 'update'

Getting following error:

Updating photos...
Traceback (most recent call last):
  File "download_photos.py", line 231, in <module>
    download()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "download_photos.py", line 55, in download
    updatePhotos(icloud)
  File "download_photos.py", line 155, in updatePhotos
    icloud.photos.update()
AttributeError: 'PhotosService' object has no attribute 'update'```

Support for .mov

I understand this is for photos, but would their also be a technical reason why Videos are not supported?
Could not process IMG_3278.MOV! Maybe try again later.

Docker image

Hi,

This is a great script!
Is there are a chance that you can make a docker image for that tool?
I want to use it in my Synology Nas.

Thanks,
Idan

download_photos.py tries to connect to non-existing host p48-photosws.icloud.com

Login and 2-factor auth succeeded:

$ ./download_photos.py ./dest/ --username [email protected] --password XXXXXXXX --size original
Signing in...
Updating photos...
Traceback (most recent call last):
  File "./download_photos.py", line 231, in <module>
    download()
  File "/home/hreese/src/icloud_photos_downloader/venv/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/hreese/src/icloud_photos_downloader/venv/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/hreese/src/icloud_photos_downloader/venv/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/hreese/src/icloud_photos_downloader/venv/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "./download_photos.py", line 55, in download
    updatePhotos(icloud)
  File "./download_photos.py", line 155, in updatePhotos
    icloud.photos.update()
  File "/home/hreese/src/icloud_photos_downloader/venv/lib/python2.7/site-packages/pyicloud/base.py", line 306, in photos
    self.params
  File "/home/hreese/src/icloud_photos_downloader/venv/lib/python2.7/site-packages/pyicloud/services/photos.py", line 35, in __init__
    params=self.params
  File "/home/hreese/src/icloud_photos_downloader/venv/lib/python2.7/site-packages/requests/sessions.py", line 515, in get
    return self.request('GET', url, **kwargs)
  File "/home/hreese/src/icloud_photos_downloader/venv/lib/python2.7/site-packages/pyicloud/base.py", line 67, in request
    response = super(PyiCloudSession, self).request(*args, **kwargs)
  File "/home/hreese/src/icloud_photos_downloader/venv/lib/python2.7/site-packages/requests/sessions.py", line 502, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/hreese/src/icloud_photos_downloader/venv/lib/python2.7/site-packages/requests/sessions.py", line 612, in send
    r = adapter.send(request, **kwargs)
  File "/home/hreese/src/icloud_photos_downloader/venv/lib/python2.7/site-packages/requests/adapters.py", line 504, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='p48-photosws.icloud.com', port=443): Max retries exceeded with url: /ph/startup?clientBuildNumber=14E45&dsid=xxxxxxxxxxx&clientId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f47f80603d0>: Failed to establish a new connection: [Errno -2] Name or service not known',))

Is that a bug in pyicloud or download_photos.py?

auto-delete isn`t working

Hi,

I'm getting that error when trying 'auto-delete' option

Signing in...
Looking up all photos...
Downloading 7338 original photos and videos to /volume1/Photo/iPhone-Backup/Idan/ ...
/volume1/Photo/iPhone-Backup/Idan/2010/04/07 already exists.: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 7338/7338 [04:04<00:00, 30.02it/s]
All photos have been downloaded!
Deleting any files found in 'Recently Deleted'...
Traceback (most recent call last):
  File "/volume1/@appstore/icloud_photo_station/app/download_photos.py", line 279, in <module>
    download()
  File "/volume1/@appstore/icloud_photo_station/env/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/volume1/@appstore/icloud_photo_station/env/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/volume1/@appstore/icloud_photo_station/env/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/volume1/@appstore/icloud_photo_station/env/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/volume1/@appstore/icloud_photo_station/app/download_photos.py", line 147, in download
    item = album.item(filename)
AttributeError: 'FileSystemAlbum' object has no attribute 'item'

Downloading 0 original photos

Hi,
I have passed authentication however I am not able to download any photos, no error messages just the below message shown. I have tried with and without 2fa.

Looking up all photos... Downloading 0 original photos and videos to /media/data3/Pictures/icloud/ ... 0it [00:00, ?it/s] All photos have been downloaded!

Picking up where left off, after a crash. (Invalid Global Session)

Hi @ndbroadbent ,

Sorry to be a frequent flyer! Noticed something after I got an "Invalid Global Session" a couple of times. I assume the Invalid Global Session is the result of a timeout from trying to download a large file (i.e. a large video)

When I re-execute, and I see the "already exists", jump 100 and check that file (forgive the pseudocode). If the file that is "100 later" already exists, another 100 is added to the counter and the 201st file is checked.

Makes complete sense. Only question I have is, what if the "n+100" file does indeed exist (in my case, because i downloaded all photos first, and am now running for videos), but the n+41 or n+73 or n+98 file does not? Will I end up missing the ones that are missing, but are under the "100 mark"?

Let me know if that doesn't make sense and I'll try to summarize better.

Thanks!!

AttributeError: 'module' object has no attribute 'python_2_unicode_compatible'

When running, i get the following error:
AttributeError: 'module' object has no attribute 'python_2_unicode_compatible'

Six has already been updated to latest version. Complete error output:

Traceback (most recent call last):
File "./download_photos.py", line 10, in
import pyicloud
File "/Library/Python/2.7/site-packages/pyicloud/init.py", line 2, in
from pyicloud.base import PyiCloudService
File "/Library/Python/2.7/site-packages/pyicloud/base.py", line 18, in
from pyicloud.services import (
File "/Library/Python/2.7/site-packages/pyicloud/services/init.py", line 7, in
from pyicloud.services.account import AccountService
File "/Library/Python/2.7/site-packages/pyicloud/services/account.py", line 31, in
@six.python_2_unicode_compatible
AttributeError: 'module' object has no attribute 'python_2_unicode_compatible'

Encoding of credentials

I like your tool very much. The only thing that annoys me is the fact that I have to give my icloud credentials in pure readable text. In this unsecure times I'd prefer to give it with the best encryption I can get.

At least I would love to see Base64 encoding which makes it unreadable for someone that isn't too computer-savvy...

Live photos not downloading

Live photos are not downloading, proabably an issue with pyicloud, can you suggest a fix?

Great project btw ๐Ÿ‘

Connection refused

Login and 2-Factor OK:

Signing in...
Updating photos...
Traceback (most recent call last):
File "download_photos.py", line 231, in
download()
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "download_photos.py", line 55, in download
updatePhotos(icloud)
File "download_photos.py", line 155, in updatePhotos
icloud.photos.update()
File "/usr/local/lib/python2.7/dist-packages/pyicloud/base.py", line 306, in photos
self.params
File "/usr/local/lib/python2.7/dist-packages/pyicloud/services/photos.py", line 35, in init
params=self.params
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 480, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pyicloud/base.py", line 67, in request
response = super(PyiCloudSession, self).request(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 437, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='p10-photosws.icloud.com', port=443): Max retries exceeded with url: /ph/startup?clientBuildNumber=14E45&dsid=93754147&clientId=0A0FB892-5738-11E7-9B6E-B827EBF49F22 (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x75a6a2d0>: Failed to establish a new connection: [Errno 111] Connection refused',))

Not sure what went wrong. I am realitivily new to Linux and Github so if it's something simple I have not done I apologise in advance.

Problem with Unicode characters in destination path

When I invoke the command with non-ascii characters in the destination path, there seem to be problems. For example,
mengyibai@my_computer:~/่ฝฏไปถ/icloud_photos_downloader$ ./download_photos.py ~/ ๅ›พ็‰‡/iCloud_Photos
In this case, the following error would occur:

Traceback (most recent call last):
  File "./download_photos.py", line 252, in <module>
    download()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "./download_photos.py", line 144, in download
    download_path = local_download_path(photo, size, download_dir)
  File "./download_photos.py", line 211, in local_download_path
    download_path = os.path.join(download_dir, filename)
  File "/usr/lib/python2.7/posixpath.py", line 73, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 16: ordinal not in range(128)

and the program would terminate. However, if the destination path is changed to pure ascii, the program would run smoothly. The non-ascii characters in the path of the script appear to have no ill effects.

Possibility to get notification?

Hey, I run this script as a cron on a headless server. It would be great it it could notify me as soon as the 2-factor has run out`.

No support for prompting for password

Giving password as a command line argument has some security risks as it will leave the password in the shell history and it is visible to other users on a system through the process list.

You can currently add password to PyIcloud's keychain but it would also be nice to have the download_photos command prompt for password when not provided.

TypeError

Hi! I have an error, when downloading my photos.

Signing in...
Updating photos...
Looking up all photos...
Downloading 2661 original photos and videos to ./photos/ ...
./photos/2014/04/02/2014-04-02 14-original.07-original.17-original.jpg already exists.:  38%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ                                           | 1006/2661 [00:26<04:25,  6.22it/s]Traceback (most recent call last):
  File "./download_photos.py", line 224, in <module>
    download()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "./download_photos.py", line 93, in download
    created_date = parse(photo.created)
  File "/usr/local/lib/python2.7/dist-packages/pyicloud/services/photos.py", line 248, in created
    dt = datetime.fromtimestamp(self.data.get('createdDate') / 1000.0)
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

Possible to download only videos?

Hi @ndbroadbent . Still running like a top. Thanks again for your help with my other issue. A quick question - naturally, I forgot to use the "--download-videos" argument. Once the photos all finish downloading, if I run with the "--download-videos" argument, will it know to get, effectively, only the videos? I know I read that multiple runs would only get new photos. But wanted to see if the same applied for videos since, technically, they are new.

Thanks!

Error message ImportError: No module named 'pyicloud'

Environment: ubuntu 16 LTS.

Install the package successfully. Install the requirement twice. This is the system message in the second installation.

(carnd-term1-gpu) cocadas@cocadas-ThinkPad-W540:~/icloud_photos_downloader$ sudo pip install -r requirements.txt
The directory '/home/cocadas/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/cocadas/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: docopt in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 1))
Requirement already satisfied: schema in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 2))
Requirement already satisfied: click in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 3))
Requirement already satisfied: python-dateutil in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 4))
Requirement already satisfied: requests in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 5))
Requirement already satisfied: tqdm==4.5.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 6))
Requirement already satisfied: pyicloud from git+https://github.com/picklepete/pyicloud.git#egg=pyicloud in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 7))
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/local/lib/python2.7/dist-packages (from requests->-r requirements.txt (line 5))
Requirement already satisfied: idna<2.7,>=2.5 in /usr/local/lib/python2.7/dist-packages (from requests->-r requirements.txt (line 5))
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python2.7/dist-packages (from requests->-r requirements.txt (line 5))
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python2.7/dist-packages (from requests->-r requirements.txt (line 5))
Requirement already satisfied: keyring<9.0,>=8.0 in /usr/local/lib/python2.7/dist-packages (from pyicloud->-r requirements.txt (line 7))
Requirement already satisfied: keyrings.alt<2.0,>=1.0 in /usr/local/lib/python2.7/dist-packages (from pyicloud->-r requirements.txt (line 7))
Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python2.7/dist-packages (from pyicloud->-r requirements.txt (line 7))
Requirement already satisfied: tzlocal in /usr/local/lib/python2.7/dist-packages (from pyicloud->-r requirements.txt (line 7))
Requirement already satisfied: pytz in /usr/local/lib/python2.7/dist-packages (from pyicloud->-r requirements.txt (line 7))
Requirement already satisfied: future in /usr/local/lib/python2.7/dist-packages (from pyicloud->-r requirements.txt (line 7))

Error message

(carnd-term1-gpu) cocadas@cocadas-ThinkPad-W540:~/icloud_photos_downloader$ ./download_photos.py ./iphoto --username=xyzemail --password=mypassword --size=original --download-videos --notification-email [email protected]
Traceback (most recent call last):
  File "./download_photos.py", line 13, in <module>
    from authentication import authenticate
  File "/home/cocadas/icloud_photos_downloader/authentication.py", line 3, in <module>
    from pyicloud import PyiCloudService
ImportError: No module named 'pyicloud'
(carnd-term1-gpu) cocadas@cocadas-ThinkPad-W540:~/icloud_photos_downloader$ 

Traceback error

sharry:icloud_photos_downloader$ ./download_photos.py /home/sharry/Pictures/icloud/ --username=[email protected] --size=original --recent 200
iCloud password: PASSWORDHERE


Signing in...
Updating photos...
Traceback (most recent call last):
  File "./download_photos.py", line 231, in <module>
    download()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "./download_photos.py", line 55, in download
    updatePhotos(icloud)
  File "./download_photos.py", line 155, in updatePhotos
    icloud.photos.update()
AttributeError: 'PhotosService' object has no attribute 'update'

Delete after download

Is there a way for you to make it automatically delete the photo off of iCloud after it is downloaded? The auto-delete seems to only remove the photos you have automatically deleted.

"Invalid Global Session" on every 100 items downloaded

Hi,
I'm downloading a decent amount of photos accumulated for a few years, and the process seems to fail regularly with either "Invalid global session" on every 100 items, or randomly with "Gone (410)" errors.

It's windows 10, freshly installed Python 3.6.3

If it matters -- the connection is rather slow, I'm in Australia :/

Log:

C:\Users\me\icloud_photos_downloader>download_photos.py d:\iCloud [email protected]  --download-videos
Looking up all photos...
Downloading 5694 original photos and videos to d:\iCloud/ ...
Downloading d:\iCloud\2017/10/18\IMG_3671-original.JPG:   5%|????                                                                 | 300/5694 [59:04<15:28:58, 10.33s/it]Traceback (most recent call last):
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 255, in <module>
    download()
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 129, in download
    for photo in progress_bar:
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tqdm\_tqdm.py", line 579, in __iter__
    for obj in iterable:
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\services\photos.py", line 281, in photos
    headers={'Content-type': 'text/plain'}
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 555, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 100, in request
    self._raise_error(code, reason)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 122, in _raise_error
    raise api_error
pyicloud.exceptions.PyiCloudAPIResponseError: Invalid global session


C:\Users\me\icloud_photos_downloader>download_photos.py d:\iCloud [email protected] --download-videos
Looking up all photos...
Downloading 5695 original photos and videos to d:\iCloud/ ...
Downloading d:\iCloud\2017/10/05\IMG_3486-original.MOV:   7%|?????                                                            | 377/5695 [1:00:54<304:35:47, 206.20s/it]Traceback (most recent call last):
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 255, in <module>
    download()
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 158, in download
    download_photo(photo, download_path, size, force_size, download_dir, progress_bar)
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 230, in download_photo
    download_url = photo.download(size)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\services\photos.py", line 501, in download
    **kwargs
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 521, in get
    return self.request('GET', url, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 74, in request
    self._raise_error(response.status_code, response.reason)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 122, in _raise_error
    raise api_error
pyicloud.exceptions.PyiCloudAPIResponseError: Gone (410)


C:\Users\me\icloud_photos_downloader>download_photos.py d:\iCloud [email protected] --download-videos
Looking up all photos...
Downloading 5695 original photos and videos to d:\iCloud/ ...
Downloading d:\iCloud\2017/09/17\IMG_3256-original.JPG:   9%|??????                                                             | 500/5695 [1:18:19<54:56:44, 38.08s/it]Traceback (most recent call last):
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 255, in <module>
    download()
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 129, in download
    for photo in progress_bar:
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tqdm\_tqdm.py", line 579, in __iter__
    for obj in iterable:
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\services\photos.py", line 281, in photos
    headers={'Content-type': 'text/plain'}
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 555, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 100, in request
    self._raise_error(code, reason)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 122, in _raise_error
    raise api_error
pyicloud.exceptions.PyiCloudAPIResponseError: Invalid global session


C:\Users\me\icloud_photos_downloader>download_photos.py d:\iCloud [email protected] --download-videos
Looking up all photos...
Downloading 5717 original photos and videos to d:\iCloud/ ...
Downloading d:\iCloud\2017/09/06\IMG_3070-original.MOV:  11%|????????                                                         | 631/5717 [1:36:58<749:26:03, 530.47s/it]Traceback (most recent call last):
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 255, in <module>
    download()
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 158, in download
    download_photo(photo, download_path, size, force_size, download_dir, progress_bar)
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 230, in download_photo
    download_url = photo.download(size)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\services\photos.py", line 501, in download
    **kwargs
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 521, in get
    return self.request('GET', url, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 74, in request
    self._raise_error(response.status_code, response.reason)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 122, in _raise_error
    raise api_error
pyicloud.exceptions.PyiCloudAPIResponseError: Gone (410)


C:\Users\me\icloud_photos_downloader>download_photos.py d:\iCloud [email protected] --download-videos
Looking up all photos...
Downloading 5717 original photos and videos to d:\iCloud/ ...
Downloading d:\iCloud\2017/08/28\IMG_2939-original.JPG:  12%|?????????                                                             | 700/5717 [55:46<5:33:48,  3.99s/it]Traceback (most recent call last):
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 255, in <module>
    download()
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 129, in download
    for photo in progress_bar:
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tqdm\_tqdm.py", line 579, in __iter__
    for obj in iterable:
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\services\photos.py", line 281, in photos
    headers={'Content-type': 'text/plain'}
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 555, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 100, in request
    self._raise_error(code, reason)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 122, in _raise_error
    raise api_error
pyicloud.exceptions.PyiCloudAPIResponseError: Invalid global session


C:\Users\me\icloud_photos_downloader>download_photos.py d:\iCloud [email protected] --download-videos
Looking up all photos...
Downloading 5717 original photos and videos to d:\iCloud/ ...
Downloading d:\iCloud\2017/08/14\IMG_2603-original.JPG:  14%|??????????                                                            | 800/5717 [44:53<5:13:56,  3.83s/it]Traceback (most recent call last):
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 255, in <module>
    download()
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 129, in download
    for photo in progress_bar:
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tqdm\_tqdm.py", line 579, in __iter__
    for obj in iterable:
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\services\photos.py", line 281, in photos
    headers={'Content-type': 'text/plain'}
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 555, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 100, in request
    self._raise_error(code, reason)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 122, in _raise_error
    raise api_error
pyicloud.exceptions.PyiCloudAPIResponseError: Invalid global session


C:\Users\me\icloud_photos_downloader>download_photos.py d:\iCloud [email protected] --download-videos
Looking up all photos...
Downloading 5717 original photos and videos to d:\iCloud/ ...
Downloading d:\iCloud\2017/08/02\IMG_2411-original.JPG:  16%|???????????                                                          | 900/5717 [44:12<16:21:27, 12.23s/it]Traceback (most recent call last):
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 255, in <module>
    download()
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 129, in download
    for photo in progress_bar:
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tqdm\_tqdm.py", line 579, in __iter__
    for obj in iterable:
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\services\photos.py", line 281, in photos
    headers={'Content-type': 'text/plain'}
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 555, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 100, in request
    self._raise_error(code, reason)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 122, in _raise_error
    raise api_error
pyicloud.exceptions.PyiCloudAPIResponseError: Invalid global session


C:\Users\me\icloud_photos_downloader>download_photos.py d:\iCloud [email protected] --download-videos
Looking up all photos...
Downloading 5717 original photos and videos to d:\iCloud/ ...
Downloading d:\iCloud\2017/07/23\IMG_2217-original.MOV:  17%|???????????                                                      | 965/5717 [1:02:29<415:16:48, 314.61s/it]Traceback (most recent call last):
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 255, in <module>
    download()
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 158, in download
    download_photo(photo, download_path, size, force_size, download_dir, progress_bar)
  File "C:\Users\me\icloud_photos_downloader\download_photos.py", line 230, in download_photo
    download_url = photo.download(size)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\services\photos.py", line 501, in download
    **kwargs
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 521, in get
    return self.request('GET', url, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 74, in request
    self._raise_error(response.status_code, response.reason)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyicloud\base.py", line 122, in _raise_error
    raise api_error
pyicloud.exceptions.PyiCloudAPIResponseError: Gone (410)

maintain timestamp

Great library, just what I needed. But would be nice if you can keep the timestamp of the files being downloaded.

Getting some error: Invalid global session

Hello,

I'm getting an error 'Invalid global session' every time the downloader is reaching 100-200 photos.
I'm running it on my Synology Nas.

here is the 'Invalid global session' error

Downloading /volume1/Photo/iPhone-Backup/Idan-test/2017/07/24/IMG_7747-original.JPG:   4%| | 300/7346 [1:27:59<60:36:5        3, 30.97s/it]Traceback (most recent call last):
  File "/volume1/homes/BuSHari/iCloudDownloader/icloud_photos_downloader/download_photos.py", line 231, in <module>
    download()
  File "/usr/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/volume1/homes/BuSHari/iCloudDownloader/icloud_photos_downloader/download_photos.py", line 87, in download
    for photo in progress_bar:
  File "/usr/lib/python2.7/site-packages/tqdm/_tqdm.py", line 872, in __iter__
    for obj in iterable:
  File "/usr/lib/python2.7/site-packages/pyicloud/services/photos.py", line 281, in photos
    headers={'Content-type': 'text/plain'}
  File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 518, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/lib/python2.7/site-packages/pyicloud/base.py", line 100, in request
    self._raise_error(code, reason)
  File "/usr/lib/python2.7/site-packages/pyicloud/base.py", line 122, in _raise_error
    raise api_error
pyicloud.exceptions.PyiCloudAPIResponseError: Invalid global session

IndexError: list index out of range

Hi,

Another issue: IndexError: list index out of range when launching my command to download all pictures and videos (see below).

Thanks for your help,

yop

Traceback (most recent call last): File "./download_photos.py", line 231, in <module> download() File "/Library/Python/2.7/site-packages/click/core.py", line 722, in __call__ return self.main(*args, **kwargs) File "/Library/Python/2.7/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/Library/Python/2.7/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "/Library/Python/2.7/site-packages/click/core.py", line 535, in invoke return callback(*args, **kwargs) File "./download_photos.py", line 54, in download icloud = authenticate(username, password) File "./download_photos.py", line 139, in authenticate device = devices[device] IndexError: list index out of range

Error: Gone (410)

Hello,

I'm getting some errors, and this is one of them: Gone (410).
I'm running it on my Synology Nas.

Downloading /volume1/Photo/iPhone-Backup/Idan-test/2017/07/15/IMG_7637-original.MOV:   5%| | 361/7349 [1:03:06<305:51:57s/it]Traceback (most recent call last):
  File "/volume1/homes/BuSHari/iCloudDownloader/icloud_photos_downloader/download_photos.py", line 231, in <module>
    download()
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/volume1/homes/BuSHari/iCloudDownloader/icloud_photos_downloader/download_photos.py", line 112, in download
    download_photo(photo, download_path, size, force_size, download_dir, progress_bar)
  File "/volume1/homes/BuSHari/iCloudDownloader/icloud_photos_downloader/download_photos.py", line 206, in download_ph
    download_url = photo.download(size)
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/pyicloud/services/photos.py", line 501, in downl
    **kwargs
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/sessions.py", line 521, in get
    return self.request('GET', url, **kwargs)
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/pyicloud/base.py", line 74, in request
    self._raise_error(response.status_code, response.reason)
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/pyicloud/base.py", line 122, in _raise_error
    raise api_error
pyicloud.exceptions.PyiCloudAPIResponseError: Gone (410)

Does not accept application password

It works with 2FA, but when I tried to use an application-specific password to run unattended, it fails with an authentication exception within pyicloud.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.