diff options
| author | 2022-07-16 00:39:30 -0400 | |
|---|---|---|
| committer | 2022-07-16 00:39:30 -0400 | |
| commit | 5d92ac909e26a3373506cc4fce1dd465ea649942 (patch) | |
| tree | 2be8b9ea40d04c87b375fbe3b36dce641dce5c3a /gallery_dl/postprocessor/mtime.py | |
| parent | 278a4319a00485410c1af8f0788a539f34c42696 (diff) | |
| parent | ae2a0f5622beaa6f402526f8a7b939419283a090 (diff) | |
Update upstream source from tag 'upstream/1.22.4'
Update to upstream version '1.22.4'
with Debian dir 740824d4b4f6e11c0a3280aa45c483d7116cf56d
Diffstat (limited to 'gallery_dl/postprocessor/mtime.py')
| -rw-r--r-- | gallery_dl/postprocessor/mtime.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/gallery_dl/postprocessor/mtime.py b/gallery_dl/postprocessor/mtime.py index 3f8d90a..ea61b7b 100644 --- a/gallery_dl/postprocessor/mtime.py +++ b/gallery_dl/postprocessor/mtime.py @@ -9,7 +9,7 @@ """Use metadata as file modification time""" from .common import PostProcessor -from .. import text, util +from .. import text, util, formatter from datetime import datetime @@ -17,7 +17,12 @@ class MtimePP(PostProcessor): def __init__(self, job, options): PostProcessor.__init__(self, job) - self.key = options.get("key", "date") + value = options.get("value") + if value: + self._get = formatter.parse(value, None, util.identity).format_map + else: + key = options.get("key", "date") + self._get = lambda kwdict: kwdict.get(key) events = options.get("event") if events is None: @@ -27,7 +32,7 @@ class MtimePP(PostProcessor): job.register_hooks({event: self.run for event in events}, options) def run(self, pathfmt): - mtime = pathfmt.kwdict.get(self.key) + mtime = self._get(pathfmt.kwdict) pathfmt.kwdict["_mtime"] = ( util.datetime_to_timestamp(mtime) if isinstance(mtime, datetime) else |
