aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/postprocessor
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2019-07-20 05:51:44 -0400
committerLibravatarUnit 193 <unit193@ubuntu.com>2019-07-20 05:51:44 -0400
commit2a63a9c9b7032a76894c48ac4d9cea732fcaee49 (patch)
tree3d5f633ff69cd393036a3dabc4d4533c8484f9ad /gallery_dl/postprocessor
parent195c45911e79c33cf0bb986721365fb06df5a153 (diff)
New upstream version 1.9.0upstream/1.9.0
Diffstat (limited to 'gallery_dl/postprocessor')
-rw-r--r--gallery_dl/postprocessor/__init__.py18
-rw-r--r--gallery_dl/postprocessor/mtime.py27
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