support format string replacement fields in archive paths

(closes #985)
pull/997/head
Mike Fährmann 4 years ago
parent 2b8d57f0ab
commit 5912727b88
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -368,13 +368,19 @@ extractor.*.archive
=========== ===== =========== =====
Type |Path|_ Type |Path|_
Default ``null`` Default ``null``
Example ``"$HOME/.archives/{category}.sqlite3"``
Description File to store IDs of downloaded files in. Downloads of files Description File to store IDs of downloaded files in. Downloads of files
already recorded in this archive file will be skipped_. already recorded in this archive file will be
`skipped <extractor.*.skip_>`__.
The resulting archive file is not a plain text file but an SQLite3 The resulting archive file is not a plain text file but an SQLite3
database, as either lookup operations are significantly faster or database, as either lookup operations are significantly faster or
memory requirements are significantly lower when the memory requirements are significantly lower when the
amount of stored IDs gets reasonably large. amount of stored IDs gets reasonably large.
Note: archive paths support regular `format string`_ replacements,
but be aware that using external inputs for building local paths
may pose a security risk.
=========== ===== =========== =====
@ -2265,7 +2271,6 @@ Description An object with the ``name`` of a post-processor and its options.
.. |strptime| replace:: strftime() and strptime() Behavior .. |strptime| replace:: strftime() and strptime() Behavior
.. _base-directory: `extractor.*.base-directory`_ .. _base-directory: `extractor.*.base-directory`_
.. _skipped: `extractor.*.skip`_
.. _date-format: `extractor.*.date-format`_ .. _date-format: `extractor.*.date-format`_
.. _deviantart.metadata: extractor.deviantart.metadata_ .. _deviantart.metadata: extractor.deviantart.metadata_

@ -397,6 +397,8 @@ class DownloadJob(Job):
if archive: if archive:
path = util.expand_path(archive) path = util.expand_path(archive)
try: try:
if "{" in path:
path = util.Formatter(path).format_map(kwdict)
self.archive = util.DownloadArchive(path, self.extractor) self.archive = util.DownloadArchive(path, self.extractor)
except Exception as exc: except Exception as exc:
self.extractor.log.warning( self.extractor.log.warning(

Loading…
Cancel
Save