Browse Source

startup: fix "read_exif_datetime_original"

https://git.hammerle.me/fphammerle/setup/commit/47bb9ac8e2eb4919bd6796a622f4ec2a6cc0c13e
Fabian Peter Hammerle 2 weeks ago
parent
commit
713aea1721
1 changed files with 4 additions and 1 deletions
  1. 4 1
      profile_default/startup/init.py

+ 4 - 1
profile_default/startup/init.py

@@ -49,7 +49,10 @@ def read_exif_datetime_original(path: str) -> datetime.datetime:
     with pathlib.Path(path).open("rb") as file:
         tags = exifread.process_file(file)
         return dateutil.parser.parse(
-            tags["EXIF DateTimeOriginal"].values
+            # https://web.archive.org/web/20240609164044/https://github.com/dateutil/dateutil/issues/271
+            datetime.datetime.strptime(
+                tags["EXIF DateTimeOriginal"].values, "%Y:%m:%d %H:%M:%S"
+            ).isoformat()
             + "."
             + tags["EXIF SubSecTimeOriginal"].values
             + tags["EXIF OffsetTimeOriginal"].values