2016-02-19 15:24:49 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2022-10-24 16:16:29 +02:00
|
|
|
# Copyright 2016-2022 Mike Fährmann
|
2016-02-19 15:24:49 +01:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2022-10-24 16:16:29 +02:00
|
|
|
"""Extractors for https://hentai2read.com/"""
|
2016-02-19 15:24:49 +01:00
|
|
|
|
2018-02-07 11:22:47 +01:00
|
|
|
from .common import ChapterExtractor, MangaExtractor
|
2023-02-07 23:14:53 +01:00
|
|
|
from .. import text, util
|
2019-02-11 18:38:47 +01:00
|
|
|
import re
|
2016-02-19 15:24:49 +01:00
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2019-02-11 18:38:47 +01:00
|
|
|
class Hentai2readBase():
|
|
|
|
"""Base class for hentai2read extractors"""
|
2016-02-20 06:49:35 +01:00
|
|
|
category = "hentai2read"
|
2019-02-11 18:38:47 +01:00
|
|
|
root = "https://hentai2read.com"
|
2016-02-20 06:49:35 +01:00
|
|
|
|
2017-09-20 13:28:57 +02:00
|
|
|
|
2019-02-11 18:38:47 +01:00
|
|
|
class Hentai2readChapterExtractor(Hentai2readBase, ChapterExtractor):
|
2016-09-12 10:20:57 +02:00
|
|
|
"""Extractor for a single manga chapter from hentai2read.com"""
|
2018-02-12 23:09:34 +01:00
|
|
|
archive_fmt = "{chapter_id}_{page}"
|
2022-10-24 15:53:51 +02:00
|
|
|
pattern = r"(?:https?://)?(?:www\.)?hentai2read\.com(/[^/?#]+/([^/?#]+))"
|
|
|
|
test = (
|
|
|
|
("https://hentai2read.com/amazon_elixir/1/", {
|
|
|
|
"url": "964b942cf492b3a129d2fe2608abfc475bc99e71",
|
|
|
|
"keyword": "85645b02d34aa11b3deb6dadd7536863476e1bad",
|
|
|
|
}),
|
|
|
|
("https://hentai2read.com/popuni_kei_joshi_panic/2.5/", {
|
2022-10-24 16:16:29 +02:00
|
|
|
"pattern": r"https://hentaicdn\.com/hentai"
|
|
|
|
r"/13088/2\.5y/ccdn00\d+\.jpg",
|
|
|
|
"count": 36,
|
|
|
|
"keyword": {
|
|
|
|
"author": "Kurisu",
|
|
|
|
"chapter": 2,
|
|
|
|
"chapter_id": 75152,
|
|
|
|
"chapter_minor": ".5",
|
|
|
|
"count": 36,
|
|
|
|
"lang": "en",
|
|
|
|
"language": "English",
|
|
|
|
"manga": "Popuni Kei Joshi Panic!",
|
|
|
|
"manga_id": 13088,
|
|
|
|
"page": int,
|
|
|
|
"title": "Popuni Kei Joshi Panic! 2.5",
|
|
|
|
"type": "Original",
|
|
|
|
},
|
2022-10-24 15:53:51 +02:00
|
|
|
}),
|
|
|
|
)
|
2016-02-19 15:24:49 +01:00
|
|
|
|
|
|
|
def __init__(self, match):
|
2019-02-11 18:38:47 +01:00
|
|
|
self.chapter = match.group(2)
|
|
|
|
ChapterExtractor.__init__(self, match)
|
2016-02-19 15:24:49 +01:00
|
|
|
|
2019-02-11 18:38:47 +01:00
|
|
|
def metadata(self, page):
|
2018-02-07 11:22:47 +01:00
|
|
|
title, pos = text.extract(page, "<title>", "</title>")
|
|
|
|
manga_id, pos = text.extract(page, 'data-mid="', '"', pos)
|
|
|
|
chapter_id, pos = text.extract(page, 'data-cid="', '"', pos)
|
2022-10-24 16:16:29 +02:00
|
|
|
chapter, sep, minor = self.chapter.partition(".")
|
2017-08-22 13:51:00 +02:00
|
|
|
match = re.match(r"Reading (.+) \(([^)]+)\) Hentai(?: by (.+))? - "
|
2022-10-24 15:53:51 +02:00
|
|
|
r"([^:]+): (.+) . Page 1 ", title)
|
2016-02-19 15:24:49 +01:00
|
|
|
return {
|
2017-08-22 13:51:00 +02:00
|
|
|
"manga": match.group(1),
|
2018-04-20 14:53:21 +02:00
|
|
|
"manga_id": text.parse_int(manga_id),
|
2022-10-24 15:53:51 +02:00
|
|
|
"chapter": text.parse_int(chapter),
|
|
|
|
"chapter_minor": sep + minor,
|
2018-04-20 14:53:21 +02:00
|
|
|
"chapter_id": text.parse_int(chapter_id),
|
2017-08-22 13:51:00 +02:00
|
|
|
"type": match.group(2),
|
|
|
|
"author": match.group(3),
|
|
|
|
"title": match.group(5),
|
2016-02-19 15:24:49 +01:00
|
|
|
"lang": "en",
|
|
|
|
"language": "English",
|
|
|
|
}
|
2017-02-26 02:25:36 +01:00
|
|
|
|
2022-10-24 15:53:51 +02:00
|
|
|
def images(self, page):
|
2017-02-26 02:25:36 +01:00
|
|
|
images = text.extract(page, "'images' : ", ",\n")[0]
|
2018-02-07 11:22:47 +01:00
|
|
|
return [
|
|
|
|
("https://hentaicdn.com/hentai" + part, None)
|
2023-02-07 23:14:53 +01:00
|
|
|
for part in util.json_loads(images)
|
2018-02-07 11:22:47 +01:00
|
|
|
]
|
2019-02-11 18:38:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Hentai2readMangaExtractor(Hentai2readBase, MangaExtractor):
|
|
|
|
"""Extractor for hmanga from hentai2read.com"""
|
2019-02-13 13:23:36 +01:00
|
|
|
chapterclass = Hentai2readChapterExtractor
|
2020-10-22 23:12:59 +02:00
|
|
|
pattern = r"(?:https?://)?(?:www\.)?hentai2read\.com(/[^/?#]+)/?$"
|
2019-02-11 18:38:47 +01:00
|
|
|
test = (
|
|
|
|
("https://hentai2read.com/amazon_elixir/", {
|
|
|
|
"url": "273073752d418ec887d7f7211e42b832e8c403ba",
|
2022-10-24 16:16:29 +02:00
|
|
|
"keyword": "5c1b712258e78e120907121d3987c71f834d13e1",
|
2019-02-11 18:38:47 +01:00
|
|
|
}),
|
|
|
|
("https://hentai2read.com/oshikage_riot/", {
|
|
|
|
"url": "6595f920a3088a15c2819c502862d45f8eb6bea6",
|
2022-10-24 16:16:29 +02:00
|
|
|
"keyword": "a2e9724acb221040d4b29bf9aa8cb75b2240d8af",
|
|
|
|
}),
|
|
|
|
("https://hentai2read.com/popuni_kei_joshi_panic/", {
|
|
|
|
"pattern": Hentai2readChapterExtractor.pattern,
|
|
|
|
"range": "2-3",
|
|
|
|
"keyword": {
|
|
|
|
"chapter": int,
|
|
|
|
"chapter_id": int,
|
|
|
|
"chapter_minor": ".5",
|
|
|
|
"lang": "en",
|
|
|
|
"language": "English",
|
|
|
|
"manga": "Popuni Kei Joshi Panic!",
|
|
|
|
"manga_id": 13088,
|
|
|
|
"title": str,
|
|
|
|
"type": "Original",
|
|
|
|
},
|
2019-02-11 18:38:47 +01:00
|
|
|
}),
|
|
|
|
)
|
|
|
|
|
|
|
|
def chapters(self, page):
|
|
|
|
results = []
|
2022-10-24 16:16:29 +02:00
|
|
|
|
|
|
|
pos = page.find('itemscope itemtype="http://schema.org/Book') + 1
|
2019-02-11 18:38:47 +01:00
|
|
|
manga, pos = text.extract(
|
2022-10-24 16:16:29 +02:00
|
|
|
page, '<span itemprop="name">', '</span>', pos)
|
2019-02-11 18:38:47 +01:00
|
|
|
mtype, pos = text.extract(
|
|
|
|
page, '<small class="text-danger">[', ']</small>', pos)
|
|
|
|
manga_id = text.parse_int(text.extract(
|
|
|
|
page, 'data-mid="', '"', pos)[0])
|
|
|
|
|
|
|
|
while True:
|
|
|
|
chapter_id, pos = text.extract(page, ' data-cid="', '"', pos)
|
|
|
|
if not chapter_id:
|
|
|
|
return results
|
|
|
|
_ , pos = text.extract(page, ' href="', '"', pos)
|
|
|
|
url, pos = text.extract(page, ' href="', '"', pos)
|
|
|
|
|
2022-10-24 16:16:29 +02:00
|
|
|
chapter, pos = text.extract(page, '>', '<', pos)
|
2019-02-11 18:38:47 +01:00
|
|
|
chapter, _, title = text.unescape(chapter).strip().partition(" - ")
|
2022-10-24 16:16:29 +02:00
|
|
|
chapter, sep, minor = chapter.partition(".")
|
|
|
|
|
2019-02-11 18:38:47 +01:00
|
|
|
results.append((url, {
|
2022-10-24 16:16:29 +02:00
|
|
|
"manga": manga,
|
|
|
|
"manga_id": manga_id,
|
2019-02-11 18:38:47 +01:00
|
|
|
"chapter": text.parse_int(chapter),
|
2022-10-24 16:16:29 +02:00
|
|
|
"chapter_minor": sep + minor,
|
|
|
|
"chapter_id": text.parse_int(chapter_id),
|
|
|
|
"type": mtype,
|
|
|
|
"title": title,
|
|
|
|
"lang": "en",
|
|
|
|
"language": "English",
|
2019-02-11 18:38:47 +01:00
|
|
|
}))
|