diff --git a/docs/configuration.rst b/docs/configuration.rst index c22bd8c2..b0d09b7f 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -166,6 +166,8 @@ Description extractor.*.parent-metadata --------------------------- +extractor.*.metadata-parent +--------------------------- Type * ``bool`` * ``string`` @@ -642,12 +644,12 @@ Description `format strings`_. +extractor.*.metadata-url +------------------------ extractor.*.url-metadata ------------------------ Type ``string`` -Default - ``null`` Description Insert a file's download URL into its metadata dictionary as the given name. @@ -658,12 +660,12 @@ Description with a ``metadata`` post processor, etc. +extractor.*.metadata-path +------------------------- extractor.*.path-metadata ------------------------- Type ``string`` -Default - ``null`` Description Insert a reference to the current `PathFormat `__ @@ -673,12 +675,12 @@ Description to access the current file's filename as ``"{gdl_path.filename}"``. +extractor.*.metadata-http +------------------------- extractor.*.http-metadata ------------------------- Type ``string`` -Default - ``null`` Description Insert an ``object`` containing a file's HTTP headers and ``filename``, ``extension``, and ``date`` parsed from them @@ -689,12 +691,12 @@ Description and its parsed form as ``"{gdl_http[date]}"``. +extractor.*.metadata-version +---------------------------- extractor.*.version-metadata ---------------------------- Type ``string`` -Default - ``null`` Description Insert an ``object`` containing gallery-dl's version info into metadata dictionaries as the given name. diff --git a/gallery_dl/extractor/common.py b/gallery_dl/extractor/common.py index 3bec4248..f3784272 100644 --- a/gallery_dl/extractor/common.py +++ b/gallery_dl/extractor/common.py @@ -78,6 +78,12 @@ class Extractor(): def config(self, key, default=None): return config.interpolate(self._cfgpath, key, default) + def config2(self, key, key2, default=None, sentinel=util.SENTINEL): + value = self.config(key, sentinel) + if value is not sentinel: + return value + return self.config(key2, default) + def config_deprecated(self, key, deprecated, default=None, sentinel=util.SENTINEL, history=set()): value = self.config(deprecated, sentinel) diff --git a/gallery_dl/job.py b/gallery_dl/job.py index 1e80cbf3..9aad226f 100644 --- a/gallery_dl/job.py +++ b/gallery_dl/job.py @@ -87,11 +87,10 @@ class Job(): extr.category = pextr.category extr.subcategory = pextr.subcategory - self.metadata_url = extr.config("url-metadata") - self.metadata_http = extr.config("http-metadata") - - version_info = extr.config("version-metadata") - metadata_path = extr.config("path-metadata") + self.metadata_url = extr.config2("metadata-url", "url-metadata") + self.metadata_http = extr.config2("metadata-http", "http-metadata") + metadata_path = extr.config2("metadata-path", "path-metadata") + metadata_version = extr.config2("metadata-version", "version-metadata") # user-supplied metadata kwdict = extr.config("keywords") @@ -99,8 +98,8 @@ class Job(): self.kwdict.update(kwdict) if metadata_path: self.kwdict[metadata_path] = path_proxy - if version_info: - self.kwdict[version_info] = { + if metadata_version: + self.kwdict[metadata_version] = { "version" : version.__version__, "is_executable" : util.EXECUTABLE, "current_git_head": util.git_head() @@ -375,7 +374,7 @@ class DownloadJob(Job): else: extr._parentdir = pextr._parentdir - pmeta = pextr.config("parent-metadata") + pmeta = pextr.config2("parent-metadata", "metadata-parent") if pmeta: if isinstance(pmeta, str): data = self.kwdict.copy()