From 5a4bc1c6de4c4e925329d462bb15d97595bc4407 Mon Sep 17 00:00:00 2001 From: Alessandro Benetton Date: Sat, 1 Mar 2025 12:06:51 +0100 Subject: [PATCH] [cuttingedge] fix(Weebcentral): Handle case of chapter name with multiple number parts --- Tranga/MangaConnectors/WeebCentral.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Tranga/MangaConnectors/WeebCentral.cs b/Tranga/MangaConnectors/WeebCentral.cs index d4636d1..9b5fe98 100644 --- a/Tranga/MangaConnectors/WeebCentral.cs +++ b/Tranga/MangaConnectors/WeebCentral.cs @@ -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();