Add exception handling for wrong date
This commit is contained in:
parent
c6a1e69088
commit
68aacc1926
1 changed files with 5 additions and 1 deletions
|
@ -125,7 +125,11 @@ class image_classifier:
|
|||
original_date = self.metadata['Exif.Photo.DateTimeOriginal'].value
|
||||
self._log.debug(f"File creation time: {original_date} \
|
||||
(type: {type(original_date)})")
|
||||
try:
|
||||
folder_date = original_date.strftime('%Y.%m.%d')
|
||||
except Exception as error:
|
||||
self._log.error(f"Failed to convert EXIF information about date '{original_date}'.")
|
||||
folder_date = 'unknown-time'
|
||||
if folder_date == 'unknown-time':
|
||||
match = re.search(r'(?P<year>20[0-9]{2})[\-/\._]?\
|
||||
(?P<month>[0-1]?[0-9])[\-/\._]?(?P<day>[0-3]?[0-9])', filename)
|
||||
|
|
Loading…
Reference in a new issue