Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
immisterio committed Jun 17, 2023
1 parent 30f014b commit bec3a40
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
2 changes: 1 addition & 1 deletion AppInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static AppInit conf

public TrackerSettings Anidub = new TrackerSettings("https://tr.anidub.com");

public TrackerSettings Anifilm = new TrackerSettings("https://anifilm.tv");
public TrackerSettings Anifilm = new TrackerSettings("https://anifilm.net");

public TrackerSettings Rezka = new TrackerSettings("https://rezka.cc");

Expand Down
17 changes: 12 additions & 5 deletions Controllers/CRON/AnimeLayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@
using JacRed.Engine.CORE;
using JacRed.Models.Details;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;

namespace JacRed.Controllers.CRON
{
[Route("/cron/animelayer/[action]")]
public class AnimeLayerController : BaseController
{
#region TakeLogin
static string Cookie { get; set; }
static string Cookie(IMemoryCache memoryCache)
{
if (memoryCache.TryGetValue("animelayer:cookie", out string cookie))
return cookie;

return null;
}

async public static Task<bool> TakeLogin()
async public Task<bool> TakeLogin()
{
try
{
Expand Down Expand Up @@ -63,7 +70,7 @@ async public static Task<bool> TakeLogin()

if (!string.IsNullOrWhiteSpace(layer_id) && !string.IsNullOrWhiteSpace(layer_hash) && !string.IsNullOrWhiteSpace(PHPSESSID))
{
Cookie = $"layer_id={layer_id}; layer_hash={layer_hash}; PHPSESSID={PHPSESSID};";
memoryCache.Set("animelayer:cookie", $"layer_id={layer_id}; layer_hash={layer_hash}; PHPSESSID={PHPSESSID};", DateTime.Now.AddDays(1));
return true;
}
}
Expand All @@ -84,7 +91,7 @@ async public static Task<bool> TakeLogin()
async public Task<string> Parse(int maxpage = 1)
{
#region Авторизация
if (Cookie == null)
if (Cookie(memoryCache) == null)
{
if (await TakeLogin() == false)
return "Не удалось авторизоваться";
Expand Down Expand Up @@ -237,7 +244,7 @@ await FileDB.AddOrUpdate(torrents, async (t, db) =>
if (db.TryGetValue(t.url, out TorrentDetails _tcache) && _tcache.title == t.title)
return true;

byte[] torrent = await HttpClient.Download($"{t.url}download/", cookie: Cookie);
byte[] torrent = await HttpClient.Download($"{t.url}download/", cookie: Cookie(memoryCache));
string magnet = BencodeTo.Magnet(torrent);
string sizeName = BencodeTo.SizeName(torrent);
if (!string.IsNullOrWhiteSpace(magnet) && !string.IsNullOrWhiteSpace(sizeName))
Expand Down
19 changes: 13 additions & 6 deletions Controllers/CRON/BaibakoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@
using System.Collections.Generic;
using JacRed.Engine;
using JacRed.Models.Details;
using Microsoft.Extensions.Caching.Memory;

namespace JacRed.Controllers.CRON
{
[Route("/cron/baibako/[action]")]
public class BaibakoController : BaseController
{
#region TakeLogin
static string cookie { get; set; }
static string Cookie(IMemoryCache memoryCache)
{
if (memoryCache.TryGetValue("baibako:cookie", out string cookie))
return cookie;

return null;
}

async public static Task<bool> TakeLogin()
async public Task<bool> TakeLogin()
{
try
{
Expand Down Expand Up @@ -62,7 +69,7 @@ async public static Task<bool> TakeLogin()

if (!string.IsNullOrWhiteSpace(sessid) && !string.IsNullOrWhiteSpace(uid) && !string.IsNullOrWhiteSpace(pass))
{
cookie = $"PHPSESSID={sessid}; uid={uid}; pass={pass}";
memoryCache.Set("baibako:cookie", $"PHPSESSID={sessid}; uid={uid}; pass={pass}", DateTime.Now.AddDays(1));
return true;
}
}
Expand All @@ -83,7 +90,7 @@ async public static Task<bool> TakeLogin()
async public Task<string> Parse(int maxpage)
{
#region Авторизация
if (cookie == null)
if (Cookie(memoryCache) == null)
{
if (await TakeLogin() == false)
return "Не удалось авторизоваться";
Expand Down Expand Up @@ -116,7 +123,7 @@ async public Task<string> Parse(int maxpage)
#region parsePage
async Task<bool> parsePage(int page)
{
string html = await HttpClient.Get($"{AppInit.conf.Baibako.host}/browse.php?page={page}", encoding: Encoding.GetEncoding(1251), cookie: cookie);
string html = await HttpClient.Get($"{AppInit.conf.Baibako.host}/browse.php?page={page}", encoding: Encoding.GetEncoding(1251), cookie: Cookie(memoryCache));
if (html == null || !html.Contains("id=\"navtop\""))
return false;

Expand Down Expand Up @@ -201,7 +208,7 @@ await FileDB.AddOrUpdate(torrents, async (t, db) =>
if (db.TryGetValue(t.url, out TorrentDetails _tcache) && _tcache.title == t.title)
return true;

byte[] torrent = await HttpClient.Download(t.downloadUri, cookie: cookie, referer: $"{AppInit.conf.Baibako.host}/browse.php");
byte[] torrent = await HttpClient.Download(t.downloadUri, cookie: Cookie(memoryCache), referer: $"{AppInit.conf.Baibako.host}/browse.php");
string magnet = BencodeTo.Magnet(torrent);
string sizeName = BencodeTo.SizeName(torrent);

Expand Down
14 changes: 10 additions & 4 deletions Controllers/CRON/SelezenController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ static SelezenController()
}

#region Cookie / TakeLogin
static string Cookie;
static string Cookie(IMemoryCache memoryCache)
{
if (memoryCache.TryGetValue("selezen:cookie", out string cookie))
return cookie;

return null;
}

async Task<bool> TakeLogin()
{
Expand Down Expand Up @@ -77,7 +83,7 @@ async Task<bool> TakeLogin()

if (!string.IsNullOrWhiteSpace(PHPSESSID))
{
Cookie = $"PHPSESSID={PHPSESSID}; _ym_isad=2;";
memoryCache.Set("selezen:cookie", $"PHPSESSID={PHPSESSID}; _ym_isad=2;", DateTime.Now.AddDays(1));
return true;
}
}
Expand Down Expand Up @@ -167,14 +173,14 @@ async public Task<string> ParseAllTask()
async Task<bool> parsePage(int page)
{
#region Авторизация
if (Cookie == null && string.IsNullOrEmpty(AppInit.conf.Selezen.cookie))
if (Cookie(memoryCache) == null && string.IsNullOrEmpty(AppInit.conf.Selezen.cookie))
{
if (await TakeLogin() == false)
return false;
}
#endregion

string cookie = AppInit.conf.Selezen.cookie ?? Cookie;
string cookie = AppInit.conf.Selezen.cookie ?? Cookie(memoryCache);
string html = await HttpClient.Get(page == 1 ? $"{AppInit.conf.Selezen.host}/relizy-ot-selezen/" : $"{AppInit.conf.Selezen.host}/relizy-ot-selezen/page/{page}/", cookie: cookie, useproxy: AppInit.conf.Selezen.useproxy);
if (html == null || !html.Contains("dle_root"))
return false;
Expand Down

0 comments on commit bec3a40

Please sign in to comment.