Beispiel #1
0
        public ComicInfo LoadUri(Uri Uri)
        {
            if (Uri.AbsoluteUri.Contains("/chapters/"))
            {
                Uri = new Uri(Uri.AbsoluteUri.Substring(0, Uri.AbsoluteUri.IndexOf("/chapters/")).TrimEnd('/') + "/chapters/1");
            }
            else
            {
                Uri = new Uri(Uri.AbsoluteUri.TrimEnd('/') + "/chapters/1");
            }

            if (CFData == null)
            {
                using (ChromiumWebBrowser Browser = new ChromiumWebBrowser()) {
                    Browser.WaitForLoad(Uri.AbsoluteUri);
                    do
                    {
                        CFData = Browser.BypassCloudflare();
                    } while (Browser.IsCloudflareTriggered());
                }
            }

            Document = new HtmlAgilityPack.HtmlDocument();
            Document.LoadUrl(Uri, Referer: "https://mangadex.org", UserAgent: CFData?.UserAgent ?? null, Cookies: CFData?.Cookies ?? null);

            ComicInfo Info = new ComicInfo();

            Info.Title = Document.SelectSingleNode("//*[@id=\"content\"]//h6/span[@class=\"mx-1\"]").InnerText;
            Info.Title = HttpUtility.HtmlDecode(Info.Title);

            Info.Cover = TryDownload(Document
                                     .SelectSingleNode("//*[@id=\"content\"]//img[@class=\"rounded\"]")
                                     .GetAttributeValue("src", string.Empty).EnsureAbsoluteUri("https://mangadex.org"));

            Info.ContentType = ContentType.Comic;

            CurrentUrl = Uri.AbsoluteUri;

            if (Uri.AbsolutePath.Trim('/').Split('/').Length == 4)
            {
                CurrentUrl = Document.SelectSingleNode("//link[@rel='canonical']").GetAttributeValue("href", null);
                CurrentUrl = CurrentUrl.TrimEnd() + "/chapters/1";
            }

            return(Info);
        }