Fixed logical error after introducing timestamp of videos from

EXIF data. Previous logic dictated that all timestamps should
live within attribute name starting with "dateTime", which caused
issues when re-scanning an album (complaining about corrupt cache).
Renamed variable and all is good.
patches
Joachim Tingvold 2018-11-15 01:40:22 +01:00
parent 6029f92aad
commit 3b9f64b057
1 changed files with 7 additions and 5 deletions

View File

@ -281,18 +281,18 @@ class Photo(object):
try: try:
info['format']['tags']['creation_time'] info['format']['tags']['creation_time']
except KeyError: except KeyError:
self._attributes["videoCreateDate"] = self._attributes["dateTimeFile"] pass
else: else:
# we have time modifiable via exif # we have time modifiable via exif
# lets use this # lets use this
try: try:
self._attributes["videoCreateDate"] = datetime.strptime(info['format']['tags']['creation_time'], '%Y-%m-%d %H:%M:%S') self._attributes["dateTimeVideo"] = datetime.strptime(info['format']['tags']['creation_time'], '%Y-%m-%d %H:%M:%S')
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
except TypeError: except TypeError:
pass pass
def _photo_thumbnail(self, original_path, thumb_path, size, square=False): def _photo_thumbnail(self, original_path, thumb_path, size, square=False):
try: try:
image = Image.open(original_path) image = Image.open(original_path)
@ -545,8 +545,8 @@ class Photo(object):
correct_date = None; correct_date = None;
if not self.is_valid: if not self.is_valid:
correct_date = datetime(1900, 1, 1) correct_date = datetime(1900, 1, 1)
if "videoCreateDate" in self._attributes: if "dateTimeVideo" in self._attributes:
correct_date = self._attributes["videoCreateDate"] correct_date = self._attributes["dateTimeVideo"]
elif "dateTimeOriginal" in self._attributes: elif "dateTimeOriginal" in self._attributes:
correct_date = self._attributes["dateTimeOriginal"] correct_date = self._attributes["dateTimeOriginal"]
elif "dateTime" in self._attributes: elif "dateTime" in self._attributes:
@ -557,9 +557,11 @@ class Photo(object):
def __cmp__(self, other): def __cmp__(self, other):
date_compare = cmp(self.date, other.date) date_compare = cmp(self.date, other.date)
if date_compare == 0: if date_compare == 0:
return cmp(self.name, other.name) return cmp(self.name, other.name)
return date_compare return date_compare
@property @property
def attributes(self): def attributes(self):
return self._attributes return self._attributes