From 861945affc4cd9538e12769ce81760209ec25d9f Mon Sep 17 00:00:00 2001 From: Bogdan Date: Thu, 16 Nov 2023 20:25:08 +0200 Subject: [PATCH] hdbits: add use filename options and set empty default values for codec, medium and origin --- src/Jackett.Common/Indexers/HDBitsApi.cs | 14 ++++- .../Bespoke/ConfigurationDataHDBitsApi.cs | 59 +++++++++++-------- 2 files changed, 47 insertions(+), 26 deletions(-) diff --git a/src/Jackett.Common/Indexers/HDBitsApi.cs b/src/Jackett.Common/Indexers/HDBitsApi.cs index 430ebbf1d..6b8affdd7 100644 --- a/src/Jackett.Common/Indexers/HDBitsApi.cs +++ b/src/Jackett.Common/Indexers/HDBitsApi.cs @@ -4,6 +4,7 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Threading.Tasks; +using Jackett.Common.Extensions; using Jackett.Common.Models; using Jackett.Common.Models.IndexerConfig.Bespoke; using Jackett.Common.Services.Interfaces; @@ -177,7 +178,8 @@ namespace Jackett.Common.Indexers continue; } - var title = (string)r["name"]; + var title = GetTitle(r); + // if tv then match query keywords against title #12753 if (!query.IsImdbQuery && !query.MatchQueryStringAND(title)) { @@ -223,6 +225,16 @@ namespace Jackett.Common.Indexers return releases; } + private string GetTitle(JObject item) + { + var filename = (string)item["filename"]; + var name = (string)item["name"]; + + return configData.UseFilenames.Value && filename.IsNotNullOrWhiteSpace() + ? filename.Replace(".torrent", "") + : name; + } + private static double GetUploadFactor(JObject r) => (int)r["type_category"] == 7 ? 0 : 1; private static double GetDownloadFactor(JObject r) diff --git a/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataHDBitsApi.cs b/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataHDBitsApi.cs index 173332359..fb403ab97 100644 --- a/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataHDBitsApi.cs +++ b/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataHDBitsApi.cs @@ -10,6 +10,7 @@ namespace Jackett.Common.Models.IndexerConfig.Bespoke public MultiSelectConfigurationItem Mediums { get; private set; } public MultiSelectConfigurationItem Origins { get; private set; } public BoolConfigurationItem FilterFreeleech { get; private set; } + public BoolConfigurationItem UseFilenames { get; private set; } public ConfigurationDataHDBitsApi() { @@ -18,35 +19,43 @@ namespace Jackett.Common.Models.IndexerConfig.Bespoke Value = false }; - Codecs = new MultiSelectConfigurationItem("Codec", new Dictionary() - { - {"0", "Undefined"}, - {"1", "H.264"}, - {"5", "HEVC"}, - {"2", "MPEG-2"}, - {"3", "VC-1"}, - {"6", "VP9"}, - {"4", "XviD"} - }) - { Values = new[] { "0", "1", "5", "2", "3", "6", "4" } }; + UseFilenames = new BoolConfigurationItem("Use Filenames as release titles") + { + Value = false + }; - Mediums = new MultiSelectConfigurationItem("Medium", new Dictionary() + Codecs = new MultiSelectConfigurationItem( + "Codec", + new Dictionary { - {"0", "Undefined"}, - {"1", "Blu-ray/HD DVD"}, - {"4", "Capture"}, - {"3", "Encode"}, - {"5", "Remux"}, - {"6", "WEB-DL"} - }) - { Values = new[] { "0", "1", "4", "3", "5", "6" } }; + { "0", "Undefined" }, + { "1", "H.264" }, + { "5", "HEVC" }, + { "2", "MPEG-2" }, + { "3", "VC-1" }, + { "6", "VP9" }, + { "4", "XviD" } + }); - Origins = new MultiSelectConfigurationItem("Origin", new Dictionary() + Mediums = new MultiSelectConfigurationItem( + "Medium", + new Dictionary { - {"0", "Undefined"}, - {"1", "Internal"} - }) - { Values = new[] { "0", "1" } }; + { "0", "Undefined" }, + { "1", "Blu-ray/HD DVD" }, + { "4", "Capture" }, + { "3", "Encode" }, + { "5", "Remux" }, + { "6", "WEB-DL" } + }); + + Origins = new MultiSelectConfigurationItem( + "Origin", + new Dictionary + { + { "0", "Undefined" }, + { "1", "Internal" } + }); } } }