From f0c50938128ab64e91fe62006155de0a09d00ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 22 Jun 2019 22:43:09 +0200 Subject: [PATCH] [nsfwalbum] add album extractor (closes #287) --- docs/supportedsites.rst | 1 + gallery_dl/extractor/__init__.py | 1 + gallery_dl/extractor/nsfwalbum.py | 61 +++++++++++++++++++++++++++++++ scripts/supportedsites.py | 1 + 4 files changed, 64 insertions(+) create mode 100644 gallery_dl/extractor/nsfwalbum.py diff --git a/docs/supportedsites.rst b/docs/supportedsites.rst index 9e409dcf..6a56476f 100644 --- a/docs/supportedsites.rst +++ b/docs/supportedsites.rst @@ -70,6 +70,7 @@ Ngomik http://ngomik.in/ Chapters nhentai https://nhentai.net/ Galleries, Search Results Niconico Seiga https://seiga.nicovideo.jp/ Images from Users, individual Images Required nijie https://nijie.info/ |nijie-C| Required +NSFWalbum.com https://nsfwalbum.com/ Albums Nyafuu Archive https://archive.nyafuu.org/ Threads Patreon https://www.patreon.com/ Images from Users, Creators Pawoo https://pawoo.net/ Images from Users, Images from Statuses diff --git a/gallery_dl/extractor/__init__.py b/gallery_dl/extractor/__init__.py index b223db0b..dc3cee2e 100644 --- a/gallery_dl/extractor/__init__.py +++ b/gallery_dl/extractor/__init__.py @@ -65,6 +65,7 @@ modules = [ "ngomik", "nhentai", "nijie", + "nsfwalbum", "paheal", "patreon", "photobucket", diff --git a/gallery_dl/extractor/nsfwalbum.py b/gallery_dl/extractor/nsfwalbum.py new file mode 100644 index 00000000..72e7e197 --- /dev/null +++ b/gallery_dl/extractor/nsfwalbum.py @@ -0,0 +1,61 @@ +# -*- 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}" + 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('
', '
')), + "models" : text.split_html(extr('"models"> Models:', '')), + "studio" : text.remove_html(extr('"models"> Studio:', '')), + } + + 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 + ) diff --git a/scripts/supportedsites.py b/scripts/supportedsites.py index 31b78530..f4b5061c 100755 --- a/scripts/supportedsites.py +++ b/scripts/supportedsites.py @@ -50,6 +50,7 @@ CATEGORY_MAP = { "myportfolio" : "Adobe Portfolio", "nhentai" : "nhentai", "nijie" : "nijie", + "nsfwalbum" : "NSFWalbum.com", "nyafuu" : "Nyafuu Archive", "paheal" : "rule #34", "powermanga" : "PowerManga",