[exhentai] add ability to specify custom image limit (#940)

This commit is contained in:
Mike Fährmann
2020-08-17 22:14:56 +02:00
parent b2009ea39e
commit dbbbb21180
2 changed files with 12 additions and 1 deletions

View File

@@ -743,10 +743,13 @@ Description * ``"auto"``: Use ``e-hentai.org`` or ``exhentai.org``
extractor.exhentai.limits extractor.exhentai.limits
------------------------- -------------------------
=========== ===== =========== =====
Type ``bool`` Type ``bool`` or ``integer``
Default ``true`` Default ``true``
Description Check image download limits Description Check image download limits
and stop extraction when they are exceeded. 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``
=========== ===== =========== =====

View File

@@ -47,6 +47,12 @@ class ExhentaiExtractor(Extractor):
self.wait_min = self.config("wait-min", 3) self.wait_min = self.config("wait-min", 3)
self.wait_max = self.config("wait-max", 6) 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 self._remaining = 0
if self.wait_max < self.wait_min: if self.wait_max < self.wait_min:
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 page = self.request(url, cookies=cookies).text
current, pos = text.extract(page, "<strong>", "</strong>") current, pos = text.extract(page, "<strong>", "</strong>")
maximum, pos = text.extract(page, "<strong>", "</strong>", pos) maximum, pos = text.extract(page, "<strong>", "</strong>", pos)
if self._limit_max:
maximum = self._limit_max
self.log.debug("Image Limits: %s/%s", current, maximum) self.log.debug("Image Limits: %s/%s", current, maximum)
self._remaining = text.parse_int(maximum) - text.parse_int(current) self._remaining = text.parse_int(maximum) - text.parse_int(current)