Skip to content

Commit

Permalink
Fix Auto-delete date mismatch icloud-photos-downloader#345
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen Martin committed Jun 4, 2023
1 parent a5d47ce commit 752b79d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion icloudpd/autodelete.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
Delete any files found in "Recently Deleted"
"""
import os
import datetime
import logging
from icloudpd.logger import setup_logger
from icloudpd.paths import local_download_path
from tzlocal import get_localzone


def autodelete_photos(icloud, folder_structure, directory):
Expand All @@ -18,7 +21,14 @@ def autodelete_photos(icloud, folder_structure, directory):
recently_deleted = icloud.photos.albums["Recently Deleted"]

for media in recently_deleted:
created_date = media.created
try:
created_date = media.created.astimezone(get_localzone())
except (ValueError, OSError):
logger.set_tqdm_description(
"Could not convert media created date to local timezone (%s)" %
media.created, logging.ERROR)
created_date = media.created

date_path = folder_structure.format(created_date)
download_dir = os.path.join(directory, date_path)

Expand Down

0 comments on commit 752b79d

Please sign in to comment.