From 903bb5af5e931544c654b6691346719a603afc12 Mon Sep 17 00:00:00 2001 From: glax Date: Wed, 3 Jan 2024 17:05:33 +0100 Subject: [PATCH] Resolves #97 Manga4Life Volume Numbers --- Tranga/MangaConnectors/MangaLife.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Tranga/MangaConnectors/MangaLife.cs b/Tranga/MangaConnectors/MangaLife.cs index 19b9ced..1e3f924 100644 --- a/Tranga/MangaConnectors/MangaLife.cs +++ b/Tranga/MangaConnectors/MangaLife.cs @@ -142,12 +142,17 @@ public class MangaLife : MangaConnector HtmlNodeCollection chapterNodes = result.htmlDocument.DocumentNode.SelectNodes( "//a[contains(concat(' ',normalize-space(@class),' '),' ChapterLink ')]"); string[] urls = chapterNodes.Select(node => node.GetAttributeValue("href", "")).ToArray(); + Regex urlRex = new Regex(@"-chapter-([0-9\\.]+)(-index-([0-9\\.]+))?"); List chapters = new(); foreach (string url in urls) { + Match rexMatch = urlRex.Match(url); + string volumeNumber = "1"; - string chapterNumber = Regex.Match(url, @"-chapter-([0-9\.]+)").Groups[1].ToString(); + if (rexMatch.Groups.Count == 4) + volumeNumber = rexMatch.Groups[3].ToString(); + string chapterNumber = rexMatch.Groups[1].ToString(); string fullUrl = $"https://manga4life.com{url}"; fullUrl = fullUrl.Replace(Regex.Match(url,"(-page-[0-9])").Value,""); chapters.Add(new Chapter(manga, "", volumeNumber, chapterNumber, fullUrl));