From 9b2e5f72d6bd55cc84d65e32b061372ea0c59110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 2 Nov 2020 15:28:54 +0100 Subject: [PATCH] [exhentai] update image URL parsing (#1094) --- gallery_dl/extractor/exhentai.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/gallery_dl/extractor/exhentai.py b/gallery_dl/extractor/exhentai.py index 06b5ba2d..4ead3fb4 100644 --- a/gallery_dl/extractor/exhentai.py +++ b/gallery_dl/extractor/exhentai.py @@ -347,24 +347,33 @@ class ExhentaiGalleryExtractor(ExhentaiExtractor): @staticmethod def _parse_image_info(url): - parts = url.split("/")[4].split("-") + for part in url.split("/")[4:]: + try: + _, size, width, height, _ = part.split("-") + break + except ValueError: + pass + else: + size = width = height = 0 + return { - "width": text.parse_int(parts[2]), - "height": text.parse_int(parts[3]), - "size": text.parse_int(parts[1]), - "cost": 1, + "cost" : 1, + "size" : text.parse_int(size), + "width" : text.parse_int(width), + "height": text.parse_int(height), } @staticmethod def _parse_original_info(info): parts = info.lstrip().split(" ") size = text.parse_bytes(parts[3] + parts[4][0]) + return { - "width": text.parse_int(parts[0]), - "height": text.parse_int(parts[2]), - "size": size, # 1 initial point + 1 per 0.1 MB - "cost": 1 + math.ceil(size / 100000) + "cost" : 1 + math.ceil(size / 100000), + "size" : size, + "width" : text.parse_int(parts[0]), + "height": text.parse_int(parts[2]), }