1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

extend 'parent-metadata' functionality (#1687, #1651, #1364)

This commit is contained in:
Mike Fährmann 2021-07-13 02:04:59 +02:00
parent 193401ce3b
commit e95f99882f
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 26 additions and 7 deletions

View File

@ -165,11 +165,23 @@ Description
extractor.*.parent-metadata
---------------------------
Type
``bool``
``bool`` or ``string``
Default
``false``
Description
Overwrite any metadata provided by a child extractor with its parent's.
If ``true``, overwrite any metadata provided by a child extractor
with its parent's.
| If this is a ``string``, add a parent's metadata to its children's
to a field named after said string.
| For example with ``"parent-metadata": "_p_"``:
.. code:: json
{
"id": "child-id",
"_p_": {"id": "parent-id"}
}
extractor.*.parent-skip

View File

@ -302,11 +302,18 @@ class DownloadJob(Job):
else:
extr._parentdir = pextr._parentdir
if pextr.config("parent-metadata"):
if self.kwdict:
job.kwdict.update(self.kwdict)
if kwdict:
job.kwdict.update(kwdict)
pmeta = pextr.config("parent-metadata")
if pmeta:
if isinstance(pmeta, str):
data = self.kwdict.copy()
if kwdict:
data.update(kwdict)
job.kwdict[pmeta] = data
else:
if self.kwdict:
job.kwdict.update(self.kwdict)
if kwdict:
job.kwdict.update(kwdict)
if pextr.config("parent-skip"):
job._skipcnt = self._skipcnt