[cuttingedge] fix(Weebcentral): Handle case of chapter name with multiple number parts

This commit is contained in:
Alessandro Benetton 2025-03-01 12:06:51 +01:00
parent 71f663ca2f
commit 5a4bc1c6de
No known key found for this signature in database
GPG Key ID: ED63A304CE2C0303

View File

@ -164,10 +164,14 @@ public class Weebcentral : MangaConnector
string chapterNode = elem.SelectSingleNode("span[@class='grow flex items-center gap-2']/span")?.InnerText ??
"Undefined";
Match chapterNumberMatch = chapterRex.Match(chapterNode);
string chapterNumber = chapterNumberMatch.Success ? chapterNumberMatch.Groups[1].Value : "-1";
Match chapterNameMatch = chapterNameRex.Match(chapterNode);
string chapterName = chapterNameMatch.Success ? chapterNameMatch.Groups[1].Value.Trim() : "";
MatchCollection chapterNumberMatch = chapterRex.Matches(chapterNode);
string chapterNumber = chapterNumberMatch.Count > 0 ? chapterNumberMatch[^1].Groups[1].Value : "-1";
MatchCollection chapterNameMatch = chapterNameRex.Matches(chapterNode);
string chapterName = chapterNameMatch.Count > 0
? string.Join(" - ",
chapterNameMatch.Select(m => m.Groups[1].Value.Trim())
.Where(name => name.Length > 0 && !name.Equals("Chapter", StringComparison.OrdinalIgnoreCase)).ToArray()).Trim()
: "";
return new Chapter(manga, chapterName != "" ? chapterName : null, null, chapterNumber, url, id);
}).Where(elem => elem.chapterNumber != -1 && elem.url != "undefined").ToList();