[exhentai] add 'source' option

setting it to "hitomi" downloads the corresponding gallery from
hitomi.la; might be extended to other sources in the future
This commit is contained in:
Mike Fährmann
2021-12-16 22:29:04 +01:00
parent 099ed72de7
commit 62692c6842
2 changed files with 39 additions and 11 deletions

View File

@@ -1081,17 +1081,6 @@ Description
Minimum wait time in seconds before API requests.
extractor.exhentai.limits
-------------------------
Type
``integer``
Default
``null``
Description
Sets a custom image download limit and
stops extraction when it gets exceeded.
extractor.exhentai.domain
-------------------------
Type
@@ -1105,6 +1094,17 @@ Description
* ``"exhentai.org"``: Use ``exhentai.org`` for all URLs
extractor.exhentai.limits
-------------------------
Type
``integer``
Default
``null``
Description
Sets a custom image download limit and
stops extraction when it gets exceeded.
extractor.exhentai.metadata
---------------------------
Type
@@ -1129,6 +1129,18 @@ Description
Download full-sized original images if available.
extractor.exhentai.source
-------------------------
Type
``string``
Default
``"gallery"``
Description
Selects an alternative source to download files from.
* ``"hitomi"``: Download the corresponding gallery from ``hitomi.la``
extractor.fanbox.embeds
-----------------------
Type

View File

@@ -176,6 +176,10 @@ class ExhentaiGalleryExtractor(ExhentaiExtractor):
self.image_token = match.group(4)
self.image_num = text.parse_int(match.group(6), 1)
source = self.config("source")
if source == "hitomi":
self.items = self._items_hitomi
def items(self):
self.login()
@@ -221,6 +225,18 @@ class ExhentaiGalleryExtractor(ExhentaiExtractor):
data["_http_validate"] = None
yield Message.Url, url, data
def _items_hitomi(self):
if self.config("metadata", False):
data = self.metadata_from_api()
data["date"] = text.parse_timestamp(data["posted"])
else:
data = {}
from .hitomi import HitomiGalleryExtractor
url = "https://hitomi.la/galleries/{}.html".format(self.gallery_id)
data["_extractor"] = HitomiGalleryExtractor
yield Message.Queue, url, data
def get_metadata(self, page):
"""Extract gallery metadata"""
data = self.metadata_from_page(page)