From 5c39f7e57acea7bc5b007d4e69e9301ecf2cb410 Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Sun, 24 Mar 2019 15:26:55 +0000 Subject: [PATCH] old photo publish date for phots that were published somewhere in the past but I don't have an exact date for them --- nasg.py | 19 ++++++++++++++++++- settings.py | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/nasg.py b/nasg.py index f574156..9d5a52b 100644 --- a/nasg.py +++ b/nasg.py @@ -607,7 +607,15 @@ class Singular(MarkdownDoc): @property def published(self): - return arrow.get(self.meta.get('published')) + # ok, so here's a hack: because I have no idea when my older photos + # were actually published, any photo from before 2014 will have + # the EXIF createdate as publish date + pub = arrow.get(self.meta.get('published')) + if self.is_photo: + maybe = arrow.get(self.photo.exif.get('CreateDate')) + if maybe.year < settings.photo.earlyyears: + pub = maybe + return pub @property def is_reply(self): @@ -1399,6 +1407,15 @@ class WebImage(object): logger.info("writing %s", self.fpath) thumb.save(file=f) + # n, e = os.path.splitext(os.path.basename(self.fpath)) + # webppath = self.fpath.replace(e, '.webp') + # with open(webppath, 'wb') as f: + # logger.info("writing %s", webppath) + # thumb.format = 'webp' + # thumb.compression_quality = 88 + # thumb.save(file=f) + + class PHPFile(object): @property diff --git a/settings.py b/settings.py index 8bc2131..4811e58 100644 --- a/settings.py +++ b/settings.py @@ -169,6 +169,7 @@ photo = struct({ 720: '', 1280: '_b', }, + 'earlyyears': 2014 }) tmpdir = os.path.join(gettempdir(),'nasg')