|
|
|
@ -43,16 +43,14 @@ class ExhentaiExtractor(Extractor):
|
|
|
|
|
self.cookiedomain = "." + domain
|
|
|
|
|
|
|
|
|
|
Extractor.__init__(self, match)
|
|
|
|
|
self.limits = self.config("limits", True)
|
|
|
|
|
self.original = self.config("original", True)
|
|
|
|
|
|
|
|
|
|
if type(self.limits) is int:
|
|
|
|
|
self._limit_max = self.limits
|
|
|
|
|
self.limits = True
|
|
|
|
|
limits = self.config("limits", False)
|
|
|
|
|
if limits and limits.__class__ is int:
|
|
|
|
|
self.limits = limits
|
|
|
|
|
self._remaining = 0
|
|
|
|
|
else:
|
|
|
|
|
self._limit_max = 0
|
|
|
|
|
|
|
|
|
|
self._remaining = 0
|
|
|
|
|
self.limits = False
|
|
|
|
|
|
|
|
|
|
self.session.headers["Referer"] = self.root + "/"
|
|
|
|
|
if version != "ex":
|
|
|
|
@ -219,6 +217,8 @@ class ExhentaiGalleryExtractor(ExhentaiExtractor):
|
|
|
|
|
if "/fullimg.php" in url:
|
|
|
|
|
data["extension"] = ""
|
|
|
|
|
data["_http_validate"] = _validate_response
|
|
|
|
|
else:
|
|
|
|
|
data["_http_validate"] = None
|
|
|
|
|
yield Message.Url, url, data
|
|
|
|
|
|
|
|
|
|
def get_metadata(self, page):
|
|
|
|
@ -358,6 +358,26 @@ class ExhentaiGalleryExtractor(ExhentaiExtractor):
|
|
|
|
|
"Continue with '%s/s/%s/%s-%s' as URL after resetting it.",
|
|
|
|
|
self.root, data["image_token"], self.gallery_id, data["num"])
|
|
|
|
|
|
|
|
|
|
def _check_limits(self, data):
|
|
|
|
|
if not self._remaining or data["num"] % 25 == 0:
|
|
|
|
|
self._update_limits()
|
|
|
|
|
self._remaining -= data["cost"]
|
|
|
|
|
if self._remaining <= 0:
|
|
|
|
|
self._report_limits(data)
|
|
|
|
|
|
|
|
|
|
def _update_limits(self):
|
|
|
|
|
url = "https://e-hentai.org/home.php"
|
|
|
|
|
cookies = {
|
|
|
|
|
cookie.name: cookie.value
|
|
|
|
|
for cookie in self.session.cookies
|
|
|
|
|
if cookie.domain == self.cookiedomain and cookie.name != "igneous"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
page = self.request(url, cookies=cookies).text
|
|
|
|
|
current = text.extract(page, "<strong>", "</strong>")[0]
|
|
|
|
|
self.log.debug("Image Limits: %s/%s", current, self.limits)
|
|
|
|
|
self._remaining = self.limits - text.parse_int(current)
|
|
|
|
|
|
|
|
|
|
def _gallery_page(self):
|
|
|
|
|
url = "{}/g/{}/{}/".format(
|
|
|
|
|
self.root, self.gallery_id, self.gallery_token)
|
|
|
|
@ -381,35 +401,6 @@ class ExhentaiGalleryExtractor(ExhentaiExtractor):
|
|
|
|
|
raise exception.NotFoundError("image page")
|
|
|
|
|
return page
|
|
|
|
|
|
|
|
|
|
def _check_limits(self, data):
|
|
|
|
|
if not self._remaining or data["num"] % 25 == 0:
|
|
|
|
|
self._update_limits()
|
|
|
|
|
self._remaining -= data["cost"]
|
|
|
|
|
|
|
|
|
|
if self._remaining <= 0:
|
|
|
|
|
ExhentaiExtractor.LIMIT = True
|
|
|
|
|
url = "{}/s/{}/{}-{}".format(
|
|
|
|
|
self.root, data["image_token"], self.gallery_id, data["num"])
|
|
|
|
|
raise exception.StopExtraction(
|
|
|
|
|
"Image limit reached! Continue with '%s' "
|
|
|
|
|
"as URL after resetting it.", url)
|
|
|
|
|
|
|
|
|
|
def _update_limits(self):
|
|
|
|
|
url = "https://e-hentai.org/home.php"
|
|
|
|
|
cookies = {
|
|
|
|
|
cookie.name: cookie.value
|
|
|
|
|
for cookie in self.session.cookies
|
|
|
|
|
if cookie.domain == self.cookiedomain and cookie.name != "igneous"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
page = self.request(url, cookies=cookies).text
|
|
|
|
|
current, pos = text.extract(page, "<strong>", "</strong>")
|
|
|
|
|
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._remaining = text.parse_int(maximum) - text.parse_int(current)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def _parse_image_info(url):
|
|
|
|
|
for part in url.split("/")[4:]:
|
|
|
|
|