@@ -64,6 +64,10 @@ public ActionResult Jackett(string apikey, string query, string title, string ti
6464 {
6565 //Console.WriteLine(HttpContext.Request.Path + HttpContext.Request.QueryString.Value);
6666
67+ string cachekey = $ "api:v2.0:indexers:{ query } :{ title } :{ title_original } :{ year } :{ ( category != null && category . Count > 0 ? string . Join ( "," , category . Select ( i => $ "{ i . Key } ={ i . Value } ") ) : "null" ) } :{ is_serial } ";
68+ if ( memoryCache . TryGetValue ( cachekey , out List < Result > _cacheResult ) )
69+ return Json ( new RootObject ( ) { Results = _cacheResult } ) ;
70+
6771 var fastdb = getFastdb ( ) ;
6872 var torrents = new Dictionary < string , TorrentDetails > ( ) ;
6973 bool rqnum = ! HttpContext . Request . QueryString . Value . Contains ( "&is_serial=" ) && HttpContext . Request . Headers . UserAgent . ToString ( ) == "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36" ;
@@ -458,10 +462,10 @@ HashSet<int> getCategoryIds(TorrentDetails t, out string categoryDesc)
458462 {
459463 Dictionary < string , ( TorrentDetails torrent , string title , string Name , List < string > AnnounceUrls ) > temp = new Dictionary < string , ( TorrentDetails , string , string , List < string > ) > ( ) ;
460464
461- foreach ( var torrent in torrents . Values )
465+ foreach ( var torrent in torrents . Values . OrderByDescending ( i => i . createTime ) . ThenBy ( i => i . trackerName == "selezen" ) )
462466 {
463467 var magnetLink = MagnetLink . Parse ( torrent . magnet ) ;
464- string hex = magnetLink . InfoHash . ToHex ( ) ;
468+ string hex = magnetLink . InfoHashes . V1OrV2 . ToHex ( ) ;
465469
466470 if ( ! temp . TryGetValue ( hex , out _ ) )
467471 {
@@ -547,11 +551,14 @@ void UpdateTitle()
547551 }
548552 #endregion
549553
550- if ( torrent . sid > t . torrent . sid )
551- t . torrent . sid = torrent . sid ;
554+ if ( torrent . trackerName != "selezen" )
555+ {
556+ if ( torrent . sid > t . torrent . sid )
557+ t . torrent . sid = torrent . sid ;
552558
553- if ( torrent . pir > t . torrent . pir )
554- t . torrent . pir = torrent . pir ;
559+ if ( torrent . pir > t . torrent . pir )
560+ t . torrent . pir = torrent . pir ;
561+ }
555562
556563 if ( torrent . createTime > t . torrent . createTime )
557564 t . torrent . createTime = torrent . createTime ;
@@ -601,7 +608,7 @@ List<ffStream> FFprobe(TorrentDetails t, out HashSet<string> langs)
601608 return t . ffprobe ;
602609 }
603610
604- var streams = TracksDB . Get ( t . magnet , t . types ) ;
611+ var streams = TracksDB . Get ( t . magnet , t . types , onlydb : true ) ;
605612 langs = TracksDB . Languages ( t , streams ?? t . ffprobe ) ;
606613 if ( streams == null )
607614 return null ;
@@ -646,6 +653,9 @@ List<ffStream> FFprobe(TorrentDetails t, out HashSet<string> langs)
646653 } ) ;
647654 }
648655
656+ if ( AppInit . conf . evercache . enable && AppInit . conf . evercache . validHour == 0 )
657+ memoryCache . Set ( cachekey , Results , DateTime . Now . AddMinutes ( 5 ) ) ;
658+
649659 return Json ( new RootObject ( ) { Results = Results } ) ;
650660 }
651661 #endregion
@@ -847,7 +857,7 @@ void AddTorrents(TorrentDetails t)
847857 langs = TracksDB . Languages ( t , t . ffprobe ) ;
848858 else
849859 {
850- var streams = TracksDB . Get ( t . magnet , t . types ) ;
860+ var streams = TracksDB . Get ( t . magnet , t . types , onlydb : true ) ;
851861 langs = TracksDB . Languages ( t , streams ?? t . ffprobe ) ;
852862 }
853863
@@ -930,7 +940,7 @@ public static Dictionary<string, List<string>> getFastdb(bool update = false)
930940 {
931941 var fastdb = new Dictionary < string , List < string > > ( ) ;
932942
933- foreach ( var item in FileDB . masterDb )
943+ foreach ( var item in FileDB . masterDb . ToArray ( ) )
934944 {
935945 foreach ( string k in item . Key . Split ( ":" ) )
936946 {
0 commit comments