mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
cache: ignore the Cache property on TorznabQuery (#14092)
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Jackett.Common.Utils;
|
using Jackett.Common.Utils;
|
||||||
|
|
||||||
@@ -50,22 +51,17 @@ namespace Jackett.Common.Models.DTO
|
|||||||
if (!string.IsNullOrWhiteSpace(request.offset))
|
if (!string.IsNullOrWhiteSpace(request.offset))
|
||||||
query.Offset = ParseUtil.CoerceInt(request.offset);
|
query.Offset = ParseUtil.CoerceInt(request.offset);
|
||||||
|
|
||||||
bool _cache;
|
if (bool.TryParse(request.cache, out var _cache))
|
||||||
if (bool.TryParse(request.cache, out _cache))
|
|
||||||
{
|
|
||||||
query.Cache = _cache;
|
query.Cache = _cache;
|
||||||
}
|
|
||||||
|
|
||||||
if (request.cat != null)
|
if (request.cat != null)
|
||||||
{
|
query.Categories = request.cat.Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(int.Parse).ToArray();
|
||||||
query.Categories = request.cat.Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => int.Parse(s)).ToArray();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (query.QueryType == "movie" && !string.IsNullOrWhiteSpace(request.imdbid))
|
if (query.QueryType == "movie" && !string.IsNullOrWhiteSpace(request.imdbid))
|
||||||
query.Categories = new int[] { TorznabCatType.Movies.ID };
|
query.Categories = new[] { TorznabCatType.Movies.ID };
|
||||||
else
|
else
|
||||||
query.Categories = new int[0];
|
query.Categories = Array.Empty<int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(request.season))
|
if (!string.IsNullOrWhiteSpace(request.season))
|
||||||
|
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Jackett.Common.Extensions;
|
using Jackett.Common.Extensions;
|
||||||
using Jackett.Common.Utils;
|
using Jackett.Common.Utils;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Jackett.Common.Models
|
namespace Jackett.Common.Models
|
||||||
{
|
{
|
||||||
@@ -25,6 +26,8 @@ namespace Jackett.Common.Models
|
|||||||
public int? TvmazeID { get; set; }
|
public int? TvmazeID { get; set; }
|
||||||
public int? TraktID { get; set; }
|
public int? TraktID { get; set; }
|
||||||
public int? DoubanID { get; set; }
|
public int? DoubanID { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool Cache { get; set; } = true;
|
public bool Cache { get; set; } = true;
|
||||||
|
|
||||||
public int Season { get; set; }
|
public int Season { get; set; }
|
||||||
|
@@ -8,6 +8,7 @@ using Jackett.Common.Models;
|
|||||||
using Jackett.Common.Models.Config;
|
using Jackett.Common.Models.Config;
|
||||||
using Jackett.Common.Services.Interfaces;
|
using Jackett.Common.Services.Interfaces;
|
||||||
using Jackett.Common.Utils;
|
using Jackett.Common.Utils;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
namespace Jackett.Common.Services
|
namespace Jackett.Common.Services
|
||||||
@@ -248,15 +249,12 @@ namespace Jackett.Common.Services
|
|||||||
|
|
||||||
private static string GetSerializedQuery(TorznabQuery query)
|
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
|
// Changes in the query to improve cache hits
|
||||||
// Both request must return the same results, if not we are breaking Jackett search
|
// Both request must return the same results, if not we are breaking Jackett search
|
||||||
json = json.Replace("\"SearchTerm\":null", "\"SearchTerm\":\"\"");
|
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;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user