From 22e87223a3e1b4063043fb84fdf2d05cc5eeb5ee Mon Sep 17 00:00:00 2001 From: Cedric Leporcq Date: Tue, 19 Jul 2022 21:45:11 +0200 Subject: [PATCH] Add 60s tolerance when compare date_original, date_filename and date_created --- ordigi/media.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/ordigi/media.py b/ordigi/media.py index e1999dc..ac8544e 100644 --- a/ordigi/media.py +++ b/ordigi/media.py @@ -370,18 +370,20 @@ class Media(ReadExif): file_modify_date = self.metadata['file_modify_date'] if self.metadata['date_original']: if date_filename and date_filename != date_original: - self.log.warning( - f"{filename} time mark is different from {date_original}" - ) - if self.interactive: - # Ask for keep date taken, filename time, or neither - choices = [ - (f"date original:'{date_original}'", date_original), - (f"date filename:'{date_filename}'", date_filename), - ("custom", None), - ] - default = f'{date_original}' - return self._get_date_media_interactive(choices, default) + timedelta = abs(date_original - date_filename) + if timedelta.total_seconds() > 60: + self.log.warning( + f"{filename} time mark is different from {date_original}" + ) + if self.interactive: + # Ask for keep date taken, filename time, or neither + choices = [ + (f"date original:'{date_original}'", date_original), + (f"date filename:'{date_filename}'", date_filename), + ("custom", None), + ] + default = f'{date_original}' + return self._get_date_media_interactive(choices, default) return self.metadata['date_original'] @@ -392,9 +394,11 @@ class Media(ReadExif): f"use date from filename:{date_filename} for {self.file_path}" ) if date_created and date_filename > date_created: - self.log.warning( - f"{filename} time mark is more recent than {date_created}" - ) + timedelta = abs(date_created - date_filename) + if timedelta.total_seconds() > 60: + self.log.warning( + f"{filename} time mark is more recent than {date_created}" + ) return date_created if self.interactive: