mirror of
https://github.com/Jackett/Jackett
synced 2025-03-06 11:48:49 +00:00
beyond-hd-api: minor cleanup (#14190)
This commit is contained in:
parent
510168e43c
commit
fc4f4eaf23
1 changed files with 39 additions and 16 deletions
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Jackett.Common.Extensions;
|
||||||
using Jackett.Common.Models;
|
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;
|
||||||
|
@ -71,12 +72,21 @@ namespace Jackett.Common.Indexers
|
||||||
{
|
{
|
||||||
LoadValuesFromJson(configJson);
|
LoadValuesFromJson(configJson);
|
||||||
|
|
||||||
|
if (configData.ApiKey.Value.IsNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
throw new Exception("Missing API Key.");
|
||||||
|
}
|
||||||
|
|
||||||
IsConfigured = false;
|
IsConfigured = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var results = await PerformQuery(new TorznabQuery());
|
var results = await PerformQuery(new TorznabQuery());
|
||||||
if (results.Count() == 0)
|
|
||||||
|
if (!results.Any())
|
||||||
|
{
|
||||||
throw new Exception("Testing returned no results!");
|
throw new Exception("Testing returned no results!");
|
||||||
|
}
|
||||||
|
|
||||||
IsConfigured = true;
|
IsConfigured = true;
|
||||||
SaveConfig();
|
SaveConfig();
|
||||||
}
|
}
|
||||||
|
@ -93,7 +103,7 @@ namespace Jackett.Common.Indexers
|
||||||
var apiKey = configData.ApiKey.Value;
|
var apiKey = configData.ApiKey.Value;
|
||||||
var apiUrl = $"{APIBASE}{apiKey}";
|
var apiUrl = $"{APIBASE}{apiKey}";
|
||||||
|
|
||||||
Dictionary<string, string> postData = new Dictionary<string, string>
|
var postData = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ BHDParams.action, "search" },
|
{ BHDParams.action, "search" },
|
||||||
{ BHDParams.rsskey, configData.RSSKey.Value },
|
{ BHDParams.rsskey, configData.RSSKey.Value },
|
||||||
|
@ -167,24 +177,37 @@ namespace Jackett.Common.Indexers
|
||||||
|
|
||||||
private string getTitle(BHDResult bhdResult)
|
private string getTitle(BHDResult bhdResult)
|
||||||
{
|
{
|
||||||
var title = bhdResult.name;
|
var title = bhdResult.name.Trim();
|
||||||
if (!configData.AddHybridFeaturesToTitle.Value)
|
|
||||||
return title;
|
|
||||||
|
|
||||||
var featureCount = bhdResult.dv + bhdResult.hdr10 + bhdResult.hdr10plus + bhdResult.hlg;
|
if (!configData.AddHybridFeaturesToTitle.Value)
|
||||||
if (featureCount > 1)
|
|
||||||
{
|
{
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
var features = new List<string>();
|
var features = new List<string>();
|
||||||
|
|
||||||
if (bhdResult.dv == 1)
|
if (bhdResult.dv == 1)
|
||||||
|
{
|
||||||
features.Add("Dolby Vision");
|
features.Add("Dolby Vision");
|
||||||
if (bhdResult.hdr10 == 1)
|
}
|
||||||
features.Add("HDR10");
|
|
||||||
if (bhdResult.hdr10plus == 1)
|
|
||||||
features.Add("HDR10+");
|
|
||||||
if (bhdResult.hlg == 1)
|
|
||||||
features.Add("HLG");
|
|
||||||
|
|
||||||
|
if (bhdResult.hdr10 == 1)
|
||||||
|
{
|
||||||
|
features.Add("HDR10");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bhdResult.hdr10plus == 1)
|
||||||
|
{
|
||||||
|
features.Add("HDR10+");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bhdResult.hlg == 1)
|
||||||
|
{
|
||||||
|
features.Add("HLG");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (features.Any())
|
||||||
|
{
|
||||||
title += $" ({string.Join(" / ", features)})";
|
title += $" ({string.Join(" / ", features)})";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue