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

[batoto] fix crash when manga/chapter contains a '-' (#5200)

This commit is contained in:
Mike Fährmann 2024-02-16 00:10:08 +01:00
parent 0abd9723af
commit 24c1317e0d
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 27 additions and 2 deletions

View File

@ -40,10 +40,18 @@ class BatotoChapterExtractor(BatotoBase, ChapterExtractor):
def metadata(self, page):
extr = text.extract_from(page)
manga, info, _ = extr("<title>", "<").rsplit(" - ", 3)
try:
manga, info, _ = extr("<title>", "<").rsplit(" - ", 3)
except ValueError:
manga = info = None
manga_id = text.extr(
extr('rel="canonical" href="', '"'), "/title/", "/")
if not manga:
manga = extr('link-hover">', "<")
info = text.remove_html(extr('link-hover">', "</"))
match = re.match(
r"(?:Volume\s+(\d+) )?"
r"\w+\s+(\d+)(.*)", info)

View File

@ -42,6 +42,23 @@ __tests__ = (
"chapter": 5,
},
{
"#url" : "https://mto.to/chapter/2584460",
"#comment" : "'-' in manga title (#5200)",
"#category": ("", "batoto", "chapter"),
"#class" : batoto.BatotoChapterExtractor,
"chapter" : 9,
"chapter_id": 2584460,
"chapter_minor": "",
"count" : 18,
"date" : "dt:2023-11-26 11:01:12",
"manga" : "Isekai Teni shitara Aiken ga Saikyou ni narimashita - Silver Fenrir to Ore ga Isekai Kurashi wo Hajimetara (Official)",
"manga_id" : 126793,
"title" : "",
"volume" : 0
},
{
"#url" : "https://bato.to/title/86408/1681030",
"#category": ("", "batoto", "chapter"),
@ -85,7 +102,7 @@ __tests__ = (
"#class" : batoto.BatotoMangaExtractor,
"#count" : ">= 29",
"manga": "The Grand Dukes Fox Princess ⎝⎝MGCHAN⎠⎠",
"manga": "The Grand Dukes Fox Princess〖MGCHAN〗",
},
{