Skip to content

Commit

Permalink
Protect exif.get(date fiels) as some old mp4 may return ContentCreati…
Browse files Browse the repository at this point in the history
…onDate as YYYY (eg. 2014) which is converted to int, causing re.match(pattern, dt) to fail.
  • Loading branch information
oPromessa committed Sep 20, 2024
1 parent a6e4d5e commit 5b62238
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions osxphotos/exifutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def get_exif_date_time_offset(

for dt_str in time_fields:
dt = exif.get(dt_str)
# Some old mp4 may return ContentCreationDate as YYYY (eg. 2014) which
# is converted to int causing re.match(pattern, dt) to fail.
dt = str(dt) if isinstance(dt, int) else dt
if dt and dt_str in {"IPTC:DateCreated", "DateCreated"}:
# also need time
time_ = exif.get("IPTC:TimeCreated") or exif.get("TimeCreated")
Expand Down

0 comments on commit 5b62238

Please sign in to comment.