From 551fdf7ad7e7a74b891a36f7437af767c3d9d758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 13 Sep 2022 18:27:14 +0200 Subject: [PATCH] [exhentai] move 509 check into its own function --- gallery_dl/extractor/exhentai.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gallery_dl/extractor/exhentai.py b/gallery_dl/extractor/exhentai.py index a2c06776..712575cb 100644 --- a/gallery_dl/extractor/exhentai.py +++ b/gallery_dl/extractor/exhentai.py @@ -328,13 +328,7 @@ class ExhentaiGalleryExtractor(ExhentaiExtractor): data["image_token"] = self.key["start"] = extr('var startkey="', '";') self.key["show"] = extr('var showkey="', '";') - # full 509.gif URLs - # - https://exhentai.org/img/509.gif - # - https://ehgt.org/g/509.gif - if iurl.endswith(("hentai.org/img/509.gif", - "ehgt.org/g/509.gif")): - self._report_limits(data) - + self._check_509(iurl, data) return url, text.nameext_from_url(iurl, data) def images_from_api(self): @@ -370,9 +364,7 @@ class ExhentaiGalleryExtractor(ExhentaiExtractor): data["num"] = request["page"] data["image_token"] = imgkey - if imgurl.endswith(("hentai.org/img/509.gif", - "ehgt.org/g/509.gif")): - self._report_limits(data) + self._check_509(imgurl, data) yield url, text.nameext_from_url(imgurl, data) request["imgkey"] = nextkey @@ -391,6 +383,15 @@ class ExhentaiGalleryExtractor(ExhentaiExtractor): if self._remaining <= 0: self._report_limits(data) + def _check_509(self, url, data): + # full 509.gif URLs + # - https://exhentai.org/img/509.gif + # - https://ehgt.org/g/509.gif + if url.endswith(("hentai.org/img/509.gif", + "ehgt.org/g/509.gif")): + self.log.debug(url) + self._report_limits(data) + def _update_limits(self): url = "https://e-hentai.org/home.php" cookies = {