From ac67ef23846fb2a35211be8b63f5201a5567c68e Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Mon, 2 May 2022 07:54:39 -0700 Subject: [PATCH] Added confirmation for timewarp, #677 --- osxphotos/cli/timewarp.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/osxphotos/cli/timewarp.py b/osxphotos/cli/timewarp.py index 78235fab..bb47692b 100644 --- a/osxphotos/cli/timewarp.py +++ b/osxphotos/cli/timewarp.py @@ -218,6 +218,11 @@ For this to work, you'll need to install the third-party exiftool (https://exift `osxphotos timewarp --compare-exif` +**Read the date/time/timezone from the photos' original EXIF metadata to update the photos' date/time/timezone; +if the EXIF data is missing, use the file modification date/time; show verbose output** + +`osxphotos timewarp --pull-exif --use-file-time --verbose` + """ ), width=formatter.width, @@ -458,6 +463,8 @@ def timewarp( if add_to_album and not compare_exif: raise click.UsageError("--add-to-album must be used with --compare-exif.") + # configure colored rich output + # TODO: this is all a little hacky, find a better way to do this color_theme = get_theme(theme) verbose_ = verbose_print( verbose, @@ -468,7 +475,6 @@ def timewarp( file=output_file, ) # set console for rich_echo to be same as for verbose_ - # TODO: this is a hack, find a better way to do this terminal_width = terminal_width or (1000 if output_file else None) if output_file: set_rich_console(Console(file=output_file, width=terminal_width)) @@ -509,6 +515,20 @@ def timewarp( ) sys.exit(1) + # confirm with user before proceeding + click.confirm( + rich_text( + f":warning-emoji: About to process [num]{len(photos)}[/] {pluralize(len(photos), 'photo', 'photos')} with timewarp. " + "This will directly modify your Photos library database using undocumented features. " + "While this feature has been well tested, it is possible this may " + "corrupt, damage, or destroy your Photos library. Use at your own caution. " + "It is strongly recommended you make a backup of your Photos library before using the timewarp command " + "(for example, using Time Machine).\n\n" + "Proceed with timewarp?" + ), + abort=True, + ) + update_photo_date_time_ = partial( update_photo_date_time, date=date,