# -*- coding: utf-8 -*- # Copyright 2016 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. """Extract hentaimanga from https://hentai2read.com/""" from .. import text from . import hentaicdn import re import json class Hentai2readMangaExtractor(hentaicdn.HentaicdnMangaExtractor): """Extractor for mangas from hentai2read.com""" category = "hentai2read" pattern = [r"(?:https?://)?(?:www\.)?hentai2read\.com/([^/]+)/?$"] test = [ ("http://hentai2read.com/amazon_elixir/", { "url": "d1f87b71d3c97b49a478cdfb6ae96b2d9520ab78", }), ("http://hentai2read.com/oshikage_riot/", { "url": "672f34cce7bf5a855c6c38e8bc9c5117a4b3061c", }) ] def __init__(self, match): hentaicdn.HentaicdnMangaExtractor.__init__(self) self.url_title = match.group(1) def get_chapters(self): page = text.extract( self.request("http://hentai2read.com/" + self.url_title).text, '\n' )[0] return text.extract_iter(page, '
  • \n", "")[0] match = re.match(r"Reading (?:(.+) dj - )?(.+) Hentai - \d+: ", title) return { "gallery-id": images[0].split("/")[-3], "chapter": self.chapter, "count": len(images), "series": match.group(1) or "", "title": match.group(2), "lang": "en", "language": "English", } @staticmethod def get_image_urls(page): """Extract and return a list of all image-urls""" images = text.extract(page, "'images' : ", ",\n")[0] return json.loads(images)