From 7c7d43021efe06093945b24bea155f4badfba984 Mon Sep 17 00:00:00 2001 From: Andy Maesen Date: Sun, 12 Nov 2023 05:38:06 +0100 Subject: [PATCH 1/2] Fixed input string not being in correct format --- .gitignore | 3 ++- Tranga/MangaConnectors/MangaKatana.cs | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index a471f98..456b786 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,5 @@ riderModule.iml /dataSources.local.xml /.idea cover.jpg -cover.png \ No newline at end of file +cover.png +/.vscode \ No newline at end of file diff --git a/Tranga/MangaConnectors/MangaKatana.cs b/Tranga/MangaConnectors/MangaKatana.cs index fa650cc..00fcb18 100644 --- a/Tranga/MangaConnectors/MangaKatana.cs +++ b/Tranga/MangaConnectors/MangaKatana.cs @@ -154,7 +154,7 @@ public class MangaKatana : MangaConnector //Return Chapters ordered by Chapter-Number List chapters = ParseChaptersFromHtml(manga, requestUrl); Log($"Got {chapters.Count} chapters. {manga}"); - return chapters.OrderBy(chapter => Convert.ToSingle(chapter.chapterNumber, numberFormatDecimalPoint)).ToArray(); + return chapters.OrderBy(chapter => chapter.chapterNumber ?? chapter.volumeNumber).ToArray(); } private List ParseChaptersFromHtml(Manga manga, string mangaUrl) @@ -167,9 +167,9 @@ public class MangaKatana : MangaConnector HtmlNode chapterList = document.DocumentNode.SelectSingleNode("//div[contains(@class, 'chapters')]/table/tbody"); - Regex volumeRex = new(@"Volume ([0-9]+)"); - Regex chapterNumRex = new(@"https:\/\/mangakatana\.com\/manga\/.+\/c([0-9\.]+)"); - Regex chapterNameRex = new(@"Chapter [0-9\.]+: (.*)"); + Regex volumeRex = new(@"(Volume ([0-9]+))|(Vol\.[0-9]+)"); + Regex chapterNumRex = new(@"https:\/\/mangakatana\.com\/manga\/.+\/(c([0-9\.]+))|(v[0-9]+c[0-9]+)"); + Regex chapterNameRex = new(@"Chapter [0-9\.]+:? (.*)"); foreach (HtmlNode chapterInfo in chapterList.Descendants("tr")) From b995fc568a631fdd36299838309603e6416d5cea Mon Sep 17 00:00:00 2001 From: Andy Maesen Date: Mon, 13 Nov 2023 06:49:20 +0100 Subject: [PATCH 2/2] Requested changes --- Tranga/MangaConnectors/MangaKatana.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Tranga/MangaConnectors/MangaKatana.cs b/Tranga/MangaConnectors/MangaKatana.cs index 00fcb18..7b7cde0 100644 --- a/Tranga/MangaConnectors/MangaKatana.cs +++ b/Tranga/MangaConnectors/MangaKatana.cs @@ -154,7 +154,7 @@ public class MangaKatana : MangaConnector //Return Chapters ordered by Chapter-Number List chapters = ParseChaptersFromHtml(manga, requestUrl); Log($"Got {chapters.Count} chapters. {manga}"); - return chapters.OrderBy(chapter => chapter.chapterNumber ?? chapter.volumeNumber).ToArray(); + return chapters.OrderBy(chapter => Convert.ToSingle(chapter.chapterNumber, numberFormatDecimalPoint)).ToArray(); } private List ParseChaptersFromHtml(Manga manga, string mangaUrl) @@ -167,18 +167,17 @@ public class MangaKatana : MangaConnector HtmlNode chapterList = document.DocumentNode.SelectSingleNode("//div[contains(@class, 'chapters')]/table/tbody"); - Regex volumeRex = new(@"(Volume ([0-9]+))|(Vol\.[0-9]+)"); - Regex chapterNumRex = new(@"https:\/\/mangakatana\.com\/manga\/.+\/(c([0-9\.]+))|(v[0-9]+c[0-9]+)"); + Regex volumeRex = new(@"[0-9a-z\-\.]+\/[0-9a-z\-]*v([0-9\.]+)"); + Regex chapterNumRex = new(@"[0-9a-z\-\.]+\/[0-9a-z\-]*c([0-9\.]+)"); Regex chapterNameRex = new(@"Chapter [0-9\.]+:? (.*)"); - foreach (HtmlNode chapterInfo in chapterList.Descendants("tr")) { string fullString = chapterInfo.Descendants("a").First().InnerText; string url = chapterInfo.Descendants("a").First() .GetAttributeValue("href", ""); - string? volumeNumber = volumeRex.IsMatch(fullString) ? volumeRex.Match(fullString).Groups[1].Value : null; + string? volumeNumber = volumeRex.IsMatch(url) ? volumeRex.Match(url).Groups[1].Value : null; string chapterNumber = chapterNumRex.Match(url).Groups[1].Value; string chapterName = chapterNameRex.Match(fullString).Groups[1].Value; ret.Add(new Chapter(manga, chapterName, volumeNumber, chapterNumber, url));