From d42174e8d44c807173c3d8e6cfb3bd4795872065 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Tue, 27 Jul 2021 19:12:12 +0200 Subject: [PATCH] =?UTF-8?q?actualizado=20a=20los=20cambios=20en=20la=20web?= =?UTF-8?q?=20(ahora=20tienen=20Cloudflare=20para=20evitar=20ataques=20DDo?= =?UTF-8?q?s=20y=20se=20ha=20tenido=20que=20desarrollar=20la=20parte=20de?= =?UTF-8?q?=20cargar=20el=20contenido,=20as=C3=AD=20que=20va=20un=20poco?= =?UTF-8?q?=20m=C3=A1s=20lento)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CargarBD/CheckFenix.CargarBD.csproj | 2 +- CargarBD/Program.cs | 15 ++++- CheckFenix.Core/Capitulo.cs | 61 ++++++++----------- CheckFenix.Core/CheckFenix.Core.csproj | 4 +- CheckFenix.Core/Serie.cs | 26 ++++---- CheckFenix.Core/UriExtension.cs | 11 ++-- .../CheckFenix.TelegramBot.csproj | 6 +- CheckFenix.TelegramBot/Program.cs | 2 +- .../PublishProfiles/FolderProfile.pubxml.user | 2 +- CheckFenix/CheckFenix.csproj | 4 +- CheckFenix/MainWindow.xaml.cs | 2 +- .../PublishProfiles/FolderProfile.pubxml.user | 2 +- CheckFenix/SerieViewer.xaml.cs | 6 +- 13 files changed, 75 insertions(+), 68 deletions(-) diff --git a/CargarBD/CheckFenix.CargarBD.csproj b/CargarBD/CheckFenix.CargarBD.csproj index 20af0c2..ff7db30 100644 --- a/CargarBD/CheckFenix.CargarBD.csproj +++ b/CargarBD/CheckFenix.CargarBD.csproj @@ -6,7 +6,7 @@ - + diff --git a/CargarBD/Program.cs b/CargarBD/Program.cs index d6423aa..b94914a 100644 --- a/CargarBD/Program.cs +++ b/CargarBD/Program.cs @@ -10,6 +10,7 @@ namespace CargarBD public class Program { const string URL = "https://www.animefenix.com/"; + static Random r = new Random(); public static void Main(params string[] args) { int lastIndex=-1; @@ -23,9 +24,10 @@ public static void Main(params string[] args) if (Equals(last, default) || last.LastPage>1) { lastIndex = Equals(last, default) ? Serie.GetSeriesFinalizadasLastIndex(url):last.LastPage; + Wait(); for (int i = lastIndex; i >0 ; i--) { - + Wait(); foreach (Serie serie in Serie.GetSeriesFinalizadas(url, i, false, 1)) { if(Equals(context.Series.Find(serie.Pagina.AbsoluteUri),default)) @@ -42,6 +44,7 @@ public static void Main(params string[] args) { for (int i =1; !encontrado; i++) { + Wait(); if (!Equals(context.Series.Find(Serie.GetSeriesFinalizadas(url, i).First().Pagina.AbsoluteUri), default)) { encontrado = true; @@ -52,8 +55,9 @@ public static void Main(params string[] args) { for (int i = last.LastPage == 0 ? 1 : last.LastPage; i <= lastIndex; i++) - { - Serie.GetSeriesFinalizadas(url, i, true, 1).WhileEach((serie) => + { + Wait(); + Serie.GetSeriesFinalizadas(url, i, true, 1).WhileEach((serie) => { encontrado = !Equals(context.Series.Find(serie.Pagina.AbsoluteUri), default); if (!encontrado) @@ -70,5 +74,10 @@ public static void Main(params string[] args) } } + + private static void Wait() + { + System.Threading.Thread.Sleep(r.Next(3 * 1000, 5 * 1000)); + } } } diff --git a/CheckFenix.Core/Capitulo.cs b/CheckFenix.Core/Capitulo.cs index 5a2d2a9..005f67c 100644 --- a/CheckFenix.Core/Capitulo.cs +++ b/CheckFenix.Core/Capitulo.cs @@ -23,7 +23,7 @@ public class Capitulo public Capitulo() { numero = -1; } - public Capitulo(Uri pagina):this() + public Capitulo(Uri pagina) : this() { Pagina = pagina; } @@ -41,17 +41,18 @@ public int Numero return numero; } } - public Uri Picture { - get { - Task tHtmlDocument; + public Uri Picture + { + get + { + HtmlDocument htmlDocument; if (Equals(picture, default)) { - tHtmlDocument = new HtmlDocument().LoadUrl(Pagina); - tHtmlDocument.Wait(); - picture = new Uri(tHtmlDocument.Result.GetByClass("is-2by4").First().GetByTagName("img").First().Attributes["src"].Value); + htmlDocument = new HtmlDocument().LoadUrlByPassed(Pagina); + picture = new Uri(htmlDocument.GetByClass("is-2by4").First().GetByTagName("img").First().Attributes["src"].Value); } - return picture; - } + return picture; + } set => picture = value; } @@ -94,21 +95,18 @@ public List Links } public Bitmap GetImage() { - Task tImg; Bitmap imgCapitulo; string fileName = Path.GetFileName(Picture.AbsoluteUri); string pathFile = Path.Combine(CacheFolder, fileName); - + if (!Directory.Exists(CacheFolder)) Directory.CreateDirectory(CacheFolder); if (!File.Exists(pathFile)) { - - tImg= Picture.GetBitmap(); - tImg.Wait(); - imgCapitulo = tImg.Result; - imgCapitulo =imgCapitulo.Escala(0.35f); + + imgCapitulo = Picture.GetBitmapBypassed(); + imgCapitulo = imgCapitulo.Escala(0.35f); try { imgCapitulo.Save(pathFile); @@ -124,16 +122,13 @@ public void Reload() { string url; string html; - string htmlUri; Regex regex; - Match match,matchUrl; - Task tHtml; + Match match, matchUrl; try { - tHtml= Pagina.DownloadString(); - tHtml.Wait(); - html = tHtml.Result; - + html = Pagina.DownloadBypassed(); + + } catch { @@ -145,17 +140,15 @@ public void Reload() while (match.Success) { - url = HtmlNode.CreateNode("