support 'metadata-*' names for '*-metadata' options
For example, instead of 'url-metadata' it is now also possible to use 'metadata-url' as option name. - metadata-url - metadata-path - metadata-http - metadata-version - metadata-parent
This commit is contained in:
@@ -166,6 +166,8 @@ Description
|
|||||||
|
|
||||||
extractor.*.parent-metadata
|
extractor.*.parent-metadata
|
||||||
---------------------------
|
---------------------------
|
||||||
|
extractor.*.metadata-parent
|
||||||
|
---------------------------
|
||||||
Type
|
Type
|
||||||
* ``bool``
|
* ``bool``
|
||||||
* ``string``
|
* ``string``
|
||||||
@@ -642,12 +644,12 @@ Description
|
|||||||
`format strings`_.
|
`format strings`_.
|
||||||
|
|
||||||
|
|
||||||
|
extractor.*.metadata-url
|
||||||
|
------------------------
|
||||||
extractor.*.url-metadata
|
extractor.*.url-metadata
|
||||||
------------------------
|
------------------------
|
||||||
Type
|
Type
|
||||||
``string``
|
``string``
|
||||||
Default
|
|
||||||
``null``
|
|
||||||
Description
|
Description
|
||||||
Insert a file's download URL into its metadata dictionary as the given name.
|
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.
|
with a ``metadata`` post processor, etc.
|
||||||
|
|
||||||
|
|
||||||
|
extractor.*.metadata-path
|
||||||
|
-------------------------
|
||||||
extractor.*.path-metadata
|
extractor.*.path-metadata
|
||||||
-------------------------
|
-------------------------
|
||||||
Type
|
Type
|
||||||
``string``
|
``string``
|
||||||
Default
|
|
||||||
``null``
|
|
||||||
Description
|
Description
|
||||||
Insert a reference to the current
|
Insert a reference to the current
|
||||||
`PathFormat <https://github.com/mikf/gallery-dl/blob/v1.24.2/gallery_dl/path.py#L27>`__
|
`PathFormat <https://github.com/mikf/gallery-dl/blob/v1.24.2/gallery_dl/path.py#L27>`__
|
||||||
@@ -673,12 +675,12 @@ Description
|
|||||||
to access the current file's filename as ``"{gdl_path.filename}"``.
|
to access the current file's filename as ``"{gdl_path.filename}"``.
|
||||||
|
|
||||||
|
|
||||||
|
extractor.*.metadata-http
|
||||||
|
-------------------------
|
||||||
extractor.*.http-metadata
|
extractor.*.http-metadata
|
||||||
-------------------------
|
-------------------------
|
||||||
Type
|
Type
|
||||||
``string``
|
``string``
|
||||||
Default
|
|
||||||
``null``
|
|
||||||
Description
|
Description
|
||||||
Insert an ``object`` containing a file's HTTP headers and
|
Insert an ``object`` containing a file's HTTP headers and
|
||||||
``filename``, ``extension``, and ``date`` parsed from them
|
``filename``, ``extension``, and ``date`` parsed from them
|
||||||
@@ -689,12 +691,12 @@ Description
|
|||||||
and its parsed form as ``"{gdl_http[date]}"``.
|
and its parsed form as ``"{gdl_http[date]}"``.
|
||||||
|
|
||||||
|
|
||||||
|
extractor.*.metadata-version
|
||||||
|
----------------------------
|
||||||
extractor.*.version-metadata
|
extractor.*.version-metadata
|
||||||
----------------------------
|
----------------------------
|
||||||
Type
|
Type
|
||||||
``string``
|
``string``
|
||||||
Default
|
|
||||||
``null``
|
|
||||||
Description
|
Description
|
||||||
Insert an ``object`` containing gallery-dl's version info into
|
Insert an ``object`` containing gallery-dl's version info into
|
||||||
metadata dictionaries as the given name.
|
metadata dictionaries as the given name.
|
||||||
|
|||||||
@@ -78,6 +78,12 @@ class Extractor():
|
|||||||
def config(self, key, default=None):
|
def config(self, key, default=None):
|
||||||
return config.interpolate(self._cfgpath, key, default)
|
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,
|
def config_deprecated(self, key, deprecated, default=None,
|
||||||
sentinel=util.SENTINEL, history=set()):
|
sentinel=util.SENTINEL, history=set()):
|
||||||
value = self.config(deprecated, sentinel)
|
value = self.config(deprecated, sentinel)
|
||||||
|
|||||||
@@ -87,11 +87,10 @@ class Job():
|
|||||||
extr.category = pextr.category
|
extr.category = pextr.category
|
||||||
extr.subcategory = pextr.subcategory
|
extr.subcategory = pextr.subcategory
|
||||||
|
|
||||||
self.metadata_url = extr.config("url-metadata")
|
self.metadata_url = extr.config2("metadata-url", "url-metadata")
|
||||||
self.metadata_http = extr.config("http-metadata")
|
self.metadata_http = extr.config2("metadata-http", "http-metadata")
|
||||||
|
metadata_path = extr.config2("metadata-path", "path-metadata")
|
||||||
version_info = extr.config("version-metadata")
|
metadata_version = extr.config2("metadata-version", "version-metadata")
|
||||||
metadata_path = extr.config("path-metadata")
|
|
||||||
|
|
||||||
# user-supplied metadata
|
# user-supplied metadata
|
||||||
kwdict = extr.config("keywords")
|
kwdict = extr.config("keywords")
|
||||||
@@ -99,8 +98,8 @@ class Job():
|
|||||||
self.kwdict.update(kwdict)
|
self.kwdict.update(kwdict)
|
||||||
if metadata_path:
|
if metadata_path:
|
||||||
self.kwdict[metadata_path] = path_proxy
|
self.kwdict[metadata_path] = path_proxy
|
||||||
if version_info:
|
if metadata_version:
|
||||||
self.kwdict[version_info] = {
|
self.kwdict[metadata_version] = {
|
||||||
"version" : version.__version__,
|
"version" : version.__version__,
|
||||||
"is_executable" : util.EXECUTABLE,
|
"is_executable" : util.EXECUTABLE,
|
||||||
"current_git_head": util.git_head()
|
"current_git_head": util.git_head()
|
||||||
@@ -375,7 +374,7 @@ class DownloadJob(Job):
|
|||||||
else:
|
else:
|
||||||
extr._parentdir = pextr._parentdir
|
extr._parentdir = pextr._parentdir
|
||||||
|
|
||||||
pmeta = pextr.config("parent-metadata")
|
pmeta = pextr.config2("parent-metadata", "metadata-parent")
|
||||||
if pmeta:
|
if pmeta:
|
||||||
if isinstance(pmeta, str):
|
if isinstance(pmeta, str):
|
||||||
data = self.kwdict.copy()
|
data = self.kwdict.copy()
|
||||||
|
|||||||
Reference in New Issue
Block a user