From 9ae58a6b3e47974ccccd8fde03275df7da10bfeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 7 Sep 2019 13:29:01 +0200 Subject: [PATCH] [exhentai] update image limit checks - adjust cost of original images - delay limit initialization until gallery and first image page have been requested and all cookies are available --- gallery_dl/extractor/exhentai.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/gallery_dl/extractor/exhentai.py b/gallery_dl/extractor/exhentai.py index 1833b1af..0eca8ede 100644 --- a/gallery_dl/extractor/exhentai.py +++ b/gallery_dl/extractor/exhentai.py @@ -151,9 +151,6 @@ class ExhentaiGalleryExtractor(ExhentaiExtractor): def items(self): self.login() - if self.limits: - self._init_limits() - if self.gallery_token: gpage = self._gallery_page() self.image_token = text.extract(gpage, 'hentai.org/s/', '"')[0] @@ -308,15 +305,8 @@ class ExhentaiGalleryExtractor(ExhentaiExtractor): raise exception.NotFoundError("image page") return page - def _init_limits(self): - self._update_limits() - if self._remaining <= 0: - self.log.error("Image limit reached!") - ExhentaiExtractor.LIMIT = True - raise exception.StopExtraction() - def _check_limits(self, data): - if data["num"] % 20 == 0: + if not self._remaining or data["num"] % 20 == 0: self._update_limits() self._remaining -= data["cost"] @@ -360,7 +350,8 @@ class ExhentaiGalleryExtractor(ExhentaiExtractor): "width": text.parse_int(parts[0]), "height": text.parse_int(parts[2]), "size": size, - "cost": 1 + math.ceil(size * 5 / 1024 / 1024) + # 1 initial point + 1 per 0.1 MB + "cost": 1 + math.ceil(size / 104857.6) }