enable 'metadata-url/-path/-parent/-extractor]' by default

assign values to "private" keys to not have them appear in the
standard JSON output, while still making it easier to access them
This commit is contained in:
Mike Fährmann
2026-02-03 19:20:42 +01:00
parent f0f9575406
commit 2cbd9740f2
3 changed files with 28 additions and 11 deletions

View File

@@ -253,7 +253,10 @@ Type
* ``bool`` * ``bool``
* ``string`` * ``string``
Default Default
`extractor.parent <extractor.*.parent_>`__ ``true``
`extractor.parent <extractor.*.parent_>`__
``"_parent"``
otherwise
Description Description
Forward a parent's metadata to its child extractors. Forward a parent's metadata to its child extractors.
@@ -1089,6 +1092,8 @@ extractor.*.metadata-url
------------------------ ------------------------
Type Type
``string`` ``string``
Default
``"_url"``
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.
@@ -1105,6 +1110,8 @@ extractor.*.metadata-path
------------------------- -------------------------
Type Type
``string`` ``string``
Default
``"_path"``
Description Description
Insert a reference to the current Insert a reference to the current
`PathFormat <https://github.com/mikf/gallery-dl/blob/v1.27.0/gallery_dl/path.py#L27>`__ `PathFormat <https://github.com/mikf/gallery-dl/blob/v1.27.0/gallery_dl/path.py#L27>`__
@@ -1120,6 +1127,8 @@ extractor.*.metadata-extractor
------------------------------ ------------------------------
Type Type
``string`` ``string``
Default
``"_extr"``
Description Description
Insert a reference to the current Insert a reference to the current
`Extractor <https://github.com/mikf/gallery-dl/blob/v1.27.0/gallery_dl/extractor/common.py#L28>`__ `Extractor <https://github.com/mikf/gallery-dl/blob/v1.27.0/gallery_dl/extractor/common.py#L28>`__
@@ -1132,6 +1141,8 @@ extractor.*.metadata-http
------------------------- -------------------------
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
@@ -1148,6 +1159,8 @@ extractor.*.metadata-version
---------------------------- ----------------------------
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.

View File

@@ -71,11 +71,11 @@
"path-convert" : null, "path-convert" : null,
"path-extended": true, "path-extended": true,
"metadata-extractor": null, "metadata-extractor": "_extr",
"metadata-parent" : "_parent",
"metadata-path" : "_path",
"metadata-url" : "_url",
"metadata-http" : null, "metadata-http" : null,
"metadata-parent" : null,
"metadata-path" : null,
"metadata-url" : null,
"metadata-version" : null, "metadata-version" : null,
"sleep" : 0, "sleep" : 0,

View File

@@ -69,12 +69,16 @@ class Job():
extr.log = self._wrap_logger(extr.log) extr.log = self._wrap_logger(extr.log)
extr.log.debug("Using %s for '%s'", extr.__class__.__name__, extr.url) extr.log.debug("Using %s for '%s'", extr.__class__.__name__, extr.url)
self.metadata_url = extr.config2("metadata-url", "url-metadata") self.metadata_url = extr.config2(
self.metadata_http = extr.config2("metadata-http", "http-metadata") "metadata-url", "url-metadata", "_url")
metadata_path = extr.config2("metadata-path", "path-metadata") self.metadata_http = extr.config2(
metadata_version = extr.config2("metadata-version", "version-metadata") "metadata-http", "http-metadata")
metadata_path = extr.config2(
"metadata-path", "path-metadata", "_path")
metadata_version = extr.config2(
"metadata-version", "version-metadata")
metadata_extractor = extr.config2( metadata_extractor = extr.config2(
"metadata-extractor", "extractor-metadata") "metadata-extractor", "extractor-metadata", "_extr")
if metadata_path: if metadata_path:
self.kwdict[metadata_path] = path_proxy self.kwdict[metadata_path] = path_proxy
@@ -467,7 +471,7 @@ class DownloadJob(Job):
extr._parentdir = pextr._parentdir extr._parentdir = pextr._parentdir
if pmeta := pextr.config2( if pmeta := pextr.config2(
"parent-metadata", "metadata-parent", parent): "parent-metadata", "metadata-parent", parent or "_parent"):
if isinstance(pmeta, str): if isinstance(pmeta, str):
data = self.kwdict.copy() data = self.kwdict.copy()
if kwdict: if kwdict: