implement 'path-metadata' option (#2734)
This commit is contained in:
parent
81a37d21d3
commit
7d1a95ada6
@ -561,6 +561,20 @@ Description
|
|||||||
with a ``metadata`` post processor, etc.
|
with a ``metadata`` post processor, etc.
|
||||||
|
|
||||||
|
|
||||||
|
extractor.*.path-metadata
|
||||||
|
-------------------------
|
||||||
|
Type
|
||||||
|
``string``
|
||||||
|
Default
|
||||||
|
``null``
|
||||||
|
Description
|
||||||
|
Insert a reference to the current `PathFormat <https://github.com/mikf/gallery-dl/blob/v1.22.4/gallery_dl/path.py#L20>`__
|
||||||
|
data structure into metadata dictionaries as the given name.
|
||||||
|
|
||||||
|
For example, setting this option to ``"gdl_path"`` would make it possible
|
||||||
|
to access the current file's filename as ``"[gdl_path.filename}"``.
|
||||||
|
|
||||||
|
|
||||||
extractor.*.category-transfer
|
extractor.*.category-transfer
|
||||||
-----------------------------
|
-----------------------------
|
||||||
Type
|
Type
|
||||||
|
@ -35,10 +35,13 @@ class Job():
|
|||||||
self.status = 0
|
self.status = 0
|
||||||
self.url_key = extr.config("url-metadata")
|
self.url_key = extr.config("url-metadata")
|
||||||
|
|
||||||
|
path_key = extr.config("path-metadata")
|
||||||
|
path_proxy = output.PathfmtProxy(self)
|
||||||
|
|
||||||
self._logger_extra = {
|
self._logger_extra = {
|
||||||
"job" : self,
|
"job" : self,
|
||||||
"extractor": extr,
|
"extractor": extr,
|
||||||
"path" : output.PathfmtProxy(self),
|
"path" : path_proxy,
|
||||||
"keywords" : output.KwdictProxy(self),
|
"keywords" : output.KwdictProxy(self),
|
||||||
}
|
}
|
||||||
extr.log = self._wrap_logger(extr.log)
|
extr.log = self._wrap_logger(extr.log)
|
||||||
@ -58,6 +61,8 @@ class Job():
|
|||||||
kwdict = extr.config("keywords")
|
kwdict = extr.config("keywords")
|
||||||
if kwdict:
|
if kwdict:
|
||||||
self.kwdict.update(kwdict)
|
self.kwdict.update(kwdict)
|
||||||
|
if path_key:
|
||||||
|
self.kwdict[path_key] = path_proxy
|
||||||
|
|
||||||
# predicates
|
# predicates
|
||||||
self.pred_url = self._prepare_predicates("image", True)
|
self.pred_url = self._prepare_predicates("image", True)
|
||||||
|
@ -73,6 +73,12 @@ class PathfmtProxy():
|
|||||||
pathfmt = object.__getattribute__(self, "job").pathfmt
|
pathfmt = object.__getattribute__(self, "job").pathfmt
|
||||||
return pathfmt.__dict__.get(name) if pathfmt else None
|
return pathfmt.__dict__.get(name) if pathfmt else None
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
pathfmt = object.__getattribute__(self, "job").pathfmt
|
||||||
|
if pathfmt:
|
||||||
|
return pathfmt.path or pathfmt.directory
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
class KwdictProxy():
|
class KwdictProxy():
|
||||||
__slots__ = ("job",)
|
__slots__ = ("job",)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user