Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Commit

Permalink
Add --cookie-directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Zebradil committed Nov 17, 2021
1 parent d78ea2a commit 69fd1f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions gimme_iphotos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ def get_cli_args() -> argparse.Namespace:
"--password",
help="iCloud password. Can be specified interactively if not set.",
)
parser.add_argument(
"--cookie-directory",
dest="cookie_directory",
help="Directory to store cookie files.\n"
+ "Cookies can be used to avoid authentication step for subsequent runs.\n"
+ "If not set, cookies are stored in a temporary directory and usually deleted between restarts.",
)
parser.add_argument(
"-d",
"--destination",
Expand Down
11 changes: 9 additions & 2 deletions gimme_iphotos/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DownloaderApp:
DEFAULTS = {
"username": None,
"password": None,
"cookie_directory": None,
"destination": None,
"overwrite": False,
"remove": False,
Expand Down Expand Up @@ -119,9 +120,15 @@ def connect_to_icloud(
) -> PyiCloudService:
self.logger.info("Connecting to iCloud…")
if config["password"] == "":
api = PyiCloudService(config["username"])
api = PyiCloudService(
config["username"], cookie_directory=config["cookie_directory"]
)
else:
api = PyiCloudService(config["username"], config["password"])
api = PyiCloudService(
config["username"],
password=config["password"],
cookie_directory=config["cookie_directory"],
)

if api.requires_2sa:
print("Two-step authentication required.")
Expand Down

0 comments on commit 69fd1f6

Please sign in to comment.