[exhentai] add ability to specify custom image limit (#940)
This commit is contained in:
@@ -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``
|
||||||
=========== =====
|
=========== =====
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user