Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
immisterio committed Aug 28, 2023
1 parent c01051a commit e7ba85d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 16 deletions.
4 changes: 3 additions & 1 deletion AppInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public static AppInit conf

public bool mergeduplicates = true;

public bool mergenumduplicates = true;

public bool openstats = true;

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

public string[] synctrackers = null;

public int maxreadfile = 80;
public int maxreadfile = 200;

public bool evercache = false;

Expand Down
36 changes: 24 additions & 12 deletions Controllers/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ActionResult Jackett(string apikey, string query, string title, string ti
if (string.IsNullOrWhiteSpace(title) && string.IsNullOrWhiteSpace(title_original) &&
mNum.Success)
{
if (Regex.IsMatch(mNum.Groups[2].Value, "[a-zA-Z]{4}"))
if (Regex.IsMatch(mNum.Groups[2].Value, "[a-zA-Z0-9]{2}"))
{
rqnum = true;
var g = mNum.Groups;
Expand Down Expand Up @@ -109,7 +109,11 @@ void AddTorrents(TorrentDetails t)
string _o = StringConvert.SearchName(title_original);

// Быстрая выборка по совпадению ключа в имени
foreach (var val in FileDB.masterDb.Where(i => (_n != null && i.Key.StartsWith($"{_n}:")) || (_o != null && i.Key.EndsWith($":{_o}"))).Take(AppInit.conf.maxreadfile))
var mdb = FileDB.masterDb.Where(i => (_n != null && i.Key.StartsWith($"{_n}:")) || (_o != null && i.Key.EndsWith($":{_o}")));
if (!AppInit.conf.evercache)
mdb = mdb.Take(AppInit.conf.maxreadfile);

foreach (var val in mdb)
{
foreach (var t in FileDB.OpenRead(val.Key).Values)
{
Expand Down Expand Up @@ -238,15 +242,19 @@ void AddTorrents(TorrentDetails t)
}
#endregion
}
else if (!string.IsNullOrWhiteSpace(query) && query.Length > 3)
else if (!string.IsNullOrWhiteSpace(query) && query.Length > 1)
{
#region Обычный поиск
string _s = StringConvert.SearchName(query);

#region torrentsSearch
void torrentsSearch(bool exact)
{
foreach (var val in FileDB.masterDb.OrderByDescending(i => i.Value).Where(i => i.Key.Contains(_s)).Take(AppInit.conf.maxreadfile))
var mdb = FileDB.masterDb.OrderByDescending(i => i.Value).Where(i => i.Key.Contains(_s));
if (!AppInit.conf.evercache)
mdb = mdb.Take(AppInit.conf.maxreadfile);

foreach (var val in mdb)
{
foreach (var t in FileDB.OpenRead(val.Key).Values)
{
Expand Down Expand Up @@ -346,11 +354,7 @@ HashSet<int> getCategoryIds(TorrentDetails t, out string categoryDesc)
#region Объединить дубликаты
var tsort = new List<TorrentDetails>();

if (!AppInit.conf.mergeduplicates || rqnum)
{
tsort = torrents.Values.ToList();
}
else
if (AppInit.conf.mergeduplicates || (rqnum && AppInit.conf.mergenumduplicates))
{
Dictionary<string, (TorrentDetails torrent, string title, string Name, List<string> AnnounceUrls)> temp = new Dictionary<string, (TorrentDetails, string, string, List<string>)>();

Expand Down Expand Up @@ -478,6 +482,10 @@ void UpdateTitle()
foreach (var item in temp.Select(i => i.Value.torrent))
tsort.Add(item);
}
else
{
tsort = torrents.Values.ToList();
}
#endregion

#region FFprobe
Expand Down Expand Up @@ -592,7 +600,7 @@ void AddTorrents(TorrentDetails t)
}
#endregion

if (string.IsNullOrWhiteSpace(search) || 3 >= search.Length)
if (string.IsNullOrWhiteSpace(search) || search.Length == 1)
return Json(torrents);

string _s = StringConvert.SearchName(search);
Expand Down Expand Up @@ -624,9 +632,13 @@ void AddTorrents(TorrentDetails t)
else
{
#region Поиск по совпадению ключа в имени
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))
var mdb = FileDB.masterDb.OrderByDescending(i => i.Value).Where(i => i.Key.Contains(_s) || (_altsearch != null && i.Key.Contains(_altsearch)));
if (!AppInit.conf.evercache)
mdb = mdb.Take(AppInit.conf.maxreadfile);

foreach (var val in mdb)
{
foreach (var t in FileDB.OpenRead(mdb.Key).Values)
foreach (var t in FileDB.OpenRead(val.Key).Values)
{
if (t.types == null)
continue;
Expand Down
5 changes: 5 additions & 0 deletions Controllers/CRON/RutrackerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,11 @@ await FileDB.AddOrUpdate(torrents, async (t, db) =>
var fullNews = await HttpClient.Get(t.url, useproxy: AppInit.conf.Rutracker.useproxy);
if (fullNews != null)
{
string time = Regex.Match(fullNews, "<a class=\"p-link small\" href=\"viewtopic.php\\?t=[^\"]+\">([^<]+)</a>").Groups[1].Value;
DateTime createTime = tParse.ParseCreateTime(time.Replace("-", " "), "dd.MM.yy HH:mm");
if (createTime != default)
t.createTime = createTime;
string magnet = Regex.Match(fullNews, "href=\"(magnet:[^\"]+)\" class=\"(med )?magnet-link\"").Groups[1].Value;
if (!string.IsNullOrWhiteSpace(magnet))
{
Expand Down
3 changes: 1 addition & 2 deletions Engine/StatsCron.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -50,7 +49,7 @@ async public static Task Run()

if (AppInit.conf.tracks && !TracksDB.theBad(t.types))
{
if (!string.IsNullOrEmpty(t.magnet) && t.sid > 0 && t.updateTime > DateTime.Today.AddDays(-20))
if (!string.IsNullOrEmpty(t.magnet))
{
if (TracksDB.Get(t.magnet) != null)
s.trkconfirm = s.trkconfirm + 1;
Expand Down
3 changes: 2 additions & 1 deletion Engine/Tracks/TracksCron.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ async public static Task Run(int typetask)
//if (hex == null)
// continue;

torrents.Add((t.trackerName, t.magnet));
if (typetask == 1 || (t.sid > 0 && t.updateTime > DateTime.Today.AddDays(-20)))
torrents.Add((t.trackerName, t.magnet));
}
catch { }
}
Expand Down

0 comments on commit e7ba85d

Please sign in to comment.