# -*- 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://pururin.io/""" from .common import ChapterExtractor from .. import text, util import json class PururinGalleryExtractor(ChapterExtractor): """Extractor for image galleries on pururin.io""" category = "pururin" subcategory = "gallery" filename_fmt = "{category}_{gallery_id}_{page:>03}.{extension}" directory_fmt = ("{category}", "{gallery_id} {title}") archive_fmt = "{gallery_id}_{page}" pattern = r"(?:https?://)?(?:www\.)?pururin\.io/(?:gallery|read)/(\d+)" test = ("https://pururin.io/gallery/38661/iowant-2", { "pattern": r"https://cdn.pururin.io/assets/images/data/38661/\d+\.jpg", "keyword": { "artist": "Shoda Norihiro", "characters": ["Iowa", "Teitoku"], "collection": "", "convention": "C92", "count": 19, "extension": "jpg", "gallery_id": 38661, "group": "Obsidian Order", "lang": "en", "language": "English", "parody": "Kantai Collection", "scanlator": "", "score": float, "tags": list, "title": "Iowant 2!!", "title_jp": str, "type": "Doujinshi", "uploader": "demo" } }) root = "https://pururin.io" def __init__(self, match): self.gallery_id = match.group(1) url = "{}/gallery/{}/x".format(self.root, self.gallery_id) ChapterExtractor.__init__(self, match, url) self._ext = "" self._cnt = 0 def metadata(self, page): data = text.extract_all(page, ( ("artist" , "