diff options
| author | 2019-07-02 04:33:45 -0400 | |
|---|---|---|
| committer | 2019-07-02 04:33:45 -0400 | |
| commit | 195c45911e79c33cf0bb986721365fb06df5a153 (patch) | |
| tree | ac0c9b6ef40bea7aa7ab0c5c3cb500eb510668fa /gallery_dl/extractor/nsfwalbum.py | |
Import Upstream version 1.8.7upstream/1.8.7
Diffstat (limited to 'gallery_dl/extractor/nsfwalbum.py')
| -rw-r--r-- | gallery_dl/extractor/nsfwalbum.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/gallery_dl/extractor/nsfwalbum.py b/gallery_dl/extractor/nsfwalbum.py new file mode 100644 index 0000000..c55f80a --- /dev/null +++ b/gallery_dl/extractor/nsfwalbum.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- + +# Copyright 2019 Mike Fährmann +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. + +"""Extractors for https://nsfwalbum.com/""" + +from .common import GalleryExtractor +from .. import text + + +class NsfwalbumAlbumExtractor(GalleryExtractor): + """Extractor for image albums on nsfwalbum.com""" + category = "nsfwalbum" + subcategory = "album" + root = "https://nsfwalbum.com" + filename_fmt = "{album_id}_{page:>03}_{id}.{extension}" + directory_fmt = ("{category}", "{album_id} {title}") + archive_fmt = "{id}" + pattern = r"(?:https?://)?(?:www\.)?nsfwalbum\.com(/album/(\d+))" + test = ("https://nsfwalbum.com/album/295201", { + "range": "1-5", + "url": "e60eced1873215f5deee1ca7226d60cb4dcc051c", + "keyword": "e0573ecb1966611e96d10172a3ca1db1078a7984", + }) + + def __init__(self, match): + self.album_id = match.group(2) + GalleryExtractor.__init__(self, match) + + def metadata(self, page): + extr = text.extract_from(page) + return { + "album_id": text.parse_int(self.album_id), + "title" : text.unescape(extr('<h6>', '</h6>')), + "models" : text.split_html(extr('"models"> Models:', '</div>')), + "studio" : text.remove_html(extr('"models"> Studio:', '</div>')), + } + + def images(self, page): + iframe = self.root + "/iframe_image.php?id=" + backend = self.root + "/backend.php" + for image_id in text.extract_iter(page, 'data-img-id="', '"'): + spirit = text.extract(self.request( + iframe + image_id).text, 'giraffe.annihilate("', '"')[0] + params = {"spirit": self._annihilate(spirit), "photo": image_id} + data = self.request(backend, params=params).json() + yield data[0], { + "id" : text.parse_int(image_id), + "width" : text.parse_int(data[1]), + "height": text.parse_int(data[2]), + } + + @staticmethod + def _annihilate(value, base=6): + return "".join( + chr(ord(char) ^ base) + for char in value + ) |
