Skip to content

Commit 8aafc65

Browse files
enable timezone detection by param
better name permissions rollback permissions
1 parent 8591be3 commit 8aafc65

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

phockup.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ def parse_args(args=sys.argv[1:]):
127127
""",
128128
)
129129

130+
parser.add_argument(
131+
'--timezone-detection',
132+
action='store_true',
133+
help="""\
134+
Enables time zone detection. In case your times are off by time zone, this might fix it.
135+
""",
136+
)
137+
130138
parser.add_argument(
131139
'-c',
132140
'--max-concurrency',
@@ -391,7 +399,8 @@ def main(options):
391399
output_prefix=options.output_prefix,
392400
output_suffix=options.output_suffix,
393401
from_date=options.from_date,
394-
to_date=options.to_date
402+
to_date=options.to_date,
403+
timezone_detection=options.timezone_detection,
395404
)
396405

397406

src/date.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def build(date_object):
3434
date_object['minute'] if date_object.get('minute') else 0,
3535
date_object['second'] if date_object.get('second') else 0)
3636

37-
def from_exif(self, exif, timestamp=None, user_regex=None, date_field=None):
37+
def from_exif(self, exif, timestamp=None, user_regex=None, date_field=None, timezone_detection=False):
3838
if date_field:
3939
keys = date_field.split()
4040
else:
@@ -59,7 +59,7 @@ def from_exif(self, exif, timestamp=None, user_regex=None, date_field=None):
5959
parsed_date = {'date': None, 'subseconds': ''}
6060

6161
# apply TimeZone if available
62-
if exif.get('TimeZone') is not None and isinstance(exif['TimeZone'], str):
62+
if timezone_detection is True and exif.get('TimeZone') is not None and isinstance(exif['TimeZone'], str):
6363
timezonedata = exif['TimeZone'].split(':')
6464
if timezonedata and len(timezonedata) == 2:
6565
parsed_date['date'] = parsed_date['date'] + timedelta(hours=int(timezonedata[0]), minutes=int(timezonedata[1]))

src/phockup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def __init__(self, input_dir, output_dir, **args):
5555
self.dry_run = args.get('dry_run', False)
5656
self.progress = args.get('progress', False)
5757
self.max_depth = args.get('max_depth', -1)
58+
self.timezone_detection = args.get('timezone_detection', False)
5859
# default to concurrency of one to retain existing behavior
5960
self.max_concurrency = args.get("max_concurrency", 1)
6061

@@ -386,7 +387,7 @@ def get_file_name_and_path(self, filename):
386387
date = None
387388
if target_file_type in ['image', 'video']:
388389
date = Date(filename).from_exif(exif_data, self.timestamp, self.date_regex,
389-
self.date_field)
390+
self.date_field, self.timezone_detection)
390391
output = self.get_output_dir(date)
391392
target_file_name = self.get_file_name(filename, date)
392393
if not self.original_filenames:

0 commit comments

Comments
 (0)