diff options
| author | 2019-07-20 05:51:48 -0400 | |
|---|---|---|
| committer | 2019-07-20 05:51:48 -0400 | |
| commit | 38accf3526a88643ca2a7dbb6a0356f09cfeb6b8 (patch) | |
| tree | 7bd7dd9f7de7735d13d8d97140e4de1698b44728 /gallery_dl/postprocessor | |
| parent | 0d3bf12093addd340346bc053f2c8fecf45b30b6 (diff) | |
| parent | 2a63a9c9b7032a76894c48ac4d9cea732fcaee49 (diff) | |
Update upstream source from tag 'upstream/1.9.0'
Update to upstream version '1.9.0'
with Debian dir e4e6deed2c5d767438ea4528bc329c28c5e72178
Diffstat (limited to 'gallery_dl/postprocessor')
| -rw-r--r-- | gallery_dl/postprocessor/__init__.py | 18 | ||||
| -rw-r--r-- | gallery_dl/postprocessor/mtime.py | 27 |
2 files changed, 38 insertions, 7 deletions
diff --git a/gallery_dl/postprocessor/__init__.py b/gallery_dl/postprocessor/__init__.py index 093f8e0..e63d442 100644 --- a/gallery_dl/postprocessor/__init__.py +++ b/gallery_dl/postprocessor/__init__.py @@ -15,6 +15,7 @@ modules = [ "classify", "exec", "metadata", + "mtime", "ugoira", "zip", ] @@ -27,15 +28,18 @@ def find(name): try: return _cache[name] except KeyError: - klass = None + pass + + klass = None + if name in modules: # prevent unwanted imports try: - if name in modules: # prevent unwanted imports - module = importlib.import_module("." + name, __package__) - klass = module.__postprocessor__ - except (ImportError, AttributeError, TypeError): + module = importlib.import_module("." + name, __package__) + except ImportError: pass - _cache[name] = klass - return klass + else: + klass = module.__postprocessor__ + _cache[name] = klass + return klass # -------------------------------------------------------------------- diff --git a/gallery_dl/postprocessor/mtime.py b/gallery_dl/postprocessor/mtime.py new file mode 100644 index 0000000..03d2f11 --- /dev/null +++ b/gallery_dl/postprocessor/mtime.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +# Copyright 2019 Mike Fährmann +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. + +"""Use metadata as file modification time""" + +from .common import PostProcessor +from ..text import parse_int + + +class MtimePP(PostProcessor): + + def __init__(self, pathfmt, options): + PostProcessor.__init__(self) + self.key = options.get("key", "date") + + def run(self, pathfmt): + mtime = pathfmt.keywords.get(self.key) + ts = getattr(mtime, "timestamp", None) + pathfmt.keywords["_mtime"] = ts() if ts else parse_int(mtime) + + +__postprocessor__ = MtimePP |
