From f6ce3b433dfa95d759b934ef8cf7f684102e30b9 Mon Sep 17 00:00:00 2001 From: iowk Date: Tue, 3 Dec 2024 02:09:38 +0800 Subject: [PATCH] log more information for authentication error (#1013) --- CHANGELOG.md | 1 + src/icloudpd/autodelete.py | 8 ++++++-- src/pyicloud_ipd/base.py | 9 ++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b07f173d..d249b2b5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- fix: log more information for authentication error [#1010](https://github.com/icloud-photos-downloader/icloud_photos_downloader/issues/1010) - feature: add support for XMP files with `--xmp-sidecar` parameter [#448](https://github.com/icloud-photos-downloader/icloud_photos_downloader/issues/448), [#102](https://github.com/icloud-photos-downloader/icloud_photos_downloader/issues/102), [#789](https://github.com/icloud-photos-downloader/icloud_photos_downloader/issues/789) ## 1.24.4 (2024-11-18) diff --git a/src/icloudpd/autodelete.py b/src/icloudpd/autodelete.py index 5937bc940..0b970787c 100644 --- a/src/icloudpd/autodelete.py +++ b/src/icloudpd/autodelete.py @@ -73,11 +73,15 @@ def autodelete_photos( for _size, _version in disambiguate_filenames(media.versions, _sizes).items(): if _size in [AssetVersionSize.ALTERNATIVE, AssetVersionSize.ADJUSTED]: paths.add(os.path.normpath(local_download_path(_version.filename, download_dir))) - paths.add(os.path.normpath(local_download_path(_version.filename, download_dir)) + ".xmp") + paths.add( + os.path.normpath(local_download_path(_version.filename, download_dir)) + ".xmp" + ) for _size, _version in media.versions.items(): if _size not in [AssetVersionSize.ALTERNATIVE, AssetVersionSize.ADJUSTED]: paths.add(os.path.normpath(local_download_path(_version.filename, download_dir))) - paths.add(os.path.normpath(local_download_path(_version.filename, download_dir)) + ".xmp") + paths.add( + os.path.normpath(local_download_path(_version.filename, download_dir)) + ".xmp" + ) for path in paths: if os.path.exists(path): logger.debug("Deleting %s...", path) diff --git a/src/pyicloud_ipd/base.py b/src/pyicloud_ipd/base.py index 77f15cbca..38369a11a 100644 --- a/src/pyicloud_ipd/base.py +++ b/src/pyicloud_ipd/base.py @@ -266,15 +266,18 @@ def encode(self) -> bytes: data=json.dumps(data), headers=headers, ) - if response.status_code == 401: - raise PyiCloudAPIResponseException(response.text, str(response.status_code)) - if response.status_code == 412: + if response.status_code == 409: + # requires 2FA + pass + elif response.status_code == 412: # non 2FA account returns 412 "precondition no met" response = self.session.post( "%s/repair/complete" % self.AUTH_ENDPOINT, data=json.dumps({}), headers=headers, ) + elif response.status_code >= 400 and response.status_code < 600: + raise PyiCloudAPIResponseException(response.text, str(response.status_code)) except PyiCloudAPIResponseException as error: msg = "Invalid email/password combination." raise PyiCloudFailedLoginException(msg, error) from error