-
Notifications
You must be signed in to change notification settings - Fork 573
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 (building upon Santa77's #620) #1022
base: master
Are you sure you want to change the base?
Added option to download X oldest items, not only X recent ones (building upon Santa77's #620) #1022
Changes from all commits
b2e0aa4
44a5a71
7973160
598d277
9c781f7
6506fa6
1c55664
8652398
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -338,6 +338,11 @@ def report_version(ctx: click.Context, _param: click.Parameter, value: bool) -> | |
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(0), | ||
) | ||
@click.option( | ||
"--until-found", | ||
help="Download most recently added photos until we find x number of " | ||
|
@@ -582,6 +587,7 @@ def main( | |
size: Sequence[AssetVersionSize], | ||
live_photo_size: LivePhotoVersionSize, | ||
recent: Optional[int], | ||
oldest: Optional[int], | ||
until_found: Optional[int], | ||
album: str, | ||
list_albums: bool, | ||
|
@@ -694,6 +700,7 @@ def main( | |
primary_sizes=size, | ||
live_photo_size=live_photo_size, | ||
recent=recent, | ||
oldest=oldest, | ||
until_found=until_found, | ||
album=album, | ||
list_albums=list_albums, | ||
|
@@ -774,6 +781,7 @@ def main( | |
cookie_directory, | ||
size, | ||
recent, | ||
oldest, | ||
until_found, | ||
album, | ||
list_albums, | ||
|
@@ -935,6 +943,7 @@ def download_photo_(counter: Counter, photo: PhotoAsset) -> bool: | |
if file_exists: | ||
counter.increment() | ||
logger.debug("%s already exists", truncate_middle(download_path, 96)) | ||
success = True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That logic change seems to be related to cases outside of oldest as well. Will is break anything? |
||
|
||
if not file_exists: | ||
counter.reset() | ||
|
@@ -1152,6 +1161,7 @@ def core( | |
cookie_directory: str, | ||
primary_sizes: Sequence[AssetVersionSize], | ||
recent: Optional[int], | ||
oldest: Optional[int], | ||
until_found: Optional[int], | ||
album: str, | ||
list_albums: bool, | ||
|
@@ -1289,6 +1299,13 @@ def core( | |
photos_count = recent | ||
photos_enumerator = itertools.islice(photos_enumerator, recent) | ||
|
||
# Optional: Only download the x oldest photos. | ||
if oldest is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add tests for new functionality. That will ensure this feature is not broken with other code changes. |
||
photos_count = oldest | ||
total_photos = len(photos_enumerator) | ||
start = total_photos - oldest | ||
photos_enumerator = itertools.islice(photos_enumerator, start, total_photos) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am curious how that works on large collections in iCloud.com. I think we are processing images as a stream and any filtering is done on a fly instead of memory. |
||
|
||
if until_found is not None: | ||
photos_count = None | ||
# ensure photos iterator doesn't have a known length | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What params cannot be used with
--oldest
? I think at least--recent
. Need to check for invalid combination of params.