[hentai2read] fix manga metadata extraction
and update tests
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- 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
|
# 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
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
"""Extract hentai-manga from https://hentai2read.com/"""
|
"""Extractors for https://hentai2read.com/"""
|
||||||
|
|
||||||
from .common import ChapterExtractor, MangaExtractor
|
from .common import ChapterExtractor, MangaExtractor
|
||||||
from .. import text
|
from .. import text
|
||||||
@@ -30,8 +30,23 @@ class Hentai2readChapterExtractor(Hentai2readBase, ChapterExtractor):
|
|||||||
"keyword": "85645b02d34aa11b3deb6dadd7536863476e1bad",
|
"keyword": "85645b02d34aa11b3deb6dadd7536863476e1bad",
|
||||||
}),
|
}),
|
||||||
("https://hentai2read.com/popuni_kei_joshi_panic/2.5/", {
|
("https://hentai2read.com/popuni_kei_joshi_panic/2.5/", {
|
||||||
"url": "454a2312238e3aa7d89dd118252f57c084e21d29",
|
"pattern": r"https://hentaicdn\.com/hentai"
|
||||||
"keyword": "1f244247ad9a801fce3671a4d88c21d4e5b3c7a3",
|
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",
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -40,10 +55,10 @@ class Hentai2readChapterExtractor(Hentai2readBase, ChapterExtractor):
|
|||||||
ChapterExtractor.__init__(self, match)
|
ChapterExtractor.__init__(self, match)
|
||||||
|
|
||||||
def metadata(self, page):
|
def metadata(self, page):
|
||||||
chapter, sep, minor = self.chapter.partition(".")
|
|
||||||
title, pos = text.extract(page, "<title>", "</title>")
|
title, pos = text.extract(page, "<title>", "</title>")
|
||||||
manga_id, pos = text.extract(page, 'data-mid="', '"', pos)
|
manga_id, pos = text.extract(page, 'data-mid="', '"', pos)
|
||||||
chapter_id, pos = text.extract(page, 'data-cid="', '"', pos)
|
chapter_id, pos = text.extract(page, 'data-cid="', '"', pos)
|
||||||
|
chapter, sep, minor = self.chapter.partition(".")
|
||||||
match = re.match(r"Reading (.+) \(([^)]+)\) Hentai(?: by (.+))? - "
|
match = re.match(r"Reading (.+) \(([^)]+)\) Hentai(?: by (.+))? - "
|
||||||
r"([^:]+): (.+) . Page 1 ", title)
|
r"([^:]+): (.+) . Page 1 ", title)
|
||||||
return {
|
return {
|
||||||
@@ -74,18 +89,35 @@ class Hentai2readMangaExtractor(Hentai2readBase, MangaExtractor):
|
|||||||
test = (
|
test = (
|
||||||
("https://hentai2read.com/amazon_elixir/", {
|
("https://hentai2read.com/amazon_elixir/", {
|
||||||
"url": "273073752d418ec887d7f7211e42b832e8c403ba",
|
"url": "273073752d418ec887d7f7211e42b832e8c403ba",
|
||||||
"keyword": "85d55ecc3508e321a9b52f0b2241708ea7f06ffa",
|
"keyword": "5c1b712258e78e120907121d3987c71f834d13e1",
|
||||||
}),
|
}),
|
||||||
("https://hentai2read.com/oshikage_riot/", {
|
("https://hentai2read.com/oshikage_riot/", {
|
||||||
"url": "6595f920a3088a15c2819c502862d45f8eb6bea6",
|
"url": "6595f920a3088a15c2819c502862d45f8eb6bea6",
|
||||||
"keyword": "4aa8d9d7c4a92f2f9d39bc33eee4b0773fcbe887",
|
"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",
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
def chapters(self, page):
|
def chapters(self, page):
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
|
pos = page.find('itemscope itemtype="http://schema.org/Book') + 1
|
||||||
manga, pos = text.extract(
|
manga, pos = text.extract(
|
||||||
page, '<span itemprop="name">', '</span>')
|
page, '<span itemprop="name">', '</span>', pos)
|
||||||
mtype, pos = text.extract(
|
mtype, pos = text.extract(
|
||||||
page, '<small class="text-danger">[', ']</small>', pos)
|
page, '<small class="text-danger">[', ']</small>', pos)
|
||||||
manga_id = text.parse_int(text.extract(
|
manga_id = text.parse_int(text.extract(
|
||||||
@@ -97,12 +129,19 @@ class Hentai2readMangaExtractor(Hentai2readBase, MangaExtractor):
|
|||||||
return results
|
return results
|
||||||
_ , pos = text.extract(page, ' href="', '"', pos)
|
_ , pos = text.extract(page, ' href="', '"', pos)
|
||||||
url, pos = text.extract(page, ' href="', '"', pos)
|
url, pos = text.extract(page, ' href="', '"', pos)
|
||||||
chapter, pos = text.extract(page, '>', '<', pos)
|
|
||||||
|
|
||||||
|
chapter, pos = text.extract(page, '>', '<', pos)
|
||||||
chapter, _, title = text.unescape(chapter).strip().partition(" - ")
|
chapter, _, title = text.unescape(chapter).strip().partition(" - ")
|
||||||
|
chapter, sep, minor = chapter.partition(".")
|
||||||
|
|
||||||
results.append((url, {
|
results.append((url, {
|
||||||
"manga_id": manga_id, "manga": manga, "type": mtype,
|
"manga": manga,
|
||||||
"chapter_id": text.parse_int(chapter_id),
|
"manga_id": manga_id,
|
||||||
"chapter": text.parse_int(chapter),
|
"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",
|
||||||
}))
|
}))
|
||||||
|
|||||||
Reference in New Issue
Block a user