Fix get_date_from_string function

This commit is contained in:
Cédric Leporcq 2022-07-19 19:41:43 +02:00
parent eee3c71f6a
commit cdfa408206
2 changed files with 4 additions and 1 deletions

View File

@ -143,6 +143,9 @@ class FPath:
# Delete separator
if re.search('^[-_ .]', part):
part = part[1:]
if part != stem:
# We only want to match first result
break
elif item == 'date':
date = metadata['date_media']
# early morning photos can be grouped with previous day

View File

@ -69,7 +69,7 @@ def get_date_regex(user_regex=None):
# regex to match date format type %Y%m%d, %y%m%d, %d%m%Y,
# etc...
'a': re.compile(
r'.*[_-]?(?P<year>\d{4})[_-]?(?P<month>\d{2})[_-]?(?P<day>\d{2})[_-]?(?P<hour>\d{2})[_-]?(?P<minute>\d{2})[_-]?(?P<second>\d{2})'
r'[-_./](?P<year>\d{4})[-_.]?(?P<month>\d{2})[-_.]?(?P<day>\d{2})[-_.]?(?P<hour>\d{2})[-_.]?(?P<minute>\d{2})[-_.]?(?P<second>\d{2})'
),
'b': re.compile(
r'[-_./](?P<year>\d{4})[-_.]?(?P<month>\d{2})[-_.]?(?P<day>\d{2})[-_./]'