From b2e0aa4286d7b9384893214afbe25ce74689035a Mon Sep 17 00:00:00 2001 From: santa Date: Mon, 10 Apr 2023 09:27:56 +0200 Subject: [PATCH] Added option to download X oldest items, not only X recent ones. --- icloudpd/base.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/icloudpd/base.py b/icloudpd/base.py index 2327e73c8..1313e7e44 100755 --- a/icloudpd/base.py +++ b/icloudpd/base.py @@ -75,6 +75,11 @@ help="Number of recent photos to download (default: download all photos)", type=click.IntRange(0), ) +@click.option( + "--oldest", + help="Number of oldest photos to download (default: download all photos)", + type=click.IntRange(-50), +) @click.option( "--until-found", help="Download most recently added photos until we find x number of " @@ -229,6 +234,7 @@ def main( size, live_photo_size, recent, + oldest, until_found, album, list_albums, @@ -303,6 +309,7 @@ def main( cookie_directory, size, recent, + oldest, until_found, album, list_albums, @@ -539,6 +546,7 @@ def core( cookie_directory, size, recent, + oldest, until_found, album, list_albums, @@ -647,6 +655,13 @@ def photos_exception_handler(ex, retries): photos_count = recent photos = itertools.islice(photos, recent) + # Optional: Only download the x oldest photos. + if oldest is not None: + photos_count = oldest + total_photos = len(photos) + start = total_photos - oldest + photos = itertools.islice(photos, start, total_photos) + tqdm_kwargs = {"total": photos_count} if until_found is not None: