2
0

Merge pull request #84 from arxae/mangakatana_input_string_not_correct_format

Fixed input string not being in correct format
This commit is contained in:
Glax 2023-11-13 11:54:02 +01:00 committed by GitHub
commit e15717cb04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

3
.gitignore vendored
View File

@ -18,4 +18,5 @@ riderModule.iml
/dataSources.local.xml /dataSources.local.xml
/.idea /.idea
cover.jpg cover.jpg
cover.png cover.png
/.vscode

View File

@ -178,18 +178,17 @@ public class MangaKatana : MangaConnector
HtmlNode chapterList = document.DocumentNode.SelectSingleNode("//div[contains(@class, 'chapters')]/table/tbody"); HtmlNode chapterList = document.DocumentNode.SelectSingleNode("//div[contains(@class, 'chapters')]/table/tbody");
Regex volumeRex = new(@"Volume ([0-9]+)"); Regex volumeRex = new(@"[0-9a-z\-\.]+\/[0-9a-z\-]*v([0-9\.]+)");
Regex chapterNumRex = new(@"https:\/\/mangakatana\.com\/manga\/.+\/c([0-9\.]+)"); Regex chapterNumRex = new(@"[0-9a-z\-\.]+\/[0-9a-z\-]*c([0-9\.]+)");
Regex chapterNameRex = new(@"Chapter [0-9\.]+: (.*)"); Regex chapterNameRex = new(@"Chapter [0-9\.]+:? (.*)");
foreach (HtmlNode chapterInfo in chapterList.Descendants("tr")) foreach (HtmlNode chapterInfo in chapterList.Descendants("tr"))
{ {
string fullString = chapterInfo.Descendants("a").First().InnerText; string fullString = chapterInfo.Descendants("a").First().InnerText;
string url = chapterInfo.Descendants("a").First() string url = chapterInfo.Descendants("a").First()
.GetAttributeValue("href", ""); .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 chapterNumber = chapterNumRex.Match(url).Groups[1].Value;
string chapterName = chapterNameRex.Match(fullString).Groups[1].Value; string chapterName = chapterNameRex.Match(fullString).Groups[1].Value;
ret.Add(new Chapter(manga, chapterName, volumeNumber, chapterNumber, url)); ret.Add(new Chapter(manga, chapterName, volumeNumber, chapterNumber, url));