public async Task <IEnumerable <Chapter> > FindChapters(string manga, IProgress <int> progress, CancellationToken cancellationToken) { Logger.Info($@"> FindChapters(): {manga}"); progress.Report(0); // find all chapters in a manga string input = await downloader.DownloadStringAsync(manga, cancellationToken); var title = selector.Select(input, "//meta[@property='og:title']").Attributes["content"]; var chaps = selector.SelectMany(input, "//*[self::h3 or self::h4]/a[@class='tips']") .Select(n => new Chapter(n.InnerHtml, n.Attributes["href"]) { Manga = title }); progress.Report(100); // Insert missing URI schemes in each chapter's URI. // Provisional solution, the current implementation may not be the best way to go about it. chaps = chaps.Select(chap => { chap.Url = $"http:{chap.Url}"; return(chap); }); return(chaps); }
public async Task <IEnumerable <Chapter> > FindChapters(string manga, IProgress <int> progress, CancellationToken cancellationToken) { progress.Report(0); downloader.Cookies = LoginBatoto(_username, _password); downloader.Referrer = "http://bato.to/reader"; // find all chapters in a manga string input = await downloader.DownloadStringAsync(manga, cancellationToken); var title = selector.Select(input, "//h1").InnerHtml.Trim(); var langs = selector.SelectMany(input, "//tr[contains(@class,'chapter_row')]//div").Select(n => n.Attributes["title"]).ToList(); var chaps = selector.SelectMany(input, "//tr[contains(@class,'chapter_row')]//a[@title]") .Select(n => { string originalName = n.Attributes["title"]; originalName = originalName.Remove(originalName.LastIndexOf('|')).Trim(); return(new Chapter(originalName, n.Attributes["href"]) { Manga = title }); }).ToList(); for (int i = 0; i < langs.Count(); i++) { chaps[i].Language = langs[i]; } chaps = chaps.GroupBy(c => c.Url).Select(g => g.First()).ToList(); if (selectedLanguages.Count > 0) { chaps = chaps.Where(c => selectedLanguages.Contains(c.Language)).ToList(); } progress.Report(100); return(chaps); }
public async Task <IEnumerable <Chapter> > FindChapters(string manga, IProgress <int> progress, CancellationToken cancellationToken) { progress.Report(0); // find all chapters in a manga string input = await downloader.DownloadStringAsync(manga, cancellationToken); var title = selector.Select(input, "//h2[@class='aname']").InnerHtml; var chaps = selector .SelectMany(input, "//table[@id='listing']//a") .Select(n => { string url = n.Attributes["href"]; var resultUrl = new Uri(new Uri(manga), url).AbsoluteUri; return(new Chapter(n.InnerHtml, resultUrl) { Manga = title }); }); // reverse chapters order and remove duplicated chapters in latest section chaps = chaps.Reverse().GroupBy(x => x.Url).Select(g => g.First()).ToList(); // transform pages link progress.Report(100); return(chaps); }
private async Task <string> DownloadAndParseImage(string page, CancellationToken cancellationToken) { var pageHtml = await downloader.GetStringAsync(page, cancellationToken); // <div id="content"><div...id="page-container"><section id="image-container"...><img> var image = selector .Select(pageHtml, "//div[@id='content']//div[@id='page-container']//section[@id='image-container']//img").Attributes["src"]; return(image); }
private async Task <IEnumerable <Chapter> > DownloadAndParseChapters(string manga, CancellationToken cancellationToken) { string input = await downloader.DownloadStringAsync(manga, cancellationToken); var title = selector.Select(input, "//meta[@property='og:title']").Attributes["content"]; var chaps = selector.SelectMany(input, "//*[self::h3 or self::h4]/a[@class='tips']") .Select(n => new Chapter(n.InnerHtml, n.Attributes["href"]) { Manga = title }); return(chaps); }
private async Task <IEnumerable <Chapter> > DownloadAndParseChapters(string manga, CancellationToken cancellationToken) { string input = await downloader.DownloadStringAsync(manga, cancellationToken); var title = selector.Select(input, "//meta[@property='og:title']").Attributes["content"]; var chaps = selector.SelectMany(input, "//div[contains(@class,'detail_list')]/ul//a") .Select(n => { return(new Chapter(n.InnerHtml.Trim(), $"http:{n.Attributes["href"]}") { Manga = title }); }); return(chaps); }
public async Task <IEnumerable <Chapter> > GetChapters(string manga, IProgress <string> progress, CancellationToken cancellationToken) { string input = await downloader.GetStringAsync(manga, cancellationToken); var title = selector.Select(input, "//h1").InnerText; var chaps = selector .SelectMany(input, "//td/a") .Select(n => { string url = $"https://readms.net{n.Attributes["href"]}"; return(new Chapter($"{title} {n.InnerText}", url)); }); return(chaps); }
public async Task <IEnumerable <Chapter> > GetChapters(string manga, IProgress <string> progress, CancellationToken cancellationToken) { string input = await downloader.GetStringAsync(manga, cancellationToken); var title = selector.Select(input, "//h2[@class='aname']").InnerText; var chaps = selector .SelectMany(input, "//table[@id='listing']//a") .Select(n => { string url = n.Attributes["href"]; var resultUrl = new Uri(new Uri(manga), url).AbsoluteUri; return(new Chapter(n.InnerText, resultUrl)); }); chaps = chaps.Reverse().GroupBy(x => x.Url).Select(g => g.First()).ToList(); return(chaps); }
public async Task <IEnumerable <Chapter> > FindChapters(string manga, IProgress <int> progress, CancellationToken cancellationToken) { progress.Report(0); // find all chapters in a manga string input = await downloader.DownloadStringAsync(manga, cancellationToken); var title = selector.Select(input, "//h1").InnerHtml; var chaps = selector .SelectMany(input, "//td/a") .Select(n => { string url = $"https://readms.net{n.Attributes["href"]}"; return(new Chapter(n.InnerHtml, url) { Manga = title }); }); progress.Report(100); return(chaps); }
public MyHtmlNode Select(string html, string xpath) { try { return(decoratee.Select(html, xpath)); } catch { logger.Info($"Xpath: {xpath}"); logger.Fatal(html); throw; } }
private async Task <IEnumerable <Chapter> > GetChaptersImpl(string manga, CancellationToken cancellationToken) { string input = await downloader.GetStringAsync(manga, cancellationToken); var title = selector.Select(input, "//span[@class='detail-info-right-title-font']").InnerText; var hrefs = selector.SelectMany(input, "//ul[@class='detail-main-list']/li/a").Select(a => a.Attributes["href"]).ToList(); var texts = selector.SelectMany(input, "//ul[@class='detail-main-list']/li/a/div/p[@class='title3']").Select(p => p.InnerText).ToList(); var chaps = new List <Chapter>(); for (int i = 0; i < hrefs.Count(); i++) { var chap = new Chapter($"{title} {texts[i]}", hrefs[i]); chaps.Add(chap); } return(chaps); }
public async Task <IEnumerable <Chapter> > FindChapters(string manga, IProgress <int> progress, CancellationToken cancellationToken) { progress.Report(0); // find all chapters in a manga string input = await downloader.DownloadStringAsync(manga, cancellationToken); var title = selector.Select(input, "//a[@class='bigChar']").InnerHtml; var chaps = selector.SelectMany(input, "//tr/td/a[@title]") .Select(n => { string name = n.InnerHtml.Trim(); string url = n.Attributes["href"]; var chap = NameResolver(name, url, new Uri(manga)); chap.Manga = title; return(chap); }); progress.Report(100); return(chaps); }