diff options
| author | 2023-03-13 02:07:55 -0400 | |
|---|---|---|
| committer | 2023-03-13 02:07:55 -0400 | |
| commit | c5965a4d7650b7e935f630e40d883801967f7bcc (patch) | |
| tree | 2223d05254347c00a339e4476d3daea7b2624fb4 /gallery_dl/postprocessor/common.py | |
| parent | baa8beeeb8bbe097f0b33d8c029fbd299253efa0 (diff) | |
| parent | 10987f08f8b6c510ba64f4b42d95ba67eec6e5b0 (diff) | |
Update upstream source from tag 'upstream/1.25.0'
Update to upstream version '1.25.0'
with Debian dir c2275e6e216e12115941d12f2b939d3f1a36436e
Diffstat (limited to 'gallery_dl/postprocessor/common.py')
| -rw-r--r-- | gallery_dl/postprocessor/common.py | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/gallery_dl/postprocessor/common.py b/gallery_dl/postprocessor/common.py index ef211e6..c28d060 100644 --- a/gallery_dl/postprocessor/common.py +++ b/gallery_dl/postprocessor/common.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2018-2020 Mike Fährmann +# Copyright 2018-2023 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 @@ -8,13 +8,42 @@ """Common classes and constants used by postprocessor modules.""" +from .. import util, formatter + class PostProcessor(): """Base class for postprocessors""" def __init__(self, job): - name = self.__class__.__name__[:-2].lower() - self.log = job.get_logger("postprocessor." + name) + self.name = self.__class__.__name__[:-2].lower() + self.log = job.get_logger("postprocessor." + self.name) def __repr__(self): return self.__class__.__name__ + + def _init_archive(self, job, options, prefix=None): + archive = options.get("archive") + if archive: + extr = job.extractor + archive = util.expand_path(archive) + if not prefix: + prefix = "_" + self.name.upper() + "_" + archive_format = ( + options.get("archive-prefix", extr.category) + + options.get("archive-format", prefix + extr.archive_fmt)) + try: + if "{" in archive: + archive = formatter.parse(archive).format_map( + job.pathfmt.kwdict) + self.archive = util.DownloadArchive( + archive, archive_format, + options.get("archive-pragma"), + "_archive_" + self.name) + except Exception as exc: + self.log.warning( + "Failed to open %s archive at '%s' ('%s: %s')", + self.name, archive, exc.__class__.__name__, exc) + else: + self.log.debug("Using %s archive '%s'", self.name, archive) + else: + self.archive = None |
