Added an additional channel for downloading the metadata of an entire post or gallery.

pull/511/head
Gio 5 years ago
parent f451be48c3
commit cfc70a97ab

@ -52,3 +52,4 @@ class Message():
# Cookies = 5
Queue = 6
Urllist = 7
Metadata = 8

@ -69,6 +69,10 @@ class PatreonExtractor(Extractor):
post["type"] = "content"
yield Message.Url, url, text.nameext_from_url(url, post)
post.update({"metadata_only": True})
url = post.get("creator").get("image_url")
yield Message.Metadata, url, text.nameext_from_url(url, post)
def posts(self):
"""Return all relevant post objects"""

@ -97,6 +97,12 @@ class Job():
self.update_kwdict(kwds)
self.handle_urllist(urls, kwds)
elif msg[0] == Message.Metadata:
_, url, kwds = msg
if self.pred_url(url, kwds):
self.update_kwdict(kwds)
self.handle_url(url, kwds)
elif msg[0] == Message.Version:
if msg[1] != 1:
raise "unsupported message-version ({}, {})".format(
@ -188,6 +194,10 @@ class DownloadJob(Job):
for pp in postprocessors:
pp.prepare(pathfmt)
if kwdict.get("metadata_only"):
self.handle_skip()
return
if pathfmt.exists(archive):
self.handle_skip()
return

@ -18,6 +18,7 @@ modules = [
"mtime",
"ugoira",
"zip",
"metadata_bypost",
]
log = logging.getLogger("postprocessor")

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
"""Write metadata to JSON files"""
from .metadata import __postprocessor__ as MetadataPP
class Metadata_BypostPP(MetadataPP):
def __init__(self, pathfmt, options):
MetadataPP.__init__(self, pathfmt, options)
def prepare(self, pathfmt):
if pathfmt.kwdict.get("metadata_only"):
MetadataPP.run(self, pathfmt)
def run(self, pathfmt):
return
__postprocessor__ = Metadata_BypostPP
Loading…
Cancel
Save