1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-26 04:32:51 +01:00

[hentai2read] fix manga metadata extraction

and update tests
This commit is contained in:
Mike Fährmann 2022-10-24 16:16:29 +02:00
parent f4d06e5180
commit d2fc73f20b
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -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://hentai2read.com/"""
"""Extractors for https://hentai2read.com/"""
from .common import ChapterExtractor, MangaExtractor
from .. import text
@ -30,8 +30,23 @@ class Hentai2readChapterExtractor(Hentai2readBase, ChapterExtractor):
"keyword": "85645b02d34aa11b3deb6dadd7536863476e1bad",
}),
("https://hentai2read.com/popuni_kei_joshi_panic/2.5/", {
"url": "454a2312238e3aa7d89dd118252f57c084e21d29",
"keyword": "1f244247ad9a801fce3671a4d88c21d4e5b3c7a3",
"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",
},
}),
)
@ -40,10 +55,10 @@ class Hentai2readChapterExtractor(Hentai2readBase, ChapterExtractor):
ChapterExtractor.__init__(self, match)
def metadata(self, page):
chapter, sep, minor = self.chapter.partition(".")
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)
chapter, sep, minor = self.chapter.partition(".")
match = re.match(r"Reading (.+) \(([^)]+)\) Hentai(?: by (.+))? - "
r"([^:]+): (.+) . Page 1 ", title)
return {
@ -74,18 +89,35 @@ class Hentai2readMangaExtractor(Hentai2readBase, MangaExtractor):
test = (
("https://hentai2read.com/amazon_elixir/", {
"url": "273073752d418ec887d7f7211e42b832e8c403ba",
"keyword": "85d55ecc3508e321a9b52f0b2241708ea7f06ffa",
"keyword": "5c1b712258e78e120907121d3987c71f834d13e1",
}),
("https://hentai2read.com/oshikage_riot/", {
"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):
results = []
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, '<small class="text-danger">[', ']</small>', pos)
manga_id = text.parse_int(text.extract(
@ -97,12 +129,19 @@ class Hentai2readMangaExtractor(Hentai2readBase, MangaExtractor):
return results
_ , 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, sep, minor = chapter.partition(".")
results.append((url, {
"manga_id": manga_id, "manga": manga, "type": mtype,
"chapter_id": text.parse_int(chapter_id),
"manga": manga,
"manga_id": manga_id,
"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",
}))