mirror of
https://github.com/Jackett/Jackett
synced 2025-01-03 05:36:44 +00:00
cache: ignore the Cache property on TorznabQuery (#14092)
This commit is contained in:
parent
378d5eeaa4
commit
39129cf0f8
3 changed files with 10 additions and 13 deletions
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Jackett.Common.Utils;
|
||||
|
||||
|
@ -50,22 +51,17 @@ namespace Jackett.Common.Models.DTO
|
|||
if (!string.IsNullOrWhiteSpace(request.offset))
|
||||
query.Offset = ParseUtil.CoerceInt(request.offset);
|
||||
|
||||
bool _cache;
|
||||
if (bool.TryParse(request.cache, out _cache))
|
||||
{
|
||||
if (bool.TryParse(request.cache, out var _cache))
|
||||
query.Cache = _cache;
|
||||
}
|
||||
|
||||
if (request.cat != null)
|
||||
{
|
||||
query.Categories = request.cat.Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => int.Parse(s)).ToArray();
|
||||
}
|
||||
query.Categories = request.cat.Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(int.Parse).ToArray();
|
||||
else
|
||||
{
|
||||
if (query.QueryType == "movie" && !string.IsNullOrWhiteSpace(request.imdbid))
|
||||
query.Categories = new int[] { TorznabCatType.Movies.ID };
|
||||
query.Categories = new[] { TorznabCatType.Movies.ID };
|
||||
else
|
||||
query.Categories = new int[0];
|
||||
query.Categories = Array.Empty<int>();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.season))
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Text.RegularExpressions;
|
||||
using Jackett.Common.Extensions;
|
||||
using Jackett.Common.Utils;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Jackett.Common.Models
|
||||
{
|
||||
|
@ -25,6 +26,8 @@ namespace Jackett.Common.Models
|
|||
public int? TvmazeID { get; set; }
|
||||
public int? TraktID { get; set; }
|
||||
public int? DoubanID { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool Cache { get; set; } = true;
|
||||
|
||||
public int Season { get; set; }
|
||||
|
|
|
@ -8,6 +8,7 @@ using Jackett.Common.Models;
|
|||
using Jackett.Common.Models.Config;
|
||||
using Jackett.Common.Services.Interfaces;
|
||||
using Jackett.Common.Utils;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
|
||||
namespace Jackett.Common.Services
|
||||
|
@ -248,15 +249,12 @@ namespace Jackett.Common.Services
|
|||
|
||||
private static string GetSerializedQuery(TorznabQuery query)
|
||||
{
|
||||
var json = Newtonsoft.Json.JsonConvert.SerializeObject(query);
|
||||
var json = JsonConvert.SerializeObject(query);
|
||||
|
||||
// Changes in the query to improve cache hits
|
||||
// Both request must return the same results, if not we are breaking Jackett search
|
||||
json = json.Replace("\"SearchTerm\":null", "\"SearchTerm\":\"\"");
|
||||
|
||||
// The Cache parameter's value should not affect caching itself
|
||||
json = json.Replace("\"Cache\":false", "\"Cache\":true");
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue