From dbbbb211809a610050998bf58ec7b746b77dc0b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 17 Aug 2020 22:14:56 +0200 Subject: [PATCH] [exhentai] add ability to specify custom image limit (#940) --- docs/configuration.rst | 5 ++++- gallery_dl/extractor/exhentai.py | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index ce85e5ef..308b4c4d 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -743,10 +743,13 @@ Description * ``"auto"``: Use ``e-hentai.org`` or ``exhentai.org`` extractor.exhentai.limits ------------------------- =========== ===== -Type ``bool`` +Type ``bool`` or ``integer`` Default ``true`` Description Check image download limits and stop extraction when they are exceeded. + + If this value is an ``integer``, it gets used as the limit maximum + instead of the value listed on ``https://e-hentai.org/home.php`` =========== ===== diff --git a/gallery_dl/extractor/exhentai.py b/gallery_dl/extractor/exhentai.py index 4cb10b4a..88f1bc50 100644 --- a/gallery_dl/extractor/exhentai.py +++ b/gallery_dl/extractor/exhentai.py @@ -47,6 +47,12 @@ class ExhentaiExtractor(Extractor): self.wait_min = self.config("wait-min", 3) self.wait_max = self.config("wait-max", 6) + if isinstance(self.limits, int): + self._limit_max = self.limits + self.limits = True + else: + self._limit_max = 0 + self._remaining = 0 if self.wait_max < self.wait_min: self.wait_max = self.wait_min @@ -331,6 +337,8 @@ class ExhentaiGalleryExtractor(ExhentaiExtractor): page = self.request(url, cookies=cookies).text current, pos = text.extract(page, "", "") maximum, pos = text.extract(page, "", "", pos) + if self._limit_max: + maximum = self._limit_max self.log.debug("Image Limits: %s/%s", current, maximum) self._remaining = text.parse_int(maximum) - text.parse_int(current)