[madokami] improve 'chapter_string' extraction (#7828)
This commit is contained in:
@@ -64,21 +64,25 @@ class MadokamiMangaExtractor(MadokamiExtractor):
|
|||||||
"complete": extr('span class="scanstatus">', "<").lower() == "yes",
|
"complete": extr('span class="scanstatus">', "<").lower() == "yes",
|
||||||
})
|
})
|
||||||
|
|
||||||
parse_chinfo = text.re(
|
search_chstr = text.re(
|
||||||
r"(?i).+?\s+("
|
r"(?i)((?:v(?:ol)?\.?\s*(\d+))"
|
||||||
r"(?:v(?:ol)?\.?\s*(\d+)\s+)?"
|
r"(?:\s+ch?\.?\s*(\d+)(?:-(\d+))?)?)").search
|
||||||
r"(?:ch?\.?\s*(\d+)(?:-(\d+))?)"
|
search_chstr_min = text.re(
|
||||||
r")"
|
r"(?i)(ch?\.?\s*(\d+)(?:-(\d+))?)").search
|
||||||
).match
|
|
||||||
|
|
||||||
for ch in chapters:
|
for ch in chapters:
|
||||||
|
|
||||||
chstr = ch["chapter_string"]
|
chstr = ch["chapter_string"]
|
||||||
if match := parse_chinfo(chstr):
|
if match := search_chstr(chstr):
|
||||||
ch["chapter_string"], volume, chapter, end = match.groups()
|
ch["chapter_string"], volume, chapter, end = match.groups()
|
||||||
ch["volume"] = text.parse_int(volume)
|
ch["volume"] = text.parse_int(volume)
|
||||||
ch["chapter"] = text.parse_int(chapter)
|
ch["chapter"] = text.parse_int(chapter)
|
||||||
ch["chapter_end"] = text.parse_int(end)
|
ch["chapter_end"] = text.parse_int(end)
|
||||||
|
elif match := search_chstr_min(chstr):
|
||||||
|
ch["chapter_string"], chapter, end = match.groups()
|
||||||
|
ch["volume"] = 0
|
||||||
|
ch["chapter"] = text.parse_int(chapter)
|
||||||
|
ch["chapter_end"] = text.parse_int(end)
|
||||||
else:
|
else:
|
||||||
ch["volume"] = ch["chapter"] = ch["chapter_end"] = 0
|
ch["volume"] = ch["chapter"] = ch["chapter_end"] = 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user