Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion phockup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
)


Expand Down
4 changes: 2 additions & 2 deletions src/date.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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]))
Expand Down
3 changes: 2 additions & 1 deletion src/phockup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down
Loading