toloka: add freeleech search. #9456

This commit is contained in:
Garfield69 2023-04-01 19:46:22 +13:00
parent 19ca962177
commit 9e849c03ce
1 changed files with 15 additions and 0 deletions

View File

@ -10,8 +10,11 @@ using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig.Bespoke; using Jackett.Common.Models.IndexerConfig.Bespoke;
using Jackett.Common.Services.Interfaces; using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils; using Jackett.Common.Utils;
using Microsoft.AspNetCore.Http.Internal;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using NLog; using NLog;
using static System.Net.Mime.MediaTypeNames;
using static Jackett.Common.Models.IndexerConfig.ConfigurationData;
using WebClient = Jackett.Common.Utils.Clients.WebClient; using WebClient = Jackett.Common.Utils.Clients.WebClient;
namespace Jackett.Common.Indexers namespace Jackett.Common.Indexers
@ -46,6 +49,7 @@ namespace Jackett.Common.Indexers
cacheService: cs, cacheService: cs,
configData: new ConfigurationDataToloka()) configData: new ConfigurationDataToloka())
{ {
configData.AddDynamic("freeleech", new BoolConfigurationItem("Search freeleech only") { Value = false });
} }
private TorznabCapabilities SetCapabilities() private TorznabCapabilities SetCapabilities()
@ -245,6 +249,9 @@ namespace Jackett.Common.Indexers
{"s", "2"} {"s", "2"}
}; };
if (((BoolConfigurationItem)configData.GetDynamic("freeleech")).Value)
qc.Add("sds", "1");
// if the search string is empty use the getnew view // if the search string is empty use the getnew view
if (string.IsNullOrWhiteSpace(searchString)) if (string.IsNullOrWhiteSpace(searchString))
qc.Add("nm", searchString); qc.Add("nm", searchString);
@ -312,6 +319,14 @@ namespace Jackett.Common.Indexers
MinimumRatio = 1, MinimumRatio = 1,
MinimumSeedTime = 0 MinimumSeedTime = 0
}; };
if (row.QuerySelector("img[src=\"images/gold.gif\"]") != null)
release.DownloadVolumeFactor = 0;
else if (row.QuerySelector("img[src=\"images/silver.gif\"]") != null)
release.DownloadVolumeFactor = 0.5;
else if (row.QuerySelector("img[src=\"images/bronze.gif\"]") != null)
release.DownloadVolumeFactor = 0.75;
else
release.DownloadVolumeFactor = 1;
releases.Add(release); releases.Add(release);
} }