merge #5997: [batoto] improve chapter info regex (#5988)

… and add 'chapter_string' metadata
This commit is contained in:
Mike Fährmann
2024-08-12 17:54:17 +02:00
2 changed files with 25 additions and 11 deletions

View File

@@ -51,28 +51,30 @@ class BatotoChapterExtractor(BatotoBase, ChapterExtractor):
if not manga:
manga = extr('link-hover">', "<")
info = text.remove_html(extr('link-hover">', "</"))
info = text.unescape(info)
match = re.match(
r"(?:Volume\s+(\d+) )?"
r"\w+\s+(\d+)(.*)", info)
r"[Cc]hapter\s*(\d+)([\w.]*)", info)
if match:
volume, chapter, minor = match.groups()
title = text.remove_html(extr(
"selected>", "</option")).partition(" : ")[2]
title = text.unescape(text.remove_html(extr(
"selected>", "</option")).partition(" : ")[2])
else:
volume = chapter = 0
minor = ""
title = info
return {
"manga" : text.unescape(manga),
"manga_id" : text.parse_int(manga_id),
"title" : text.unescape(title),
"volume" : text.parse_int(volume),
"chapter" : text.parse_int(chapter),
"chapter_minor": minor,
"chapter_id" : text.parse_int(self.chapter_id),
"date" : text.parse_timestamp(extr(' time="', '"')[:-3]),
"manga" : text.unescape(manga),
"manga_id" : text.parse_int(manga_id),
"title" : title,
"volume" : text.parse_int(volume),
"chapter" : text.parse_int(chapter),
"chapter_minor" : minor,
"chapter_string": info,
"chapter_id" : text.parse_int(self.chapter_id),
"date" : text.parse_timestamp(extr(' time="', '"')[:-3]),
}
def images(self, page):

View File

@@ -59,6 +59,18 @@ __tests__ = (
"volume" : 0
},
{
"#url" : "https://bato.to/title/90710-new-suitor-for-the-abandoned-wife/2089747-ch_76",
"#comment" : "duplicate info in chapter_minor / title (#5988)",
"#category": ("", "batoto", "chapter"),
"#class" : batoto.BatotoChapterExtractor,
"chapter" : 76,
"chapter_id" : 2089747,
"chapter_minor": "",
"title" : "Side Story 4 [END]",
},
{
"#url" : "https://bato.to/title/86408/1681030",
"#category": ("", "batoto", "chapter"),