mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-13 23:07:53 +02:00
Fix #307 Chapternumbers
ChapterNumbers now can be sub-decimal, like version-numbers (x.y.z.a...)
This commit is contained in:
@ -152,7 +152,9 @@ public class AsuraToon : MangaConnector
|
||||
string chapterUrl = chapterInfo.GetAttributeValue("href", "");
|
||||
|
||||
Match match = infoRex.Match(chapterInfo.InnerText);
|
||||
float chapterNumber = float.Parse(match.Groups[1].Value);
|
||||
if(!ChapterNumber.CanParse(match.Groups[1].Value))
|
||||
continue;
|
||||
ChapterNumber chapterNumber = new(match.Groups[1].Value);
|
||||
string? chapterName = match.Groups[2].Success && match.Groups[2].Length > 1 ? match.Groups[2].Value : null;
|
||||
string url = $"https://asuracomic.net/series/{chapterUrl}";
|
||||
try
|
||||
|
@ -158,8 +158,10 @@ public class Bato : MangaConnector
|
||||
|
||||
Match match = numberRex.Match(chapterUrl);
|
||||
string id = match.Groups[1].Value;
|
||||
float? volumeNumber = match.Groups[2].Success ? float.Parse(match.Groups[2].Value) : null;
|
||||
float chapterNumber = float.Parse(match.Groups[3].Value);
|
||||
int? volumeNumber = match.Groups[2].Success ? int.Parse(match.Groups[2].Value) : null;
|
||||
if(ChapterNumber.CanParse(match.Groups[3].Value))
|
||||
continue;
|
||||
ChapterNumber chapterNumber = new(match.Groups[3].Value);
|
||||
string url = $"https://bato.to{chapterUrl}?load=2";
|
||||
try
|
||||
{
|
||||
|
@ -221,13 +221,17 @@ public class MangaDex : MangaConnector
|
||||
? attributes["title"]!.GetValue<string>()
|
||||
: null;
|
||||
|
||||
float? volume = attributes.ContainsKey("volume") && attributes["volume"] is not null
|
||||
? float.Parse(attributes["volume"]!.GetValue<string>())
|
||||
int? volume = attributes.ContainsKey("volume") && attributes["volume"] is not null
|
||||
? int.Parse(attributes["volume"]!.GetValue<string>())
|
||||
: null;
|
||||
|
||||
float chapterNum = attributes.ContainsKey("chapter") && attributes["chapter"] is not null
|
||||
? float.Parse(attributes["chapter"]!.GetValue<string>())
|
||||
: 0;
|
||||
string? chapterNumStr = attributes.ContainsKey("chapter") && attributes["chapter"] is not null
|
||||
? attributes["chapter"]!.GetValue<string>()
|
||||
: null;
|
||||
|
||||
if(chapterNumStr is null || ChapterNumber.CanParse(chapterNumStr))
|
||||
continue;
|
||||
ChapterNumber chapterNumber = new(chapterNumStr);
|
||||
|
||||
|
||||
if (attributes.ContainsKey("pages") && attributes["pages"] is not null &&
|
||||
@ -238,7 +242,7 @@ public class MangaDex : MangaConnector
|
||||
|
||||
try
|
||||
{
|
||||
Chapter newChapter = new Chapter(manga, url, chapterNum, volume, title);
|
||||
Chapter newChapter = new Chapter(manga, url, chapterNumber, volume, title);
|
||||
if(!chapters.Contains(newChapter))
|
||||
chapters.Add(newChapter);
|
||||
}
|
||||
|
@ -127,8 +127,10 @@ public class MangaHere : MangaConnector
|
||||
{
|
||||
Match rexMatch = chapterRex.Match(url);
|
||||
|
||||
float? volumeNumber = rexMatch.Groups[1].Value == "TBD" ? null : float.Parse(rexMatch.Groups[1].Value);
|
||||
float chapterNumber = float.Parse(rexMatch.Groups[2].Value);
|
||||
int? volumeNumber = rexMatch.Groups[1].Value == "TBD" ? null : int.Parse(rexMatch.Groups[1].Value);
|
||||
if(!ChapterNumber.CanParse(rexMatch.Groups[2].Value))
|
||||
continue;
|
||||
ChapterNumber chapterNumber = new(rexMatch.Groups[2].Value);
|
||||
string fullUrl = $"https://www.mangahere.cc{url}";
|
||||
|
||||
try
|
||||
|
@ -184,8 +184,10 @@ public class MangaKatana : MangaConnector
|
||||
string url = chapterInfo.Descendants("a").First()
|
||||
.GetAttributeValue("href", "");
|
||||
|
||||
float? volumeNumber = volumeRex.IsMatch(url) ? float.Parse(volumeRex.Match(url).Groups[1].Value) : null;
|
||||
float chapterNumber = float.Parse(chapterNumRex.Match(url).Groups[1].Value);
|
||||
int? volumeNumber = volumeRex.IsMatch(url) ? int.Parse(volumeRex.Match(url).Groups[1].Value) : null;
|
||||
if(!ChapterNumber.CanParse(chapterNumRex.Match(url).Groups[1].Value))
|
||||
continue;
|
||||
ChapterNumber chapterNumber = new(chapterNumRex.Match(url).Groups[1].Value);
|
||||
string chapterName = chapterNameRex.Match(fullString).Groups[1].Value;
|
||||
try
|
||||
{
|
||||
|
@ -147,9 +147,13 @@ public class MangaLife : MangaConnector
|
||||
{
|
||||
Match rexMatch = urlRex.Match(url);
|
||||
|
||||
float? volumeNumber = rexMatch.Groups[3].Success && rexMatch.Groups[3].Value.Length > 0 ?
|
||||
float.Parse(rexMatch.Groups[3].Value) : null;
|
||||
float chapterNumber = float.Parse(rexMatch.Groups[1].Value);
|
||||
int? volumeNumber = rexMatch.Groups[3].Success && rexMatch.Groups[3].Value.Length > 0
|
||||
? int.Parse(rexMatch.Groups[3].Value)
|
||||
: null;
|
||||
|
||||
if(!ChapterNumber.CanParse(rexMatch.Groups[1].Value))
|
||||
continue;
|
||||
ChapterNumber chapterNumber = new(rexMatch.Groups[1].Value);
|
||||
string fullUrl = $"https://manga4life.com{url}";
|
||||
fullUrl = fullUrl.Replace(Regex.Match(url,"(-page-[0-9])").Value,"");
|
||||
try
|
||||
|
@ -178,8 +178,12 @@ public class Manganato : MangaConnector
|
||||
string url = chapterInfo.Descendants("a").First(d => d.HasClass("chapter-name"))
|
||||
.GetAttributeValue("href", "");
|
||||
|
||||
float? volumeNumber = volRex.IsMatch(fullString) ? float.Parse(volRex.Match(fullString).Groups[1].Value) : null;
|
||||
float chapterNumber = float.Parse(chapterRex.Match(url).Groups[1].Value);
|
||||
int? volumeNumber = volRex.IsMatch(fullString)
|
||||
? int.Parse(volRex.Match(fullString).Groups[1].Value)
|
||||
: null;
|
||||
if(!ChapterNumber.CanParse(chapterRex.Match(url).Groups[1].Value))
|
||||
continue;
|
||||
ChapterNumber chapterNumber = new(chapterRex.Match(url).Groups[1].Value);
|
||||
string chapterName = nameRex.Match(fullString).Groups[3].Value;
|
||||
try
|
||||
{
|
||||
|
@ -171,8 +171,10 @@ public class Mangasee : MangaConnector
|
||||
{
|
||||
string url = chapter.Descendants("link").First().Value;
|
||||
Match m = chVolRex.Match(url);
|
||||
float? volumeNumber = m.Groups[2].Success ? float.Parse(m.Groups[2].Value) : null;
|
||||
float chapterNumber = float.Parse(m.Groups[1].Value);
|
||||
int? volumeNumber = m.Groups[2].Success ? int.Parse(m.Groups[2].Value) : null;
|
||||
if(!ChapterNumber.CanParse(m.Groups[1].Value))
|
||||
continue;
|
||||
ChapterNumber chapterNumber = new(m.Groups[1].Value);
|
||||
|
||||
string chapterUrl = Regex.Replace(url, @"-page-[0-9]+(\.html)", ".html");
|
||||
try
|
||||
|
@ -154,17 +154,19 @@ public class Mangaworld : MangaConnector
|
||||
foreach (HtmlNode volNode in document.DocumentNode.SelectNodes("//div[contains(concat(' ',normalize-space(@class),' '),'volume-element')]"))
|
||||
{
|
||||
string volumeStr = volumeRex.Match(volNode.SelectNodes("div").First(node => node.HasClass("volume")).SelectSingleNode("p").InnerText).Groups[1].Value;
|
||||
float volume = float.Parse(volumeStr);
|
||||
int volume = int.Parse(volumeStr);
|
||||
foreach (HtmlNode chNode in volNode.SelectNodes("div").First(node => node.HasClass("volume-chapters")).SelectNodes("div"))
|
||||
{
|
||||
|
||||
string numberStr = chapterRex.Match(chNode.SelectSingleNode("a").SelectSingleNode("span").InnerText).Groups[1].Value;
|
||||
float chapter = float.Parse(numberStr);
|
||||
if(!ChapterNumber.CanParse(numberStr))
|
||||
continue;
|
||||
ChapterNumber chapterNumber = new(numberStr);
|
||||
string url = chNode.SelectSingleNode("a").GetAttributeValue("href", "");
|
||||
string id = idRex.Match(chNode.SelectSingleNode("a").GetAttributeValue("href", "")).Groups[1].Value;
|
||||
try
|
||||
{
|
||||
ret.Add(new Chapter(manga, url, chapter, volume, null));
|
||||
ret.Add(new Chapter(manga, url, chapterNumber, volume, null));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -177,12 +179,14 @@ public class Mangaworld : MangaConnector
|
||||
foreach (HtmlNode chNode in chaptersWrapper.SelectNodes("div").Where(node => node.HasClass("chapter")))
|
||||
{
|
||||
string numberStr = chapterRex.Match(chNode.SelectSingleNode("a").SelectSingleNode("span").InnerText).Groups[1].Value;
|
||||
float chapter = float.Parse(numberStr);
|
||||
if(!ChapterNumber.CanParse(numberStr))
|
||||
continue;
|
||||
ChapterNumber chapterNumber = new(numberStr);
|
||||
string url = chNode.SelectSingleNode("a").GetAttributeValue("href", "");
|
||||
string id = idRex.Match(chNode.SelectSingleNode("a").GetAttributeValue("href", "")).Groups[1].Value;
|
||||
try
|
||||
{
|
||||
ret.Add(new Chapter(manga, url, chapter, null, null));
|
||||
ret.Add(new Chapter(manga, url, chapterNumber, null, null));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -148,7 +148,9 @@ public class ManhuaPlus : MangaConnector
|
||||
{
|
||||
Match rexMatch = urlRex.Match(url);
|
||||
|
||||
float chapterNumber = float.Parse(rexMatch.Groups[1].Value);
|
||||
if(!ChapterNumber.CanParse(rexMatch.Groups[1].Value))
|
||||
continue;
|
||||
ChapterNumber chapterNumber = new(rexMatch.Groups[1].Value);
|
||||
string fullUrl = url;
|
||||
try
|
||||
{
|
||||
|
@ -182,7 +182,7 @@ public class Weebcentral : MangaConnector
|
||||
var url = elem.GetAttributeValue("href", "") ?? "Undefined";
|
||||
|
||||
if (!url.StartsWith("https://") && !url.StartsWith("http://"))
|
||||
return new Chapter(manga, "undefined", -1, null, null);
|
||||
return new Chapter(manga, "undefined", new ChapterNumber(-1), null, null);
|
||||
|
||||
var idMatch = idRex.Match(url);
|
||||
var id = idMatch.Success ? idMatch.Groups[1].Value : null;
|
||||
@ -191,10 +191,13 @@ public class Weebcentral : MangaConnector
|
||||
"Undefined";
|
||||
|
||||
var chapterNumberMatch = chapterRex.Match(chapterNode);
|
||||
var chapterNumber = chapterNumberMatch.Success ? float.Parse(chapterNumberMatch.Groups[1].Value) : -1;
|
||||
|
||||
if(!chapterNumberMatch.Success || !ChapterNumber.CanParse(chapterNumberMatch.Groups[1].Value))
|
||||
return new Chapter(manga, "undefined", new ChapterNumber(-1), null, null);
|
||||
ChapterNumber chapterNumber = new(chapterNumberMatch.Groups[1].Value);
|
||||
|
||||
return new Chapter(manga, url, chapterNumber, null, null);
|
||||
}).Where(elem => elem.ChapterNumber < 0 && elem.Url != "undefined").ToList();
|
||||
}).Where(elem => elem.ChapterNumber < ChapterNumber.Zero && elem.Url != "undefined").ToList();
|
||||
|
||||
ret.Reverse();
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user