icloud-photos-downloader / icloud_photos_downloader

A command-line tool to download photos from iCloud
MIT License
6.77k stars 552 forks source link

[China] 1.9.0 domain parameter did't work #584

Open bosconb opened 1 year ago

bosconb commented 1 year ago

Overview

i've been using icloudpd in china mainland . months ago ,i cannt success anymore because of domain. Today i've upgrade icloudpd to 1.9.0 by pip, and use new --domain parameter,it should be no problem ,however,still showed Error info.

Steps to Reproduce

  1. pip install --upgrade icloudpd

    ❯ pip install --upgrade icloudpd
    Requirement already satisfied: icloudpd in /usr/local/lib/python3.10/site-packages/icloudpd-1.7.2-py3.10.egg (1.7.2)
    Collecting icloudpd
    Using cached icloudpd-1.9.0-py2.py3-none-any.whl (56 kB)
    Requirement already satisfied: requests<3,>=2.28.2 in /usr/local/lib/python3.10/site-packages/requests-2.28.2-py3.10.egg (from icloudpd) (2.28.2)
    Requirement already satisfied: piexif<2,>=1.1.3 in /usr/local/lib/python3.10/site-packages/piexif-1.1.3-py3.10.egg (from icloudpd) (1.1.3)
    Requirement already satisfied: tzlocal<5,>=4.2 in /usr/local/lib/python3.10/site-packages/tzlocal-4.2-py3.10.egg (from icloudpd) (4.2)
    Collecting schema<0.8,>=0.7.5
    Using cached schema-0.7.5-py2.py3-none-any.whl (17 kB)
    Requirement already satisfied: certifi<2023,>=2022.12.7 in /usr/local/lib/python3.10/site-packages/certifi-2022.12.7-py3.10.egg (from icloudpd) (2022.12.7)
    Requirement already satisfied: keyrings-alt<5,>=4.2.0 in /usr/local/lib/python3.10/site-packages/keyrings.alt-4.2.0-py3.10.egg (from icloudpd) (4.2.0)
    Collecting tqdm<5,>=4.64.1
    Using cached tqdm-4.64.1-py2.py3-none-any.whl (78 kB)
    Requirement already satisfied: python-dateutil<3,>=2.8.2 in /usr/local/lib/python3.10/site-packages/python_dateutil-2.8.2-py3.10.egg (from icloudpd) (2.8.2)
    Collecting six<2,>=1.16.0
    Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
    Requirement already satisfied: click<9,>=8.1.3 in /usr/local/lib/python3.10/site-packages/click-8.1.3-py3.10.egg (from icloudpd) (8.1.3)
    Requirement already satisfied: urllib3<2,>=1.26.14 in /usr/local/lib/python3.10/site-packages/urllib3-1.26.14-py3.10.egg (from icloudpd) (1.26.14)
    Requirement already satisfied: keyring<24,>=23.13.1 in /usr/local/lib/python3.10/site-packages/keyring-23.13.1-py3.10.egg (from icloudpd) (23.13.1)
    Collecting pytz<2023,>=2022.7.1
    Using cached pytz-2022.7.1-py2.py3-none-any.whl (499 kB)
    Collecting future<0.19,>=0.18.3
    Using cached future-0.18.3.tar.gz (840 kB)
    Preparing metadata (setup.py) ... done
    Requirement already satisfied: jaraco.classes in /usr/local/lib/python3.10/site-packages/jaraco.classes-3.2.3-py3.10.egg (from keyring<24,>=23.13.1->icloudpd) (3.2.3)
    Requirement already satisfied: importlib-metadata>=4.11.4 in /usr/local/lib/python3.10/site-packages/importlib_metadata-6.0.0-py3.10.egg (from keyring<24,>=23.13.1->icloudpd) (6.0.0)
    Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/site-packages/charset_normalizer-3.0.1-py3.10-macosx-11-x86_64.egg (from requests<3,>=2.28.2->icloudpd) (3.0.1)
    Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/site-packages/idna-3.4-py3.10.egg (from requests<3,>=2.28.2->icloudpd) (3.4)
    Collecting contextlib2>=0.5.5
    Using cached contextlib2-21.6.0-py2.py3-none-any.whl (13 kB)
    Requirement already satisfied: pytz-deprecation-shim in /usr/local/lib/python3.10/site-packages/pytz_deprecation_shim-0.1.0.post0-py3.10.egg (from tzlocal<5,>=4.2->icloudpd) (0.1.0.post0)
    Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.10/site-packages/zipp-3.12.0-py3.10.egg (from importlib-metadata>=4.11.4->keyring<24,>=23.13.1->icloudpd) (3.12.0)
    Requirement already satisfied: more-itertools in /usr/local/lib/python3.10/site-packages/more_itertools-9.0.0-py3.10.egg (from jaraco.classes->keyring<24,>=23.13.1->icloudpd) (9.0.0)
    Requirement already satisfied: tzdata in /usr/local/lib/python3.10/site-packages/tzdata-2022.7-py3.10.egg (from pytz-deprecation-shim->tzlocal<5,>=4.2->icloudpd) (2022.7)
    Building wheels for collected packages: future
    Building wheel for future (setup.py) ... done
    Created wheel for future: filename=future-0.18.3-py3-none-any.whl size=492025 sha256=0027cafde3d495d10cb6ddcd8e7c517a642c8b1d85b5f710ae2ef23efcb4d595
    Stored in directory: /Users/ian/Library/Caches/pip/wheels/5e/a9/47/f118e66afd12240e4662752cc22cefae5d97275623aa8ef57d
    Successfully built future
    Installing collected packages: pytz, tqdm, six, future, contextlib2, schema, icloudpd
    Attempting uninstall: tqdm
    Found existing installation: tqdm 4.62.0
    Uninstalling tqdm-4.62.0:
      Successfully uninstalled tqdm-4.62.0
    Attempting uninstall: schema
    Found existing installation: schema 0.7.4
    Uninstalling schema-0.7.4:
      Successfully uninstalled schema-0.7.4
    Attempting uninstall: icloudpd
    Found existing installation: icloudpd 1.7.2
    Uninstalling icloudpd-1.7.2:
      Successfully uninstalled icloudpd-1.7.2
    Successfully installed contextlib2-21.6.0 future-0.18.3 icloudpd-1.9.0 pytz-2022.7.1 schema-0.7.5 six-1.16.0 tqdm-4.64.1
  2. use icloudpd command,before i complete the 2FA step,it shows:

~/Pictures/icloudbackup4
❯ icloudpd --directory ~/Pictures/icloudbackup4 \
--username xxx@xxx.com \
--password xxxxx \
--domain cn \
--auto-delete
2023-02-12 18:39:06 DEBUG    Authenticating...
2023-02-12 18:39:11 INFO     Two-step/two-factor authentication is required!
Traceback (most recent call last):
  File "/usr/local/bin/icloudpd", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/site-packages/click-8.1.3-py3.10.egg/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click-8.1.3-py3.10.egg/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click-8.1.3-py3.10.egg/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click-8.1.3-py3.10.egg/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/icloudpd/base.py", line 275, in main
    icloud = authenticator(domain)(
  File "/usr/local/lib/python3.10/site-packages/icloudpd/authentication.py", line 48, in authenticate_
    request_2sa(icloud, logger)
  File "/usr/local/lib/python3.10/site-packages/icloudpd/authentication.py", line 55, in request_2sa
    devices = icloud.trusted_devices
  File "/usr/local/lib/python3.10/site-packages/pyicloud_ipd/base.py", line 266, in trusted_devices
    request = self.session.get(
  File "/usr/local/lib/python3.10/site-packages/requests-2.28.2-py3.10.egg/requests/sessions.py", line 600, in get
    return self.request("GET", url, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pyicloud_ipd/base.py", line 105, in request
    self._raise_error(code, reason)
  File "/usr/local/lib/python3.10/site-packages/pyicloud_ipd/base.py", line 127, in _raise_error
    raise api_error
pyicloud_ipd.exceptions.PyiCloudAPIResponseError: statusCode = UnknownServerError, IOException sending request https://accountservice.p00.prod.me.com:443/api/get_challenge_devices, accountservice.p00.prod.me.com
  1. another time
    
    ~/Pictures/icloudbackup4
    ❯ icloudpd --directory ~/Pictures/icloudbackup4 \
    --username xxx@xxx.com \
    --password xxxxx \
    --domain cn \
    --auto-delete
    2023-02-12 18:57:01 DEBUG    Authenticating...
    Traceback (most recent call last):
    File "/usr/local/lib/python3.10/site-packages/pyicloud_ipd/base.py", line 220, in authenticate
    req = self.session.post(
    File "/usr/local/lib/python3.10/site-packages/requests-2.28.2-py3.10.egg/requests/sessions.py", line 635, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
    File "/usr/local/lib/python3.10/site-packages/pyicloud_ipd/base.py", line 105, in request
    self._raise_error(code, reason)
    File "/usr/local/lib/python3.10/site-packages/pyicloud_ipd/base.py", line 127, in _raise_error
    raise api_error
    pyicloud_ipd.exceptions.PyiCloudAPIResponseError: statusCode = UnknownServerError, SocketTimeoutException sending request https://accountservice.p211.prod.silu.net:443/api/get_account_by_appleid_password, Read timed out, timeoutMs: 5000

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/bin/icloudpd", line 8, in sys.exit(main()) File "/usr/local/lib/python3.10/site-packages/click-8.1.3-py3.10.egg/click/core.py", line 1130, in call return self.main(args, kwargs) File "/usr/local/lib/python3.10/site-packages/click-8.1.3-py3.10.egg/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.10/site-packages/click-8.1.3-py3.10.egg/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/local/lib/python3.10/site-packages/click-8.1.3-py3.10.egg/click/core.py", line 760, in invoke return __callback(args, **kwargs) File "/usr/local/lib/python3.10/site-packages/icloudpd/base.py", line 275, in main icloud = authenticator(domain)( File "/usr/local/lib/python3.10/site-packages/icloudpd/authentication.py", line 31, in authenticate_ icloud = pyicloud_ipd.PyiCloudService( File "/usr/local/lib/python3.10/site-packages/pyicloud_ipd/base.py", line 204, in init self.authenticate() File "/usr/local/lib/python3.10/site-packages/pyicloud_ipd/base.py", line 228, in authenticate raise PyiCloudFailedLoginException(msg, error) pyicloud_ipd.exceptions.PyiCloudFailedLoginException: ('Invalid email/password combination.', PyiCloudAPIResponseError('statusCode = UnknownServerError, SocketTimeoutException sending request https://accountservice.p211.prod.silu.net:443/api/get_account_by_appleid_password, Read timed out, timeoutMs: 5000'))

AndreyNikiforov commented 1 year ago

@bosconb thanks for reporting. Looks like changing domain was not enough to get icloudpd working from China. I'll keep looking for solutions.

boredazfcuk commented 1 year ago

Someone pushed a PR to my container to fix the problem: https://github.com/boredazfcuk/docker-icloudpd/pull/265/commits/d0ffe24212cea558a3b9eead8f2d413c62b170f3

It seems they have forked picklepete’s pyicloud and got it working with that: https://github.com/qzchenwl/pyicloud

Some users have reported other issues though, such as Live Photos not working iirc. I guess this is due to picklepete’s version not having nbroadbent’s changes in it.

Hopefully you can figure out what changes from qzchenwl’s fork need bringing over to nbroadbent’s pyicloud so a fully working version can be made.

Thanks.

chyroc commented 1 year ago

same error

chyroc commented 1 year ago

试试 go 翻译的版本,至少保证在 cn 可以工作 try go port of pyicloud, work with domain=cn

https://github.com/chyroc/icloudgo

cfbsks commented 1 year ago

Same error:

iCloud username/email: c***@example.com
2023-04-09 12:29:09 DEBUG    Authenticating...
iCloud Password: 
2023-04-09 12:29:17 INFO     Two-step/two-factor authentication is required!
Traceback (most recent call last):
  File "exec.py", line 63, in <module>
  File "click/core.py", line 1130, in __call__
  File "click/core.py", line 1055, in main
  File "click/core.py", line 1657, in invoke
  File "click/core.py", line 1404, in invoke
  File "click/core.py", line 760, in invoke
  File "icloudpd/base.py", line 288, in main
  File "icloudpd/base.py", line 571, in core
  File "icloudpd/authentication.py", line 48, in authenticate_
  File "icloudpd/authentication.py", line 55, in request_2sa
  File "pyicloud_ipd/base.py", line 266, in trusted_devices
  File "requests/sessions.py", line 600, in get
  File "pyicloud_ipd/base.py", line 105, in request
  File "pyicloud_ipd/base.py", line 127, in _raise_error
pyicloud_ipd.exceptions.PyiCloudAPIResponseError: statusCode = UnknownServerError, IOException sending request https://accountservice.p00.prod.me.com:443/api/get_challenge_devices, accountservice.p00.prod.me.com
[1] Failed to execute script 'exec' due to unhandled exception!