mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 11:09:26 +00:00
added regular expression to datetime conversion
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import json
|
import json
|
||||||
@@ -115,7 +116,11 @@ def get_image_info(item: str, folder: str) -> Dict[str, Any]:
|
|||||||
if newtuple:
|
if newtuple:
|
||||||
content = newtuple
|
content = newtuple
|
||||||
if tag in ["DateTime", "DateTimeOriginal", "DateTimeDigitized"]:
|
if tag in ["DateTime", "DateTimeOriginal", "DateTimeDigitized"]:
|
||||||
|
epr = r'\d{4}:\d{2}:\d{2} \d{2}:\d{2}:\d{2}'
|
||||||
|
if re.match(epr, content):
|
||||||
content = datetime.strptime(content, "%Y:%m:%d %H:%M:%S").strftime("%Y-%m-%d %H:%M:%S")
|
content = datetime.strptime(content, "%Y:%m:%d %H:%M:%S").strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
else:
|
||||||
|
content = None
|
||||||
exifdata[tag] = content
|
exifdata[tag] = content
|
||||||
if "Orientation" in exifdata and exifdata["Orientation"] in [6, 8]:
|
if "Orientation" in exifdata and exifdata["Orientation"] in [6, 8]:
|
||||||
logger.info("image is rotated", extra={"file": file})
|
logger.info("image is rotated", extra={"file": file})
|
||||||
|
|||||||
Reference in New Issue
Block a user