mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
Separate metadata from handle_url into handle_metadata, commenting
This commit is contained in:
parent
c20bb5c338
commit
c0b9ad678d
@ -69,6 +69,7 @@ class PatreonExtractor(Extractor):
|
||||
post["type"] = "content"
|
||||
yield Message.Url, url, text.nameext_from_url(url, post)
|
||||
|
||||
# Metadata for post using dummy url for formatting
|
||||
post.update({"metadata_only": True})
|
||||
url = post.get("creator").get("image_url")
|
||||
yield Message.Metadata, url, text.nameext_from_url(url, post)
|
||||
|
@ -99,9 +99,8 @@ class Job():
|
||||
|
||||
elif msg[0] == Message.Metadata:
|
||||
_, url, kwds = msg
|
||||
if self.pred_url(url, kwds):
|
||||
self.update_kwdict(kwds)
|
||||
self.handle_url(url, kwds)
|
||||
self.update_kwdict(kwds)
|
||||
self.handle_metadata(url, kwds)
|
||||
|
||||
elif msg[0] == Message.Version:
|
||||
if msg[1] != 1:
|
||||
@ -194,9 +193,6 @@ class DownloadJob(Job):
|
||||
for pp in postprocessors:
|
||||
pp.prepare(pathfmt)
|
||||
|
||||
if kwdict.get("metadata_only"):
|
||||
return
|
||||
|
||||
if pathfmt.exists(archive):
|
||||
self.handle_skip()
|
||||
return
|
||||
@ -238,6 +234,19 @@ class DownloadJob(Job):
|
||||
pp.run_after(pathfmt)
|
||||
self._skipcnt = 0
|
||||
|
||||
def handle_metadata(self, url, kwdict, fallback=None):
|
||||
"""Download the resource specified in 'url'"""
|
||||
postprocessors = self.postprocessors
|
||||
pathfmt = self.pathfmt
|
||||
|
||||
# prepare download
|
||||
pathfmt.set_filename(kwdict)
|
||||
|
||||
if postprocessors:
|
||||
for pp in postprocessors:
|
||||
pp.prepare(pathfmt)
|
||||
return
|
||||
|
||||
def handle_urllist(self, urls, kwdict):
|
||||
"""Download the resource specified in 'url'"""
|
||||
fallback = iter(urls)
|
||||
@ -510,6 +519,9 @@ class DataJob(Job):
|
||||
def handle_url(self, url, kwdict):
|
||||
self.data.append((Message.Url, url, self.filter(kwdict)))
|
||||
|
||||
def handle_metadata(self, url, kwdict):
|
||||
self.data.append((Message.Url, url, self.filter(kwdict)))
|
||||
|
||||
def handle_urllist(self, urls, kwdict):
|
||||
self.data.append((Message.Urllist, list(urls), self.filter(kwdict)))
|
||||
|
||||
|
@ -17,6 +17,7 @@ class Metadata_bypostPP(MetadataPP):
|
||||
MetadataPP.__init__(self, pathfmt, options)
|
||||
|
||||
def prepare(self, pathfmt):
|
||||
# Only run this processor on metadata messages, not individual images.
|
||||
if pathfmt.kwdict.get("metadata_only"):
|
||||
MetadataPP.run(self, pathfmt)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user