diff --git a/phockup.py b/phockup.py index c432f57..fe08958 100755 --- a/phockup.py +++ b/phockup.py @@ -127,6 +127,14 @@ def parse_args(args=sys.argv[1:]): """, ) + parser.add_argument( + '--timezone-detection', + action='store_true', + help="""\ + Enables time zone detection. In case your times are off by time zone, this might fix it. + """, + ) + parser.add_argument( '-c', '--max-concurrency', @@ -391,7 +399,8 @@ def main(options): output_prefix=options.output_prefix, output_suffix=options.output_suffix, from_date=options.from_date, - to_date=options.to_date + to_date=options.to_date, + timezone_detection=options.timezone_detection, ) diff --git a/src/date.py b/src/date.py index 0454343..d3c107b 100644 --- a/src/date.py +++ b/src/date.py @@ -34,7 +34,7 @@ def build(date_object): date_object['minute'] if date_object.get('minute') else 0, date_object['second'] if date_object.get('second') else 0) - def from_exif(self, exif, timestamp=None, user_regex=None, date_field=None): + def from_exif(self, exif, timestamp=None, user_regex=None, date_field=None, timezone_detection=False): if date_field: keys = date_field.split() else: @@ -59,7 +59,7 @@ def from_exif(self, exif, timestamp=None, user_regex=None, date_field=None): parsed_date = {'date': None, 'subseconds': ''} # apply TimeZone if available - if exif.get('TimeZone') is not None and isinstance(exif['TimeZone'], str): + if timezone_detection is True and exif.get('TimeZone') is not None and isinstance(exif['TimeZone'], str): timezonedata = exif['TimeZone'].split(':') if timezonedata and len(timezonedata) == 2: parsed_date['date'] = parsed_date['date'] + timedelta(hours=int(timezonedata[0]), minutes=int(timezonedata[1])) diff --git a/src/phockup.py b/src/phockup.py index 5add1cd..60a6063 100755 --- a/src/phockup.py +++ b/src/phockup.py @@ -55,6 +55,7 @@ def __init__(self, input_dir, output_dir, **args): self.dry_run = args.get('dry_run', False) self.progress = args.get('progress', False) self.max_depth = args.get('max_depth', -1) + self.timezone_detection = args.get('timezone_detection', False) # default to concurrency of one to retain existing behavior self.max_concurrency = args.get("max_concurrency", 1) @@ -386,7 +387,7 @@ def get_file_name_and_path(self, filename): date = None if target_file_type in ['image', 'video']: date = Date(filename).from_exif(exif_data, self.timestamp, self.date_regex, - self.date_field) + self.date_field, self.timezone_detection) output = self.get_output_dir(date) target_file_name = self.get_file_name(filename, date) if not self.original_filenames: