From 441de711dc664b244d599c81e3dd1bcd9b2e55a0 Mon Sep 17 00:00:00 2001 From: Ag Primatic Date: Sat, 23 May 2020 18:15:45 -0400 Subject: [PATCH] Catch illegal timestamp value When using this on my Photos database, it threw a ValueError. I wrapped the fromtimestamp() call in a try block so that it would continue with the oldest date allowable. --- osxphotos/photosdb/photosdb.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osxphotos/photosdb/photosdb.py b/osxphotos/photosdb/photosdb.py index 4828b3c3..67f62feb 100644 --- a/osxphotos/photosdb/photosdb.py +++ b/osxphotos/photosdb/photosdb.py @@ -805,7 +805,11 @@ class PhotosDB: else: self._dbphotos[uuid]["lastmodifieddate"] = None - self._dbphotos[uuid]["imageDate"] = datetime.fromtimestamp(row[5] + td) + try: + self._dbphotos[uuid]["imageDate"] = datetime.fromtimestamp(row[5] + td) + except ValueError: + self._dbphotos[uuid]["imageDate"] = datetime.date(1970,1,1) + self._dbphotos[uuid]["mainRating"] = row[6] self._dbphotos[uuid]["hasAdjustments"] = row[7] self._dbphotos[uuid]["hasKeywords"] = row[8]