[hentaihere] update

- support minor versions in chapter URLs
- fix manga metadata extraction
- update tests
pull/2390/merge
Mike Fährmann 2 years ago
parent d2fc73f20b
commit 75d707fd92
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2019 Mike Fährmann
# Copyright 2016-2022 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 hentai-manga from https://hentaihere.com/"""
"""Extractors for https://hentaihere.com/"""
from .common import ChapterExtractor, MangaExtractor
from .. import text
@ -23,11 +23,28 @@ class HentaihereBase():
class HentaihereChapterExtractor(HentaihereBase, ChapterExtractor):
"""Extractor for a single manga chapter from hentaihere.com"""
archive_fmt = "{chapter_id}_{page}"
pattern = r"(?:https?://)?(?:www\.)?hentaihere\.com/m/S(\d+)/(\d+)"
test = ("https://hentaihere.com/m/S13812/1/1/", {
"url": "964b942cf492b3a129d2fe2608abfc475bc99e71",
"keyword": "cbcee0c0eb178c4b87f06a834085784f8dddad24",
})
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/", {
"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",
}),
)
def __init__(self, match):
self.manga_id, self.chapter = match.groups()
@ -37,12 +54,14 @@ class HentaihereChapterExtractor(HentaihereBase, ChapterExtractor):
def metadata(self, page):
title = text.extract(page, "<title>", "</title>")[0]
chapter_id = text.extract(page, 'report/C', '"')[0]
chapter, sep, minor = self.chapter.partition(".")
pattern = r"Page 1 \| (.+) \(([^)]+)\) - Chapter \d+: (.+) by (.+) at "
match = re.match(pattern, title)
return {
"manga": match.group(1),
"manga_id": text.parse_int(self.manga_id),
"chapter": text.parse_int(self.chapter),
"chapter": text.parse_int(chapter),
"chapter_minor": sep + minor,
"chapter_id": text.parse_int(chapter_id),
"type": match.group(2),
"title": match.group(3),
@ -67,22 +86,34 @@ class HentaihereMangaExtractor(HentaihereBase, MangaExtractor):
test = (
("https://hentaihere.com/m/S13812", {
"url": "d1ba6e28bb2162e844f8559c2b2725ba0a093559",
"keyword": "13c1ce7e15cbb941f01c843b0e89adc993d939ac",
"keyword": "5c1b712258e78e120907121d3987c71f834d13e1",
}),
("https://hentaihere.com/m/S7608", {
"url": "6c5239758dc93f6b1b4175922836c10391b174f7",
"keyword": "675c7b7a4fa52cf569c283553bd16b4200a5cd36",
"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",
},
}),
)
def chapters(self, page):
results = []
manga_id = text.parse_int(
self.manga_url.rstrip("/").rpartition("/")[2][1:])
pos = page.find('itemscope itemtype="http://schema.org/Book') + 1
manga, pos = text.extract(
page, '<span itemprop="name">', '</span>')
page, '<span itemprop="name">', '</span>', pos)
mtype, pos = text.extract(
page, '<span class="mngType text-danger">[', ']</span>', pos)
manga_id = text.parse_int(
self.manga_url.rstrip("/").rpartition("/")[2][1:])
while True:
marker, pos = text.extract(
@ -90,12 +121,20 @@ class HentaihereMangaExtractor(HentaihereBase, MangaExtractor):
if marker is None:
return results
url, pos = text.extract(page, '<a href="', '"', pos)
chapter, pos = text.extract(page, 'title="Tagged: -">\n', '<', pos)
chapter_id, pos = text.extract(page, '/C', '"', pos)
chapter, _, title = text.unescape(chapter).strip().partition(" - ")
chapter, sep, minor = chapter.partition(".")
results.append((url, {
"manga_id": manga_id, "manga": manga, "type": mtype,
"chapter_id": text.parse_int(chapter_id),
"manga_id": manga_id,
"manga": manga,
"chapter": text.parse_int(chapter),
"title": title, "lang": "en", "language": "English",
"chapter_minor": sep + minor,
"chapter_id": text.parse_int(chapter_id),
"type": mtype,
"title": title,
"lang": "en",
"language": "English",
}))

Loading…
Cancel
Save