From 2a63a9c9b7032a76894c48ac4d9cea732fcaee49 Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Sat, 20 Jul 2019 05:51:44 -0400 Subject: New upstream version 1.9.0 --- gallery_dl/postprocessor/__init__.py | 18 +++++++++++------- gallery_dl/postprocessor/mtime.py | 27 +++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 gallery_dl/postprocessor/mtime.py (limited to 'gallery_dl/postprocessor') 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 -- cgit v1.2.3