From 55e01632ca0993143c7cd6d460776502cccb62fb Mon Sep 17 00:00:00 2001 From: Tim AtLee Date: Sat, 11 Sep 2021 14:22:40 -0600 Subject: [PATCH] Read Date property from .md for video files --- AUTHORS | 1 + sigal/gallery.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 498f447..50aaa7b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -54,6 +54,7 @@ alphabetical order): - @trapperhoney - @tudacs - Thomas Misilo +- Tim AtLee - Tim Davies - Tobias Preuss - Toke Høiland-Jørgensen (@tohojo) diff --git a/sigal/gallery.py b/sigal/gallery.py index 220c878..51f9ee8 100644 --- a/sigal/gallery.py +++ b/sigal/gallery.py @@ -4,6 +4,7 @@ # Copyright (c) 2015 - François D. # Copyright (c) 2017 - Mate Lakat # Copyright (c) 2018 - Edwin Steele +# Copyright (c) 2021 - Tim AtLee # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to @@ -294,7 +295,6 @@ class Video(Media): def __init__(self, filename, path, settings): super().__init__(filename, path, settings) - self.date = self._get_file_date() if not settings['use_orig'] or not is_valid_html5_video(self.src_ext): video_format = settings['video_format'] @@ -304,6 +304,20 @@ class Video(Media): else: self.mime = get_mime(self.src_ext) + @cached_property + def date(self): + """The date from the Date metadata if available, or from the file date.""" + # If no date is found in the metadata, return the file date. + assetdate = datetime.now() + try: + assetdate = datetime.fromisoformat(self.meta['date'][0]) + except: + self.logger.debug( + "Either self.meta.data was not set, or was in an incorrect format : %s", + self.src_filename) + assetdate = self._get_file_date() + return assetdate + class Album: """Gather all informations on an album.