Skip to content

Commit

Permalink
add new thumbnail flag
Browse files Browse the repository at this point in the history
  • Loading branch information
framirez90 committed May 27, 2021
1 parent 9af5a74 commit c00dfa5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ Options:
Download live photos)
--force-size Only download the requested size (default:
download original if size is not available)
--thumbnail Only download the first photo as thumbnail
of album as it is shown in the device
(-a, --album option is required)
--auto-delete Scans the "Recently Deleted" folder and
deletes any files found in there. (If you
restore the photo in iCloud, it will be
Expand Down
14 changes: 12 additions & 2 deletions icloudpd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@
type=click.IntRange(1),
default=1,
)
@click.option(
"--thumbnail",
help="Get the first photo of album as thumbnail as is shown in the device",
is_flag=True,
)
@click.version_option()
# pylint: disable-msg=too-many-arguments,too-many-statements
# pylint: disable-msg=too-many-branches,too-many-locals
Expand Down Expand Up @@ -224,6 +229,7 @@ def main(
no_progress_bar,
notification_script,
threads_num, # pylint: disable=W0613
thumbnail,
):
"""Download all iCloud photos to a local directory"""

Expand Down Expand Up @@ -321,6 +327,10 @@ def photos_exception_handler(ex, retries):

photos_count = len(photos)

if thumbnail and album is not None:
photos = itertools.islice(photos, photos.page_size-1, photos.page_size)
photos_count = 1

# Optional: Only download the x most recent photos.
if recent is not None:
photos_count = recent
Expand All @@ -334,9 +344,9 @@ def photos_exception_handler(ex, retries):
# ensure photos iterator doesn't have a known length
photos = (p for p in photos)

plural_suffix = "" if photos_count == 1 else "s"
plural_suffix = "" if photos_count == 1 or thumbnail else "s"
video_suffix = ""
photos_count_str = "the first" if photos_count == 1 else photos_count
photos_count_str = "the first" if photos_count == 1 else "thumbnail" if thumbnail else photos_count
if not skip_videos:
video_suffix = " or video" if photos_count == 1 else " and videos"
logger.info(
Expand Down

0 comments on commit c00dfa5

Please sign in to comment.