public override List <Update> GetUpdates(string url) { lock (Lock7) { try { OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Buscando Atualizações...")); var driver = BrowserHelper.GetDriver(url); var pageSource = driver.PageSource; OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página")); IDocument source = HtmlHelper.GetSourceCodeFromHtml(pageSource); driver.Quit(); BrowserHelper.CloseDriver(); var updates = new List <Update>(); if (source == null) { throw new Exception("Ocorreu um erro ao buscar informaçoes da Hq"); } var updatesEl = source.QuerySelectorAll(".table-lancamentos tr"); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"{updatesEl.Count()} mangas encontrados!")); foreach (var update in updatesEl) { var title = update.QuerySelector("td h3.entry-title")?.TextContent; if (!string.IsNullOrEmpty(title)) { title = CleanTitle(title); var img = update.QuerySelector("td a img.manga")?.GetAttribute("src"); var link = update.QuerySelector("td h3.entry-title a")?.GetAttribute("href"); var chaptersEl = update.QuerySelectorAll(".chapters a.btn"); if (!string.IsNullOrEmpty(link)) { var chapters = new List <Chapter>(); foreach (var chap in chaptersEl) { var chapterTitle = chap.GetAttribute("title"); chapterTitle = CleanTitle(chapterTitle); var chapterLink = chap.GetAttribute("href"); chapters.Add(new Chapter { Link = chapterLink, Title = chapterTitle }); } var up = new Update { Hq = new Hq { Link = link, Title = CleanTitle(title), CoverSource = img }, Chapters = chapters }; updates.Add(up); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, up.Hq, $"{title} Adicionado")); } } } OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Tudo pronto")); return(updates); } catch (Exception e) { BrowserHelper.CloseDriver(); OnProcessingProgressError(new ProcessingErrorEventArgs(DateTime.Now, url, e)); return(null); } } }
public override Chapter GetChapterInfo(string link) { lock (Lock4) { try { OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Abrindo Internet Explorer")); var driver = BrowserHelper.GetDriver(link); var pageSource = driver.PageSource; Task.Delay(5000); var token = pageSource.Substring(pageSource.IndexOf("reader.min.js")); token = token.Substring(token.IndexOf("token")); token = token.Substring(0, token.IndexOf("id_release")); token = token.Substring(0, token.Length - 5); token = token.Replace("token=", ""); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página")); IDocument leitor = HtmlHelper.GetSourceCodeFromHtml(pageSource); var tes = leitor.QuerySelectorAll(".requests"); var chapter = new Chapter(); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página")); if (leitor == null) { driver.Quit(); BrowserHelper.CloseDriver(); throw new Exception("Ocorreu um erro ao buscar informaçoes do capitulo"); } var title = leitor.QuerySelector(".series-info .series-title .title")?.TextContent; var chap = leitor.QuerySelector(".chapter-selection .current-chapter")?.TextContent; var chapterTitle = $"{title} - {chap}"; chapterTitle = CleanTitle(chapterTitle); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Buscando informações de {chapterTitle}")); chapter.Title = CleanTitle(chapterTitle); chapter.Link = link; List <Page> pageList = GetPageList(link, token); if (pageList.Count() > 1) { chapter.Pages = pageList; } else { driver.Quit(); BrowserHelper.CloseDriver(); throw new Exception("Ocorreu um erro ao buscar informaçoes do capitulo"); } driver.Quit(); BrowserHelper.CloseDriver(); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Tudo pronto")); return(chapter); } catch (Exception e) { BrowserHelper.CloseDriver(); OnProcessingProgressError(new ProcessingErrorEventArgs(DateTime.Now, link, e)); return(null); } } }
public override Hq GetHqInfo(string link) { lock (Lock3) { try { OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página")); var driver = BrowserHelper.GetDriver(link); var pageSource = driver.PageSource; OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página")); IDocument source = HtmlHelper.GetSourceCodeFromHtml(pageSource); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página")); driver.Quit(); BrowserHelper.CloseDriver(); var hqInfo = new Hq(); if (source == null) { throw new Exception("Ocorreu um erro ao buscar informaçoes da Hq"); } var title = source.QuerySelector("h1.title")?.TextContent; title = CleanTitle(title); var img = source.QuerySelector("#descricao img"); var synopsis = source.QuerySelector("#descricao article")?.TextContent; synopsis = synopsis.Replace("'", "`").Trim(); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Buscando informações de {title}")); hqInfo.Title = title; hqInfo.CoverSource = img?.GetAttribute("src"); hqInfo.Synopsis = synopsis.Replace("\n", "").Trim(); hqInfo.Link = link; var hqInfos = source.QuerySelectorAll("#descricao div.content ul li"); foreach (var info in hqInfos) { if (info.TextContent.Contains("Autor")) { hqInfo.Author = info.TextContent.Replace("Autor:", "").Trim().Replace("\n", "").Trim().Replace("'", "`").Trim(); } } var chapters = GetListChapters(source).Reverse <Chapter>().ToList(); hqInfo.Chapters = chapters; OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Tudo pronto!")); return(hqInfo); } catch (Exception e) { BrowserHelper.CloseDriver(); OnProcessingProgressError(new ProcessingErrorEventArgs(DateTime.Now, link, e)); return(null); } } }
public override Hq GetHqInfo(string link) { lock (Lock3) { try { Uri site = new Uri(link); BaseAdress = $"{site.Scheme}://{site.Host}"; var driver = BrowserHelper.GetDriver(link); var pageSource = driver.PageSource; OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página")); IDocument source = HtmlHelper.GetSourceCodeFromHtml(pageSource); driver.Quit(); BrowserHelper.CloseDriver(); var hqInfo = new Hq(); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página")); if (source == null) { throw new Exception("Ocorreu um erro ao buscar informaçoes da Hq"); } var title = source.QuerySelector("div#series-data div.series-info span.series-title h1")?.TextContent; title = CleanTitle(title); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Buscando informações de {title}")); var img = source.QuerySelector("div.series-img div.cover img"); var author = source.QuerySelector("div#series-data div.series-info span.series-author")?.TextContent; var synopsis = source.QuerySelector("div#series-data div.series-info span.series-desc")?.TextContent; hqInfo.Title = title; hqInfo.Author = author.Replace("\n", "").Trim().Replace("\n", "").Trim().Replace("'", "`").Trim(); hqInfo.CoverSource = img?.GetAttribute("src"); hqInfo.Synopsis = synopsis.Replace("\n", "").Trim().Replace("\n", "").Trim().Replace("'", "`").Trim(); hqInfo.Link = link; var lastchapter = source.QuerySelector("#chapter-list .list-of-chapters li a"); var chapters = GetListChapters(link).Reverse <Chapter>().ToList(); hqInfo.Chapters = chapters; OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Tudo pronto!")); return(hqInfo); } catch (Exception e) { BrowserHelper.CloseDriver(); OnProcessingProgressError(new ProcessingErrorEventArgs(DateTime.Now, link, e)); return(null); } } }
public override LibraryPage GetLibrary(String linkPage) { lock (Lock2) { try { OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Buscando Biblioteca...")); var driver = BrowserHelper.GetDriver(linkPage); var pageSource = driver.PageSource; OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página")); IDocument source = HtmlHelper.GetSourceCodeFromHtml(pageSource); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página")); driver.Quit(); BrowserHelper.CloseDriver(); var hqs = new List <Hq>(); if (source == null) { throw new Exception("Ocorreu um erro ao buscar informaçoes da Hq"); } var hqsEl = source.QuerySelectorAll("#mangas .two"); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"{hqsEl.Count()} mangas encontrados!")); var nextPage = source.QuerySelector("#mangas a.next")?.GetAttribute("href"); var finalizadosEl = source.QuerySelectorAll("#mangas ul.nav-tabs li a"); var finalizedPage = ""; foreach (var el in finalizadosEl) { if (el.TextContent.Contains("Completos")) { finalizedPage = el.GetAttribute("href"); } } var lethers = source.QuerySelectorAll("#mangas .letters a"); var letherLink = new Dictionary <string, string>(); foreach (var lether in lethers) { letherLink[lether.TextContent] = lether.GetAttribute("href"); } OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Preparando para retornar mangas!")); foreach (var hq in hqsEl) { var title = hq.QuerySelector("h3")?.TextContent; title = CleanTitle(title); var img = hq.QuerySelector("a img")?.GetAttribute("src"); var link = hq.QuerySelector("h3 a")?.GetAttribute("href"); if (!string.IsNullOrEmpty(link)) { var manga = new Hq { Link = link, Title = title, CoverSource = img }; if (!hqs.Contains(manga)) { hqs.Add(manga); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, manga, $"{title} Adicionado")); } } } OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Tudo pronto")); return(new LibraryPage { Link = linkPage, Hqs = hqs, NextPage = nextPage, FinalizedPage = finalizedPage, Letras = letherLink }); } catch (Exception e) { BrowserHelper.CloseDriver(); OnProcessingProgressError(new ProcessingErrorEventArgs(DateTime.Now, linkPage, e)); return(null); } } }
public override LibraryPage GetLibrary(String linkPage) { lock (Lock2) { try { OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, "Processando os Mangas...")); Uri site = new Uri(linkPage); BaseAdress = $"{site.Scheme}://{site.Host}"; OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Abrindo Internet Explorer")); var driver = BrowserHelper.GetDriver(linkPage); var pageSource = driver.PageSource; OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados da página")); IDocument source = HtmlHelper.GetSourceCodeFromHtml(pageSource); driver.Quit(); BrowserHelper.CloseDriver(); var hqs = new List <Hq>(); if (source == null) { throw new Exception("Ocorreu um erro ao buscar informaçoes da Hq"); } var hqsEl = source.QuerySelectorAll(".content-wraper ul.seriesList li"); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"{hqsEl.Count()} mangas encontrados!")); var nextPage = source.QuerySelector("ul.content-pagination li.next a")?.GetAttribute("href"); var finalizadosEl = source.QuerySelectorAll("#subtopnav ul#menu-titulos li a"); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando links")); var finalizedPage = ""; foreach (var el in finalizadosEl) { var test = el.TextContent; if (el.TextContent.Contains("Recém Finalizados")) { finalizedPage = el.GetAttribute("href"); } } var lethers = source.QuerySelectorAll("#az-order div a"); var letherLink = new Dictionary <string, string>(); foreach (var lether in lethers) { letherLink[lether.TextContent.Trim()] = $"{BaseAdress}{lether.GetAttribute("href")}"; } OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Preparando para retornar mangas!")); foreach (var hq in hqsEl) { try { var title = hq.QuerySelector(".series-title h1")?.TextContent; title = CleanTitle(title); var imgEl = hq.QuerySelector(".cover-image")?.GetAttribute("style"); imgEl = imgEl?.Replace("background-image: url(", ""); imgEl = imgEl?.Replace(")", ""); imgEl = imgEl?.Replace("'", ""); imgEl = imgEl?.Replace("\"", ""); var img = imgEl?.Replace(";", ""); var link = hq.QuerySelector("a")?.GetAttribute("href"); if (title != null) { OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Pegando dados de {title}")); if (!img.Contains(site.Scheme)) { img = $"{BaseAdress}{img}"; } if (!string.IsNullOrEmpty(link)) { var manga = new Hq { Link = $"{BaseAdress}{link}", Title = title, CoverSource = img }; if (!hqs.Contains(manga)) { hqs.Add(manga); OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, manga, $"{title} Adicionado")); } } } } catch {} } OnProcessingProgress(new ProcessingEventArgs(DateTime.Now, $"Tudo pronto")); return(new LibraryPage { Link = linkPage, Hqs = hqs, NextPage = $"{BaseAdress}{nextPage}", FinalizedPage = $"{BaseAdress}{finalizedPage}", Letras = letherLink }); } catch (Exception e) { BrowserHelper.CloseDriver(); OnProcessingProgressError(new ProcessingErrorEventArgs(DateTime.Now, linkPage, e)); return(null); } } }