diff --git a/gallery-dl.conf b/gallery-dl.conf index 3395dd52..78a03bae 100644 --- a/gallery-dl.conf +++ b/gallery-dl.conf @@ -10,6 +10,8 @@ }, "exhentai": { + "wait-min": 3, + "wait-max": 6, "cookies": { "ipb_member_id": null, diff --git a/gallery_dl/extractor/exhentai.py b/gallery_dl/extractor/exhentai.py index 28543c80..875ab1b4 100644 --- a/gallery_dl/extractor/exhentai.py +++ b/gallery_dl/extractor/exhentai.py @@ -10,7 +10,6 @@ from .common import Extractor, Message from .. import config, text, iso639_1 -import os.path import time import random @@ -41,6 +40,10 @@ class ExhentaiExtractor(Extractor): cookies = config.get(("extractor", "exhentai", "cookies"), {}) for key, value in cookies.items(): self.session.cookies.set(key, value, domain=".exhentai.org", path="/") + self.wait_min = config.interpolate(("extractor", "exhentai", "wait-min"), 3) + self.wait_max = config.interpolate(("extractor", "exhentai", "wait-max"), 6) + if self.wait_max < self.wait_min: + self.wait_max = self.wait_min def items(self): yield Message.Version, 1 @@ -54,14 +57,14 @@ class ExhentaiExtractor(Extractor): yield Message.Directory, data urlkey = "url" - if config.get(("extractor", "exhentai", "download-original"), True): + if config.interpolate(("extractor", "exhentai", "download-original"), True): urlkey = "origurl" for num, image in enumerate(self.get_images(url), 1): image.update(data) image["num"] = num text.nameext_from_url(image["url"], image) if "/fullimg.php" in image[urlkey]: - time.sleep(random.uniform(1, 2)) + self.wait((1, 2)) yield Message.Url, image[urlkey], image def get_job_metadata(self, page): @@ -90,7 +93,7 @@ class ExhentaiExtractor(Extractor): def get_images(self, url): """Collect url and metadata for all images in this gallery""" - time.sleep(random.uniform(3, 6)) + self.wait() page = self.request(url).text data, pos = text.extract_all(page, ( (None , '