Skip to content

Commit

Permalink
#78 Manganato chapternumber parsing from url
Browse files Browse the repository at this point in the history
  • Loading branch information
C9Glax committed Nov 1, 2023
1 parent 733ae28 commit 8f5dd5a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Tranga/MangaConnectors/Manganato.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,18 @@ private List<Chapter> ParseChaptersFromHtml(Manga manga, HtmlDocument document)
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 chapterRex = new(@"https:\/\/chapmanganato.com/manga-[A-z0-9]+\/chapter-([0-9\.]+)");
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 = volRex.IsMatch(fullString) ? volRex.Match(fullString).Groups[1].Value : null;
string chapterNumber = chapterRex.IsMatch(fullString) ? chapterRex.Match(fullString).Groups[1].Value : fullString;
string chapterName = nameRex.Match(fullString).Groups[3].Value;
string url = chapterInfo.Descendants("a").First(d => d.HasClass("chapter-name"))
.GetAttributeValue("href", "");
string? volumeNumber = volRex.IsMatch(fullString) ? volRex.Match(fullString).Groups[1].Value : null;
string chapterNumber = chapterRex.Match(url).Groups[1].Value;
string chapterName = nameRex.Match(fullString).Groups[3].Value;
ret.Add(new Chapter(manga, chapterName, volumeNumber, chapterNumber, url));
}
ret.Reverse();
Expand Down

0 comments on commit 8f5dd5a

Please sign in to comment.