diff options
Diffstat (limited to 'gallery_dl/extractor/nhentai.py')
| -rw-r--r-- | gallery_dl/extractor/nhentai.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/gallery_dl/extractor/nhentai.py b/gallery_dl/extractor/nhentai.py index 90c5420..0d656d0 100644 --- a/gallery_dl/extractor/nhentai.py +++ b/gallery_dl/extractor/nhentai.py @@ -11,6 +11,7 @@ from .common import GalleryExtractor, Extractor, Message from .. import text, util import collections +import random class NhentaiGalleryExtractor(GalleryExtractor): @@ -59,15 +60,18 @@ class NhentaiGalleryExtractor(GalleryExtractor): } def images(self, _): - ufmt = ("https://i.nhentai.net/galleries/" + - self.data["media_id"] + "/{}.{}") - extdict = {"j": "jpg", "p": "png", "g": "gif", "w": "webp"} + exts = {"j": "jpg", "p": "png", "g": "gif", "w": "webp", "a": "avif"} + + data = self.data + ufmt = ("https://i{}.nhentai.net/galleries/" + + data["media_id"] + "/{}.{}").format return [ - (ufmt.format(num, extdict.get(img["t"], "jpg")), { - "width": img["w"], "height": img["h"], + (ufmt(random.randint(1, 4), num, exts.get(img["t"], "jpg")), { + "width" : img["w"], + "height": img["h"], }) - for num, img in enumerate(self.data["images"]["pages"], 1) + for num, img in enumerate(data["images"]["pages"], 1) ] |
