hdbits: add use filename options and set empty default values for codec, medium and origin

This commit is contained in:
Bogdan
2023-11-16 20:25:08 +02:00
parent ddf5070d88
commit 861945affc
2 changed files with 47 additions and 26 deletions

View File

@@ -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)

View File

@@ -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<string, string>()
{
{"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<string, string>()
Codecs = new MultiSelectConfigurationItem(
"Codec",
new Dictionary<string, string>
{
{"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<string, string>()
Mediums = new MultiSelectConfigurationItem(
"Medium",
new Dictionary<string, string>
{
{"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<string, string>
{
{ "0", "Undefined" },
{ "1", "Internal" }
});
}
}
}