Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to download X oldest items, not only X recent ones. #620

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions icloudpd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -229,6 +234,7 @@ def main(
size,
live_photo_size,
recent,
oldest,
until_found,
album,
list_albums,
Expand Down Expand Up @@ -303,6 +309,7 @@ def main(
cookie_directory,
size,
recent,
oldest,
until_found,
album,
list_albums,
Expand Down Expand Up @@ -539,6 +546,7 @@ def core(
cookie_directory,
size,
recent,
oldest,
until_found,
album,
list_albums,
Expand Down Expand Up @@ -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:
Expand Down