Skip to content

Commit bec3a40

Browse files
committed
fix
1 parent 30f014b commit bec3a40

File tree

4 files changed

+36
-16
lines changed

4 files changed

+36
-16
lines changed

AppInit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static AppInit conf
8888

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

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

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

Controllers/CRON/AnimeLayerController.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,23 @@
88
using JacRed.Engine.CORE;
99
using JacRed.Models.Details;
1010
using Microsoft.AspNetCore.Mvc;
11+
using Microsoft.Extensions.Caching.Memory;
1112

1213
namespace JacRed.Controllers.CRON
1314
{
1415
[Route("/cron/animelayer/[action]")]
1516
public class AnimeLayerController : BaseController
1617
{
1718
#region TakeLogin
18-
static string Cookie { get; set; }
19+
static string Cookie(IMemoryCache memoryCache)
20+
{
21+
if (memoryCache.TryGetValue("animelayer:cookie", out string cookie))
22+
return cookie;
23+
24+
return null;
25+
}
1926

20-
async public static Task<bool> TakeLogin()
27+
async public Task<bool> TakeLogin()
2128
{
2229
try
2330
{
@@ -63,7 +70,7 @@ async public static Task<bool> TakeLogin()
6370

6471
if (!string.IsNullOrWhiteSpace(layer_id) && !string.IsNullOrWhiteSpace(layer_hash) && !string.IsNullOrWhiteSpace(PHPSESSID))
6572
{
66-
Cookie = $"layer_id={layer_id}; layer_hash={layer_hash}; PHPSESSID={PHPSESSID};";
73+
memoryCache.Set("animelayer:cookie", $"layer_id={layer_id}; layer_hash={layer_hash}; PHPSESSID={PHPSESSID};", DateTime.Now.AddDays(1));
6774
return true;
6875
}
6976
}
@@ -84,7 +91,7 @@ async public static Task<bool> TakeLogin()
8491
async public Task<string> Parse(int maxpage = 1)
8592
{
8693
#region Авторизация
87-
if (Cookie == null)
94+
if (Cookie(memoryCache) == null)
8895
{
8996
if (await TakeLogin() == false)
9097
return "Не удалось авторизоваться";
@@ -237,7 +244,7 @@ await FileDB.AddOrUpdate(torrents, async (t, db) =>
237244
if (db.TryGetValue(t.url, out TorrentDetails _tcache) && _tcache.title == t.title)
238245
return true;
239246

240-
byte[] torrent = await HttpClient.Download($"{t.url}download/", cookie: Cookie);
247+
byte[] torrent = await HttpClient.Download($"{t.url}download/", cookie: Cookie(memoryCache));
241248
string magnet = BencodeTo.Magnet(torrent);
242249
string sizeName = BencodeTo.SizeName(torrent);
243250
if (!string.IsNullOrWhiteSpace(magnet) && !string.IsNullOrWhiteSpace(sizeName))

Controllers/CRON/BaibakoController.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,23 @@
99
using System.Collections.Generic;
1010
using JacRed.Engine;
1111
using JacRed.Models.Details;
12+
using Microsoft.Extensions.Caching.Memory;
1213

1314
namespace JacRed.Controllers.CRON
1415
{
1516
[Route("/cron/baibako/[action]")]
1617
public class BaibakoController : BaseController
1718
{
1819
#region TakeLogin
19-
static string cookie { get; set; }
20+
static string Cookie(IMemoryCache memoryCache)
21+
{
22+
if (memoryCache.TryGetValue("baibako:cookie", out string cookie))
23+
return cookie;
24+
25+
return null;
26+
}
2027

21-
async public static Task<bool> TakeLogin()
28+
async public Task<bool> TakeLogin()
2229
{
2330
try
2431
{
@@ -62,7 +69,7 @@ async public static Task<bool> TakeLogin()
6269

6370
if (!string.IsNullOrWhiteSpace(sessid) && !string.IsNullOrWhiteSpace(uid) && !string.IsNullOrWhiteSpace(pass))
6471
{
65-
cookie = $"PHPSESSID={sessid}; uid={uid}; pass={pass}";
72+
memoryCache.Set("baibako:cookie", $"PHPSESSID={sessid}; uid={uid}; pass={pass}", DateTime.Now.AddDays(1));
6673
return true;
6774
}
6875
}
@@ -83,7 +90,7 @@ async public static Task<bool> TakeLogin()
8390
async public Task<string> Parse(int maxpage)
8491
{
8592
#region Авторизация
86-
if (cookie == null)
93+
if (Cookie(memoryCache) == null)
8794
{
8895
if (await TakeLogin() == false)
8996
return "Не удалось авторизоваться";
@@ -116,7 +123,7 @@ async public Task<string> Parse(int maxpage)
116123
#region parsePage
117124
async Task<bool> parsePage(int page)
118125
{
119-
string html = await HttpClient.Get($"{AppInit.conf.Baibako.host}/browse.php?page={page}", encoding: Encoding.GetEncoding(1251), cookie: cookie);
126+
string html = await HttpClient.Get($"{AppInit.conf.Baibako.host}/browse.php?page={page}", encoding: Encoding.GetEncoding(1251), cookie: Cookie(memoryCache));
120127
if (html == null || !html.Contains("id=\"navtop\""))
121128
return false;
122129

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

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

Controllers/CRON/SelezenController.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ static SelezenController()
2727
}
2828

2929
#region Cookie / TakeLogin
30-
static string Cookie;
30+
static string Cookie(IMemoryCache memoryCache)
31+
{
32+
if (memoryCache.TryGetValue("selezen:cookie", out string cookie))
33+
return cookie;
34+
35+
return null;
36+
}
3137

3238
async Task<bool> TakeLogin()
3339
{
@@ -77,7 +83,7 @@ async Task<bool> TakeLogin()
7783

7884
if (!string.IsNullOrWhiteSpace(PHPSESSID))
7985
{
80-
Cookie = $"PHPSESSID={PHPSESSID}; _ym_isad=2;";
86+
memoryCache.Set("selezen:cookie", $"PHPSESSID={PHPSESSID}; _ym_isad=2;", DateTime.Now.AddDays(1));
8187
return true;
8288
}
8389
}
@@ -167,14 +173,14 @@ async public Task<string> ParseAllTask()
167173
async Task<bool> parsePage(int page)
168174
{
169175
#region Авторизация
170-
if (Cookie == null && string.IsNullOrEmpty(AppInit.conf.Selezen.cookie))
176+
if (Cookie(memoryCache) == null && string.IsNullOrEmpty(AppInit.conf.Selezen.cookie))
171177
{
172178
if (await TakeLogin() == false)
173179
return false;
174180
}
175181
#endregion
176182

177-
string cookie = AppInit.conf.Selezen.cookie ?? Cookie;
183+
string cookie = AppInit.conf.Selezen.cookie ?? Cookie(memoryCache);
178184
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);
179185
if (html == null || !html.Contains("dle_root"))
180186
return false;

0 commit comments

Comments
 (0)