mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
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:
parent
e97d7b1c85
commit
34a387b6e2
@ -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 <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}"``.
|
||||
|
||||
|
||||
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.
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user