Skip to content

Commit

Permalink
log more information for authentication error (#1013)
Browse files Browse the repository at this point in the history
  • Loading branch information
iowk authored Dec 2, 2024
1 parent 1b5269c commit f6ce3b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions src/icloudpd/autodelete.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions src/pyicloud_ipd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f6ce3b4

Please sign in to comment.