2016-10-05 09:20:03 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2023-02-07 23:14:53 +01:00
|
|
|
# Copyright 2016-2023 Mike Fährmann
|
2016-10-05 09:20:03 +02: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:41:22 +02:00
|
|
|
"""Extractors for https://hentaihere.com/"""
|
2016-10-05 09:20:03 +02: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-08 13:45:40 +01:00
|
|
|
import re
|
2016-10-05 09:20:03 +02:00
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2019-02-11 18:38:47 +01:00
|
|
|
class HentaihereBase():
|
|
|
|
"""Base class for hentaihere extractors"""
|
2016-10-05 09:20:03 +02:00
|
|
|
category = "hentaihere"
|
2019-02-11 18:38:47 +01:00
|
|
|
root = "https://hentaihere.com"
|
2016-10-05 09:20:03 +02:00
|
|
|
|
2017-09-20 12:26:53 +02:00
|
|
|
|
2019-02-11 18:38:47 +01:00
|
|
|
class HentaihereChapterExtractor(HentaihereBase, ChapterExtractor):
|
2016-10-05 09:20:03 +02:00
|
|
|
"""Extractor for a single manga chapter from hentaihere.com"""
|
2018-02-12 23:09:34 +01:00
|
|
|
archive_fmt = "{chapter_id}_{page}"
|
2022-10-24 16:41:22 +02:00
|
|
|
pattern = r"(?:https?://)?(?:www\.)?hentaihere\.com/m/S(\d+)/([^/?#]+)"
|
|
|
|
test = (
|
|
|
|
("https://hentaihere.com/m/S13812/1/1/", {
|
|
|
|
"url": "964b942cf492b3a129d2fe2608abfc475bc99e71",
|
|
|
|
"keyword": "0207d20eea3a15d2a8d1496755bdfa49de7cfa9d",
|
|
|
|
}),
|
|
|
|
("https://hentaihere.com/m/S23048/1.5/1/", {
|
2022-10-24 16:55:39 +02:00
|
|
|
"pattern": r"https://hentaicdn\.com/hentai"
|
|
|
|
r"/23048/1\.5/ccdn00\d+\.jpg",
|
2022-10-24 16:41:22 +02:00
|
|
|
"count": 32,
|
2022-10-24 16:55:39 +02:00
|
|
|
"keyword": {
|
|
|
|
"author": "Shinozuka Yuuji",
|
|
|
|
"chapter": 1,
|
|
|
|
"chapter_id": 80186,
|
|
|
|
"chapter_minor": ".5",
|
|
|
|
"count": 32,
|
|
|
|
"lang": "en",
|
|
|
|
"language": "English",
|
|
|
|
"manga": "High School Slut's Love Consultation",
|
|
|
|
"manga_id": 23048,
|
|
|
|
"page": int,
|
|
|
|
"title": "High School Slut's Love Consultation + "
|
|
|
|
"Girlfriend [Full Color]",
|
|
|
|
"type": "Original",
|
|
|
|
},
|
2022-10-24 16:41:22 +02:00
|
|
|
}),
|
|
|
|
)
|
2016-10-05 09:20:03 +02:00
|
|
|
|
|
|
|
def __init__(self, match):
|
2018-02-07 11:22:47 +01:00
|
|
|
self.manga_id, self.chapter = match.groups()
|
2019-02-11 18:38:47 +01:00
|
|
|
url = "{}/m/S{}/{}/1".format(self.root, self.manga_id, self.chapter)
|
2019-02-11 13:31:10 +01:00
|
|
|
ChapterExtractor.__init__(self, match, url)
|
2016-10-05 09:20:03 +02:00
|
|
|
|
2019-02-11 18:38:47 +01:00
|
|
|
def metadata(self, page):
|
2022-11-04 23:39:38 +01:00
|
|
|
title = text.extr(page, "<title>", "</title>")
|
|
|
|
chapter_id = text.extr(page, 'report/C', '"')
|
2022-10-24 16:41:22 +02:00
|
|
|
chapter, sep, minor = self.chapter.partition(".")
|
2016-10-05 09:20:03 +02:00
|
|
|
pattern = r"Page 1 \| (.+) \(([^)]+)\) - Chapter \d+: (.+) by (.+) at "
|
|
|
|
match = re.match(pattern, title)
|
|
|
|
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(self.manga_id),
|
2022-10-24 16:41:22 +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),
|
2016-10-05 09:20:03 +02:00
|
|
|
"type": match.group(2),
|
2017-08-22 13:51:00 +02:00
|
|
|
"title": match.group(3),
|
2016-10-05 09:20:03 +02:00
|
|
|
"author": match.group(4),
|
|
|
|
"lang": "en",
|
|
|
|
"language": "English",
|
|
|
|
}
|
2018-02-07 11:22:47 +01:00
|
|
|
|
|
|
|
@staticmethod
|
2019-02-11 18:38:47 +01:00
|
|
|
def images(page):
|
2022-11-04 23:39:38 +01:00
|
|
|
images = text.extr(page, "var rff_imageList = ", ";")
|
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 HentaihereMangaExtractor(HentaihereBase, MangaExtractor):
|
|
|
|
"""Extractor for hmanga from hentaihere.com"""
|
2019-02-13 13:23:36 +01:00
|
|
|
chapterclass = HentaihereChapterExtractor
|
2019-02-11 18:38:47 +01:00
|
|
|
pattern = r"(?:https?://)?(?:www\.)?hentaihere\.com(/m/S\d+)/?$"
|
|
|
|
test = (
|
|
|
|
("https://hentaihere.com/m/S13812", {
|
|
|
|
"url": "d1ba6e28bb2162e844f8559c2b2725ba0a093559",
|
2022-10-24 16:41:22 +02:00
|
|
|
"keyword": "5c1b712258e78e120907121d3987c71f834d13e1",
|
2019-02-11 18:38:47 +01:00
|
|
|
}),
|
|
|
|
("https://hentaihere.com/m/S7608", {
|
|
|
|
"url": "6c5239758dc93f6b1b4175922836c10391b174f7",
|
2022-10-24 16:41:22 +02:00
|
|
|
"keyword": {
|
|
|
|
"chapter": int,
|
|
|
|
"chapter_id": int,
|
|
|
|
"chapter_minor": "",
|
|
|
|
"lang": "en",
|
|
|
|
"language": "English",
|
|
|
|
"manga": "Oshikake Riot",
|
|
|
|
"manga_id": 7608,
|
|
|
|
"title": r"re:Oshikake Riot( \d+)?",
|
|
|
|
"type": "Original",
|
|
|
|
},
|
2019-02-11 18:38:47 +01:00
|
|
|
}),
|
|
|
|
)
|
|
|
|
|
|
|
|
def chapters(self, page):
|
|
|
|
results = []
|
2022-10-24 16:41:22 +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:41:22 +02:00
|
|
|
page, '<span itemprop="name">', '</span>', pos)
|
2019-02-11 18:38:47 +01:00
|
|
|
mtype, pos = text.extract(
|
|
|
|
page, '<span class="mngType text-danger">[', ']</span>', pos)
|
2022-10-24 16:41:22 +02:00
|
|
|
manga_id = text.parse_int(
|
|
|
|
self.manga_url.rstrip("/").rpartition("/")[2][1:])
|
2019-02-11 18:38:47 +01:00
|
|
|
|
|
|
|
while True:
|
|
|
|
marker, pos = text.extract(
|
|
|
|
page, '<li class="sub-chp clearfix">', '', pos)
|
|
|
|
if marker is None:
|
|
|
|
return results
|
|
|
|
url, pos = text.extract(page, '<a href="', '"', pos)
|
2022-10-24 16:41:22 +02:00
|
|
|
|
2019-02-11 18:38:47 +01:00
|
|
|
chapter, pos = text.extract(page, 'title="Tagged: -">\n', '<', pos)
|
|
|
|
chapter_id, pos = text.extract(page, '/C', '"', pos)
|
|
|
|
chapter, _, title = text.unescape(chapter).strip().partition(" - ")
|
2022-10-24 16:41:22 +02:00
|
|
|
chapter, sep, minor = chapter.partition(".")
|
|
|
|
|
2019-02-11 18:38:47 +01:00
|
|
|
results.append((url, {
|
2022-10-24 16:41:22 +02:00
|
|
|
"manga_id": manga_id,
|
|
|
|
"manga": manga,
|
2019-02-11 18:38:47 +01:00
|
|
|
"chapter": text.parse_int(chapter),
|
2022-10-24 16:41:22 +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
|
|
|
}))
|