[postprocessor:exec] implement archive options (#3584)

This commit is contained in:
Mike Fährmann
2023-02-01 13:57:16 +01:00
parent 489c51cecc
commit 78d3960a31
4 changed files with 63 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2019-2022 Mike Fährmann
# Copyright 2019-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
@@ -83,28 +83,7 @@ class MetadataPP(PostProcessor):
events = events.split(",")
job.register_hooks({event: self.run for event in events}, options)
archive = options.get("archive")
if archive:
extr = job.extractor
archive = util.expand_path(archive)
archive_format = (
options.get("archive-prefix", extr.category) +
options.get("archive-format", "_MD_" + extr.archive_fmt))
try:
if "{" in archive:
archive = formatter.parse(archive).format_map(
job.pathfmt.kwdict)
self.archive = util.DownloadArchive(
archive, archive_format, "_archive_metadata")
except Exception as exc:
self.log.warning(
"Failed to open download archive at '%s' ('%s: %s')",
archive, exc.__class__.__name__, exc)
else:
self.log.debug("Using download archive '%s'", archive)
else:
self.archive = None
self._init_archive(job, options, "_MD_")
self.mtime = options.get("mtime")
self.omode = options.get("open", omode)
self.encoding = options.get("encoding", "utf-8")