Skip to content

Commit

Permalink
actualizado a los cambios en la web (ahora tienen Cloudflare para evi…
Browse files Browse the repository at this point in the history
…tar ataques DDos y se ha tenido que desarrollar la parte de cargar el contenido, así que va un poco más lento)
  • Loading branch information
tetradog committed Jul 27, 2021
1 parent ee7b746 commit d42174e
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 68 deletions.
2 changes: 1 addition & 1 deletion CargarBD/CheckFenix.CargarBD.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Gabriel.Cat.S.Utilitats" Version="1.2.2" />
<PackageReference Include="Gabriel.Cat.S.Utilitats" Version="1.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.7">
Expand Down
15 changes: 12 additions & 3 deletions CargarBD/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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))
Expand All @@ -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;
Expand All @@ -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)
Expand All @@ -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));
}
}
}
61 changes: 27 additions & 34 deletions CheckFenix.Core/Capitulo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Capitulo


public Capitulo() { numero = -1; }
public Capitulo(Uri pagina):this()
public Capitulo(Uri pagina) : this()
{
Pagina = pagina;
}
Expand All @@ -41,17 +41,18 @@ public int Numero
return numero;
}
}
public Uri Picture {
get {
Task<HtmlDocument> 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;
}

Expand Down Expand Up @@ -94,21 +95,18 @@ public List<string> Links
}
public Bitmap GetImage()
{
Task<Bitmap> 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);
Expand All @@ -124,16 +122,13 @@ public void Reload()
{
string url;
string html;
string htmlUri;
Regex regex;
Match match,matchUrl;
Task<string> tHtml;
Match match, matchUrl;
try
{
tHtml= Pagina.DownloadString();
tHtml.Wait();
html = tHtml.Result;

html = Pagina.DownloadBypassed();


}
catch
{
Expand All @@ -145,25 +140,23 @@ public void Reload()

while (match.Success)
{
url = HtmlNode.CreateNode("<iframe " + match.Value).Attributes["src"].Value.Replace("&amp;","&");
url = HtmlNode.CreateNode("<iframe " + match.Value).Attributes["src"].Value.Replace("&amp;", "&");
try
{
tHtml= new Uri(url).DownloadString();
tHtml.Wait();
htmlUri = tHtml.Result;
matchUrl = regex.Match(htmlUri);
html = new Uri(url).DownloadBypassed();
matchUrl = regex.Match(html);
if (matchUrl.Success)
{
url = HtmlNode.CreateNode("<iframe " + matchUrl.Value).Attributes["src"].Value.Replace("&amp;", "&");

links.Add(url);
}
}
catch
{

}

match = match.NextMatch();


Expand All @@ -175,7 +168,7 @@ public bool AbrirLink()
string url;


url =GetLinkMega();
url = GetLinkMega();

if (!string.IsNullOrEmpty(url))
{
Expand All @@ -202,9 +195,9 @@ public override string ToString()

public static IEnumerable<Capitulo> GetCapitulosHome(string urlFenix)
{
Task<HtmlDocument> tDoc = new HtmlDocument().LoadUrl(urlFenix);
tDoc.Wait();
return GetCapitulosHome(tDoc.Result.DocumentNode);
HtmlDocument tDoc = new HtmlDocument().LoadUrlByPassed(urlFenix);

return GetCapitulosHome(tDoc.DocumentNode);
}

public static IEnumerable<Capitulo> GetCapitulosHome(HtmlNode nodePagina)
Expand Down
4 changes: 2 additions & 2 deletions CheckFenix.Core/CheckFenix.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Gabriel.Cat.S.Utilitats" Version="1.2.3" />
<PackageReference Include="Gabriel.Cat.S.Xarxa" Version="1.0.3" />
<PackageReference Include="Gabriel.Cat.S.Utilitats" Version="1.2.4" />
<PackageReference Include="Gabriel.Cat.S.Xarxa" Version="1.0.4" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.34" />
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
</ItemGroup>
Expand Down
26 changes: 11 additions & 15 deletions CheckFenix.Core/Serie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public bool IsFavorito
}
public Bitmap GetImage()
{
Task<Bitmap> tBmp;
Bitmap bmp;

Bitmap imgSerie;
string fileName = Path.GetFileName(Picture.AbsoluteUri);
Expand All @@ -222,9 +222,8 @@ public Bitmap GetImage()

if (!File.Exists(pathFile))
{
tBmp = Picture.GetBitmap();
tBmp.Wait();
imgSerie = tBmp.Result.Escala(0.35f);
bmp = Picture.GetBitmapBypassed();
imgSerie = bmp.Escala(0.35f);
try
{
imgSerie.Save(pathFile);
Expand Down Expand Up @@ -253,17 +252,14 @@ private void CargarDatosSiEsNecesario()
HtmlNode nodoFecha;
HtmlNode nodoTotal;
Serie serie;
Task<HtmlDocument> tDoc;

if (total < 0)
{
if (!DicSeriesCompleto.ContainsKey(Pagina.AbsoluteUri))
{
DicSeriesCompleto.Add(Pagina.AbsoluteUri, this);
DicSeriesBasico.AddOrReplace(Pagina.AbsoluteUri, this);
tDoc = new HtmlDocument().LoadUrl(Pagina);
tDoc.Wait();
pagina = tDoc.Result;
pagina = new HtmlDocument().LoadUrlByPassed(Pagina);
nodoNombre = pagina.GetByTagName("meta").Where(m => !Equals(m.Attributes["name"], default(HtmlAttribute)) && m.Attributes["name"].Value.Equals("title")).FirstOrDefault();
nodoDesc = pagina.GetByTagName("meta").Where(m => !Equals(m.Attributes["name"], default(HtmlAttribute)) && m.Attributes["name"].Value.Equals("description")).FirstOrDefault();
nodoPicture = pagina.GetByClass("is-2by4").FirstOrDefault();
Expand Down Expand Up @@ -325,9 +321,10 @@ private void CargarDatosBasicosOCompletosSiEsNecesario()
}
public bool UltimoEnParrilla()
{
Task<string> tHtml = new Uri(Pagina.Host).DownloadString();
tHtml.Wait();
return tHtml.Result.Contains(Ultimo.Pagina.AbsolutePath);

string tHtml = new Uri(Pagina.Host).DownloadBypassed();

return tHtml.Contains(Ultimo.Pagina.AbsolutePath);
}
public override string ToString()
{
Expand Down Expand Up @@ -355,7 +352,7 @@ static IEnumerable<Serie> IGetSeries(string urlFenix, string filtro, int startPa

const string CLASE = "serie-card";

Task<HtmlDocument> tDoc;
HtmlDocument tDoc;
HtmlNode[] nodosSeries;
HtmlNode nodoLink;
string uri, name;
Expand All @@ -366,9 +363,8 @@ static IEnumerable<Serie> IGetSeries(string urlFenix, string filtro, int startPa
do
{
//no se puede guardar porque la pagina 1 es la más nueva ergo los indices cambian
tDoc = new HtmlDocument().LoadUrl(new Uri(urlBase + paginaActual));
tDoc.Wait();
nodosSeries = tDoc.Result.GetByClass(CLASE).ToArray();
tDoc = new HtmlDocument().LoadUrlByPassed(new Uri(urlBase + paginaActual));
nodosSeries = tDoc.GetByClass(CLASE).ToArray();
if (upToDown)
{
for (int i = 0; i < nodosSeries.Length; i++)
Expand Down
11 changes: 6 additions & 5 deletions CheckFenix.Core/UriExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace CheckFenix.Core
{

public static class UriExtension
{
public static bool? IsOk(this Uri url)
Expand All @@ -30,11 +31,11 @@ public static class UriExtension
//case "ok.ru"://se necesita cargar el js
// isOk = !html.Contains("The video is blocked");
// break;
case "www.yourupload.com":
tStatus = url.GetStatusCode();
tStatus.Wait();
isOk = tStatus.Result == HttpStatusCode.OK;
break;
//case "www.yourupload.com":
// tStatus = url.GetStatusCode();
// tStatus.Wait();
// isOk = tStatus.Result == HttpStatusCode.OK;
// break;

}

Expand Down
6 changes: 5 additions & 1 deletion CheckFenix.TelegramBot/CheckFenix.TelegramBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Gabriel.Cat.S.Check" Version="1.0.9" />
<PackageReference Include="Gabriel.Cat.S.Check" Version="1.0.10" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CheckFenix.Core\CheckFenix.Core.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion CheckFenix.TelegramBot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public IEnumerable<Link> GetLinks()
}
class Program
{
public const string VERSION = "1.3";
public const string VERSION = "1.4";
public const int TIEMPOCHECK = 5 * 60 * 1000;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<History>True|2021-07-09T03:03:54.2646935Z;True|2021-07-09T02:38:00.4414086+02:00;True|2021-07-09T01:57:16.7092098+02:00;True|2021-07-09T01:49:28.8631421+02:00;</History>
<History>True|2021-07-27T16:42:46.9283904Z;True|2021-07-09T05:03:54.2646935+02:00;True|2021-07-09T02:38:00.4414086+02:00;True|2021-07-09T01:57:16.7092098+02:00;True|2021-07-09T01:49:28.8631421+02:00;</History>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions CheckFenix/CheckFenix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Gabriel.Cat.S.Utilitats" Version="1.2.2" />
<PackageReference Include="Gabriel.Cat.S.Wpf" Version="1.0.1-preview1.1.1" />
<PackageReference Include="Gabriel.Cat.S.Utilitats" Version="1.2.4" />
<PackageReference Include="Gabriel.Cat.S.Wpf" Version="1.0.1-preview1.1.2" />
<PackageReference Include="Notifications.Wpf.Core" Version="1.3.2" />
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion CheckFenix/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public partial class MainWindow : Window
const int PROXIMANENTEPAGE = 4;

const string CARGANDO = "Cargando";
const string TITULO = "AnimeFenix Desktop 1.5c";
const string TITULO = "AnimeFenix Desktop 1.6";
const string FINALIZADAS = "Finalizadas";

IEnumerable<Capitulo> capitulosAnt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<History>True|2021-07-09T00:44:11.8219602Z;True|2021-07-09T02:43:55.5334027+02:00;True|2021-06-30T04:20:19.7475622+02:00;False|2021-06-30T04:19:47.0688657+02:00;True|2021-06-30T01:52:56.3859389+02:00;True|2021-06-28T03:48:53.6914433+02:00;True|2021-06-28T03:27:28.7415951+02:00;True|2021-06-28T03:16:30.6478742+02:00;True|2021-06-28T03:07:13.1648070+02:00;True|2021-06-27T22:27:25.9063213+02:00;True|2021-06-27T22:01:46.8539155+02:00;False|2021-06-27T22:00:30.6833537+02:00;True|2021-06-27T21:35:34.9006617+02:00;True|2021-06-27T21:31:26.9248167+02:00;True|2021-06-27T21:06:07.6762072+02:00;True|2021-06-27T20:29:46.7089916+02:00;True|2021-06-27T20:20:26.4112008+02:00;True|2021-06-27T14:21:39.5602204+02:00;True|2021-06-27T14:15:03.0577443+02:00;True|2021-06-27T13:31:47.4836848+02:00;True|2021-06-27T12:59:47.5576289+02:00;True|2021-06-27T12:56:39.5452329+02:00;True|2021-06-26T22:11:11.5985646+02:00;True|2021-06-26T21:39:27.3917081+02:00;True|2021-06-26T18:24:09.9921716+02:00;True|2021-06-26T17:41:16.0809176+02:00;True|2021-06-26T05:52:27.1088566+02:00;True|2021-06-24T21:25:31.4258809+02:00;True|2021-06-24T19:33:18.0956758+02:00;True|2021-06-24T06:06:20.6521737+02:00;True|2021-06-24T04:43:02.8810260+02:00;True|2021-06-23T21:41:32.5526308+02:00;True|2021-06-23T21:13:19.3114048+02:00;</History>
<History>True|2021-07-27T17:09:39.0903579Z;False|2021-07-27T19:09:18.2144360+02:00;False|2021-07-27T19:08:56.4475259+02:00;True|2021-07-27T18:38:31.3058810+02:00;True|2021-07-27T18:19:23.0397796+02:00;True|2021-07-09T02:44:11.8219602+02:00;True|2021-07-09T02:43:55.5334027+02:00;True|2021-06-30T04:20:19.7475622+02:00;False|2021-06-30T04:19:47.0688657+02:00;True|2021-06-30T01:52:56.3859389+02:00;True|2021-06-28T03:48:53.6914433+02:00;True|2021-06-28T03:27:28.7415951+02:00;True|2021-06-28T03:16:30.6478742+02:00;True|2021-06-28T03:07:13.1648070+02:00;True|2021-06-27T22:27:25.9063213+02:00;True|2021-06-27T22:01:46.8539155+02:00;False|2021-06-27T22:00:30.6833537+02:00;True|2021-06-27T21:35:34.9006617+02:00;True|2021-06-27T21:31:26.9248167+02:00;True|2021-06-27T21:06:07.6762072+02:00;True|2021-06-27T20:29:46.7089916+02:00;True|2021-06-27T20:20:26.4112008+02:00;True|2021-06-27T14:21:39.5602204+02:00;True|2021-06-27T14:15:03.0577443+02:00;True|2021-06-27T13:31:47.4836848+02:00;True|2021-06-27T12:59:47.5576289+02:00;True|2021-06-27T12:56:39.5452329+02:00;True|2021-06-26T22:11:11.5985646+02:00;True|2021-06-26T21:39:27.3917081+02:00;True|2021-06-26T18:24:09.9921716+02:00;True|2021-06-26T17:41:16.0809176+02:00;True|2021-06-26T05:52:27.1088566+02:00;True|2021-06-24T21:25:31.4258809+02:00;True|2021-06-24T19:33:18.0956758+02:00;True|2021-06-24T06:06:20.6521737+02:00;True|2021-06-24T04:43:02.8810260+02:00;True|2021-06-23T21:41:32.5526308+02:00;True|2021-06-23T21:13:19.3114048+02:00;</History>
</PropertyGroup>
</Project>
6 changes: 5 additions & 1 deletion CheckFenix/SerieViewer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Gabriel.Cat.S.Utilitats;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
Expand Down Expand Up @@ -44,9 +45,12 @@ public SerieViewer(Serie serie):this()
public bool CargarImagenFull { get; set; }
public void Refresh()
{
Bitmap getBmp;
if (CargarImagenFull)
{
DicImgs.AddOrReplace(Serie.Picture.AbsoluteUri, Serie.Picture.GetBitmap().ToImageSource());
getBmp = Serie.Picture.GetBitmapBypassed();

DicImgs.AddOrReplace(Serie.Picture.AbsoluteUri, getBmp.ToImageSource());
}
else if (!DicImgs.ContainsKey(Serie.Picture.AbsoluteUri))
{
Expand Down

0 comments on commit d42174e

Please sign in to comment.