From d6b5a29fdca43e231d3db441086c498509068c55 Mon Sep 17 00:00:00 2001 From: glax Date: Wed, 13 Sep 2023 21:47:50 +0200 Subject: [PATCH] Fix Manganato kaguya-bug: volumenumber, chapternumber, chaptername match --- Tranga/MangaConnectors/Manganato.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Tranga/MangaConnectors/Manganato.cs b/Tranga/MangaConnectors/Manganato.cs index 3f9b818..06af92a 100644 --- a/Tranga/MangaConnectors/Manganato.cs +++ b/Tranga/MangaConnectors/Manganato.cs @@ -150,13 +150,17 @@ public class Manganato : MangaConnector HtmlNode chapterList = document.DocumentNode.Descendants("ul").First(l => l.HasClass("row-content-chapter")); + Regex volRex = new(@"Vol\.([0-9]+).*"); + Regex chapterRex = new(@"Chapter ([0-9]+(\.[0-9]+)*){1}.*"); + Regex nameRex = new(@"Chapter ([0-9]+(\.[0-9]+)*){1}:? (.*)"); + foreach (HtmlNode chapterInfo in chapterList.Descendants("li")) { string fullString = chapterInfo.Descendants("a").First(d => d.HasClass("chapter-name")).InnerText; - string? volumeNumber = fullString.Contains("Vol.") ? fullString.Replace("Vol.", "").Split(' ')[0] : null; - string chapterNumber = fullString.Split(':')[0].Split("Chapter ")[1].Replace('-','.'); - string chapterName = string.Concat(fullString.Split(':')[1..]); + string? volumeNumber = volRex.IsMatch(fullString) ? volRex.Match(fullString).Groups[1].Value : null; + string chapterNumber = chapterRex.Match(fullString).Groups[1].Value; + string chapterName = nameRex.Match(fullString).Groups[3].Value; string url = chapterInfo.Descendants("a").First(d => d.HasClass("chapter-name")) .GetAttributeValue("href", ""); ret.Add(new Chapter(manga, chapterName, volumeNumber, chapterNumber, url));