Skip to content

Commit

Permalink
If the country or region setting of Apple ID is China mainland use di…
Browse files Browse the repository at this point in the history
…fferent endpoint.
  • Loading branch information
qzchenwl committed Jan 18, 2023
1 parent dd9313c commit d061140
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions icloudpd/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def authenticate(
password,
cookie_directory=None,
raise_error_on_2sa=False,
client_id=None
client_id=None,
china_mainland=False,
):
"""Authenticate with iCloud username and password"""
logger = setup_logger()
Expand All @@ -30,7 +31,9 @@ def authenticate(
icloud = pyicloud.PyiCloudService(
username, password,
cookie_directory=cookie_directory,
client_id=client_id)
client_id=client_id,
china_mainland=china_mainland,
)
except PyiCloudNoStoredPasswordAvailableException:
# Prompt for password if not stored in PyiCloud's keyring
password = click.prompt("iCloud Password", hide_input=True)
Expand Down
6 changes: 6 additions & 0 deletions icloudpd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
"(default: use PyiCloud keyring or prompt for password)",
metavar="<password>",
)
@click.option("--china-mainland",
help="The country or region setting of your Apple ID is 'China mainland'(中国大陆)",
is_flag=True,
)
@click.option(
"--cookie-directory",
help="Directory to store cookies for authentication "
Expand Down Expand Up @@ -200,6 +204,7 @@ def main(
directory,
username,
password,
china_mainland,
cookie_directory,
size,
live_photo_size,
Expand Down Expand Up @@ -258,6 +263,7 @@ def main(
cookie_directory,
raise_error_on_2sa,
client_id=os.environ.get("CLIENT_ID"),
china_mainland=china_mainland,
)
except TwoStepAuthRequiredError:
if notification_script is not None:
Expand Down

0 comments on commit d061140

Please sign in to comment.