Skip to content

Commit e7ba85d

Browse files
committed
dev
1 parent c01051a commit e7ba85d

File tree

5 files changed

+35
-16
lines changed

5 files changed

+35
-16
lines changed

AppInit.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public static AppInit conf
4343

4444
public bool mergeduplicates = true;
4545

46+
public bool mergenumduplicates = true;
47+
4648
public bool openstats = true;
4749

4850
public bool opensync = true;
@@ -65,7 +67,7 @@ public static AppInit conf
6567

6668
public string[] synctrackers = null;
6769

68-
public int maxreadfile = 80;
70+
public int maxreadfile = 200;
6971

7072
public bool evercache = false;
7173

Controllers/ApiController.cs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public ActionResult Jackett(string apikey, string query, string title, string ti
4646
if (string.IsNullOrWhiteSpace(title) && string.IsNullOrWhiteSpace(title_original) &&
4747
mNum.Success)
4848
{
49-
if (Regex.IsMatch(mNum.Groups[2].Value, "[a-zA-Z]{4}"))
49+
if (Regex.IsMatch(mNum.Groups[2].Value, "[a-zA-Z0-9]{2}"))
5050
{
5151
rqnum = true;
5252
var g = mNum.Groups;
@@ -109,7 +109,11 @@ void AddTorrents(TorrentDetails t)
109109
string _o = StringConvert.SearchName(title_original);
110110

111111
// Быстрая выборка по совпадению ключа в имени
112-
foreach (var val in FileDB.masterDb.Where(i => (_n != null && i.Key.StartsWith($"{_n}:")) || (_o != null && i.Key.EndsWith($":{_o}"))).Take(AppInit.conf.maxreadfile))
112+
var mdb = FileDB.masterDb.Where(i => (_n != null && i.Key.StartsWith($"{_n}:")) || (_o != null && i.Key.EndsWith($":{_o}")));
113+
if (!AppInit.conf.evercache)
114+
mdb = mdb.Take(AppInit.conf.maxreadfile);
115+
116+
foreach (var val in mdb)
113117
{
114118
foreach (var t in FileDB.OpenRead(val.Key).Values)
115119
{
@@ -238,15 +242,19 @@ void AddTorrents(TorrentDetails t)
238242
}
239243
#endregion
240244
}
241-
else if (!string.IsNullOrWhiteSpace(query) && query.Length > 3)
245+
else if (!string.IsNullOrWhiteSpace(query) && query.Length > 1)
242246
{
243247
#region Обычный поиск
244248
string _s = StringConvert.SearchName(query);
245249

246250
#region torrentsSearch
247251
void torrentsSearch(bool exact)
248252
{
249-
foreach (var val in FileDB.masterDb.OrderByDescending(i => i.Value).Where(i => i.Key.Contains(_s)).Take(AppInit.conf.maxreadfile))
253+
var mdb = FileDB.masterDb.OrderByDescending(i => i.Value).Where(i => i.Key.Contains(_s));
254+
if (!AppInit.conf.evercache)
255+
mdb = mdb.Take(AppInit.conf.maxreadfile);
256+
257+
foreach (var val in mdb)
250258
{
251259
foreach (var t in FileDB.OpenRead(val.Key).Values)
252260
{
@@ -346,11 +354,7 @@ HashSet<int> getCategoryIds(TorrentDetails t, out string categoryDesc)
346354
#region Объединить дубликаты
347355
var tsort = new List<TorrentDetails>();
348356

349-
if (!AppInit.conf.mergeduplicates || rqnum)
350-
{
351-
tsort = torrents.Values.ToList();
352-
}
353-
else
357+
if (AppInit.conf.mergeduplicates || (rqnum && AppInit.conf.mergenumduplicates))
354358
{
355359
Dictionary<string, (TorrentDetails torrent, string title, string Name, List<string> AnnounceUrls)> temp = new Dictionary<string, (TorrentDetails, string, string, List<string>)>();
356360

@@ -478,6 +482,10 @@ void UpdateTitle()
478482
foreach (var item in temp.Select(i => i.Value.torrent))
479483
tsort.Add(item);
480484
}
485+
else
486+
{
487+
tsort = torrents.Values.ToList();
488+
}
481489
#endregion
482490

483491
#region FFprobe
@@ -592,7 +600,7 @@ void AddTorrents(TorrentDetails t)
592600
}
593601
#endregion
594602

595-
if (string.IsNullOrWhiteSpace(search) || 3 >= search.Length)
603+
if (string.IsNullOrWhiteSpace(search) || search.Length == 1)
596604
return Json(torrents);
597605

598606
string _s = StringConvert.SearchName(search);
@@ -624,9 +632,13 @@ void AddTorrents(TorrentDetails t)
624632
else
625633
{
626634
#region Поиск по совпадению ключа в имени
627-
foreach (var mdb in FileDB.masterDb.OrderByDescending(i => i.Value).Where(i => i.Key.Contains(_s) || (_altsearch != null && i.Key.Contains(_altsearch))).Take(AppInit.conf.maxreadfile))
635+
var mdb = FileDB.masterDb.OrderByDescending(i => i.Value).Where(i => i.Key.Contains(_s) || (_altsearch != null && i.Key.Contains(_altsearch)));
636+
if (!AppInit.conf.evercache)
637+
mdb = mdb.Take(AppInit.conf.maxreadfile);
638+
639+
foreach (var val in mdb)
628640
{
629-
foreach (var t in FileDB.OpenRead(mdb.Key).Values)
641+
foreach (var t in FileDB.OpenRead(val.Key).Values)
630642
{
631643
if (t.types == null)
632644
continue;

Controllers/CRON/RutrackerController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,11 @@ await FileDB.AddOrUpdate(torrents, async (t, db) =>
727727
var fullNews = await HttpClient.Get(t.url, useproxy: AppInit.conf.Rutracker.useproxy);
728728
if (fullNews != null)
729729
{
730+
string time = Regex.Match(fullNews, "<a class=\"p-link small\" href=\"viewtopic.php\\?t=[^\"]+\">([^<]+)</a>").Groups[1].Value;
731+
DateTime createTime = tParse.ParseCreateTime(time.Replace("-", " "), "dd.MM.yy HH:mm");
732+
if (createTime != default)
733+
t.createTime = createTime;
734+
730735
string magnet = Regex.Match(fullNews, "href=\"(magnet:[^\"]+)\" class=\"(med )?magnet-link\"").Groups[1].Value;
731736
if (!string.IsNullOrWhiteSpace(magnet))
732737
{

Engine/StatsCron.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Newtonsoft.Json;
22
using System;
33
using System.Collections.Generic;
4-
using System.Diagnostics;
54
using System.IO;
65
using System.Linq;
76
using System.Threading.Tasks;
@@ -50,7 +49,7 @@ async public static Task Run()
5049

5150
if (AppInit.conf.tracks && !TracksDB.theBad(t.types))
5251
{
53-
if (!string.IsNullOrEmpty(t.magnet) && t.sid > 0 && t.updateTime > DateTime.Today.AddDays(-20))
52+
if (!string.IsNullOrEmpty(t.magnet))
5453
{
5554
if (TracksDB.Get(t.magnet) != null)
5655
s.trkconfirm = s.trkconfirm + 1;

Engine/Tracks/TracksCron.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ async public static Task Run(int typetask)
8383
//if (hex == null)
8484
// continue;
8585

86-
torrents.Add((t.trackerName, t.magnet));
86+
if (typetask == 1 || (t.sid > 0 && t.updateTime > DateTime.Today.AddDays(-20)))
87+
torrents.Add((t.trackerName, t.magnet));
8788
}
8889
catch { }
8990
}

0 commit comments

Comments
 (0)