Compare commits

...

3 Commits

Author SHA1 Message Date
7219641859 #68 Because XML is sometimes broken, we parse from somewhere else
Also fixed the faulty url completion.
2023-10-20 15:01:55 +02:00
f63851d95d #68 JsonConverter 2023-10-20 14:50:26 +02:00
e72301d062 #68 and other chromium connectors: Wait for page to be fully loaded 2023-10-20 14:49:48 +02:00
3 changed files with 13 additions and 11 deletions

View File

@ -62,7 +62,7 @@ internal class ChromiumDownloadClient : DownloadClient
{
IPage page = this.browser.NewPageAsync().Result;
page.DefaultTimeout = 10000;
IResponse response = page.GoToAsync(url, WaitUntilNavigation.DOMContentLoaded).Result;
IResponse response = page.GoToAsync(url, WaitUntilNavigation.Networkidle0).Result;
Log("Page loaded.");
Stream stream = Stream.Null;

View File

@ -36,6 +36,8 @@ public class MangaConnectorJsonConverter : JsonConverter
return this._connectors.First(c => c is Mangaworld);
case "Bato":
return this._connectors.First(c => c is Bato);
case "Manga4Life":
return this._connectors.First(c => c is MangaLife);
}
throw new Exception();

View File

@ -58,7 +58,7 @@ public class MangaLife : MangaConnector
foreach (HtmlNode resultNode in resultsNode.SelectNodes("div"))
{
string url = resultNode.Descendants().First(d => d.HasClass("SeriesName")).GetAttributeValue("href", "");
Manga? manga = GetMangaFromUrl($"https://mangasee123.com{url}");
Manga? manga = GetMangaFromUrl($"https://manga4life.com{url}");
if (manga is not null)
ret.Add((Manga)manga);
}
@ -120,23 +120,23 @@ public class MangaLife : MangaConnector
public override Chapter[] GetChapters(Manga manga, string language="en")
{
Log($"Getting chapters {manga}");
DownloadClient.RequestResult result = downloadClient.MakeRequest($"https://manga4life.com/rss/{manga.publicationId}.xml", 1);
if ((int)result.statusCode < 200 || (int)result.statusCode >= 300)
DownloadClient.RequestResult result = downloadClient.MakeRequest($"https://manga4life.com/manga/{manga.publicationId}", 1);
if ((int)result.statusCode < 200 || (int)result.statusCode >= 300 || result.htmlDocument is null)
{
Log("Failed to load chapterinfo");
return Array.Empty<Chapter>();
}
StreamReader sr = new (result.result);
string unformattedString = sr.ReadToEnd();
Regex urlRex = new(@"(https:\/\/manga4life.com/read-online/[A-z0-9\-]+\.html)");
string[] urls = urlRex.Matches(unformattedString).Select(match => match.Groups[1].Value).ToArray();
HtmlNodeCollection chapterNodes = result.htmlDocument.DocumentNode.SelectNodes(
"//a[contains(concat(' ',normalize-space(@class),' '),' ChapterLink ')]");
string[] urls = chapterNodes.Select(node => node.GetAttributeValue("href", "")).ToArray();
List<Chapter> chapters = new();
foreach (string url in urls)
{
string volumeNumber = "1";
string chapterNumber = Regex.Match(url, @"-chapter-([0-9\.]+)").Groups[1].ToString();
string fullUrl = url.Replace(Regex.Match(url,"(-page-[0-9])").Value,"");
string fullUrl = $"https://manga4life.com{url}";
fullUrl = fullUrl.Replace(Regex.Match(url,"(-page-[0-9])").Value,"");
chapters.Add(new Chapter(manga, "", volumeNumber, chapterNumber, fullUrl));
}
//Return Chapters ordered by Chapter-Number