Use other timestamp for videos.

Easier to manipulate timestamp via exiftool this way.
This commit is contained in:
Joachim Tingvold 2018-11-11 04:22:15 +01:00
parent 1cc1ec02aa
commit 5cbc3f31e3
2 changed files with 112 additions and 97 deletions

View File

@ -273,8 +273,21 @@ class Photo(object):
self._attributes["rotate"] = s["tags"]["rotate"] self._attributes["rotate"] = s["tags"]["rotate"]
if original: if original:
self._attributes["originalSize"] = (int(s["width"]), int(s["height"])) self._attributes["originalSize"] = (int(s["width"]), int(s["height"]))
# we break, because a video can contain several streams
# this way we only get/use values from the first stream
break break
# use time from EXIF (rather than file creation)
if info['format']['tags']['creation_time']:
# we have time modifiable via exif
# lets use this
try:
self._attributes["videoCreateDate"] = datetime.strptime(info['format']['tags']['creation_time'], '%Y-%m-%d %H:%M:%S')
except KeyboardInterrupt:
raise
except TypeError:
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:
@ -518,7 +531,9 @@ 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 "dateTimeOriginal" in self._attributes: if "videoCreateDate" in self._attributes:
correct_date = self._attributes["videoCreateDate"]
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:
correct_date = self._attributes["dateTime"] correct_date = self._attributes["dateTime"]