New: Additional options for HDBits

This commit is contained in:
Bogdan 2023-11-17 17:25:38 +02:00 committed by GitHub
parent 6ddfd99619
commit 5328fb4ab3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 29 deletions

View File

@ -12,7 +12,7 @@ namespace NzbDrone.Core.Indexers.HDBits
public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
public override bool SupportsRss => true;
public override bool SupportsSearch => true;
public override int PageSize => 30;
public override int PageSize => 100;
public HDBits(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger, ILocalizationService localizationService)
: base(httpClient, indexerStatusService, configService, parsingService, logger, localizationService)
@ -21,7 +21,7 @@ namespace NzbDrone.Core.Indexers.HDBits
public override IIndexerRequestGenerator GetRequestGenerator()
{
return new HDBitsRequestGenerator() { Settings = Settings };
return new HDBitsRequestGenerator { Settings = Settings };
}
public override IParseIndexerResponse GetParser()

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace NzbDrone.Core.Indexers.HDBits
@ -7,20 +8,16 @@ namespace NzbDrone.Core.Indexers.HDBits
{
[JsonProperty(Required = Required.Always)]
public string Username { get; set; }
[JsonProperty(Required = Required.Always)]
public string Passkey { get; set; }
public string Hash { get; set; }
public string Search { get; set; }
public int[] Category { get; set; }
public int[] Codec { get; set; }
public int[] Medium { get; set; }
public int[] Origin { get; set; }
public IEnumerable<int> Category { get; set; }
public IEnumerable<int> Codec { get; set; }
public IEnumerable<int> Medium { get; set; }
public int? Origin { get; set; }
[JsonProperty(PropertyName = "imdb")]
public ImdbInfo ImdbInfo { get; set; }
@ -33,6 +30,7 @@ namespace NzbDrone.Core.Indexers.HDBits
[JsonProperty(PropertyName = "snatched_only")]
public bool? SnatchedOnly { get; set; }
public int? Limit { get; set; }
public int? Page { get; set; }

View File

@ -38,8 +38,7 @@ namespace NzbDrone.Core.Indexers.HDBits
jsonResponse.Message ?? string.Empty);
}
var responseData = jsonResponse.Data as JArray;
if (responseData == null)
if (jsonResponse.Data is not JArray responseData)
{
throw new IndexerException(indexerResponse,
"Indexer API call response missing result data");
@ -50,9 +49,9 @@ namespace NzbDrone.Core.Indexers.HDBits
foreach (var result in queryResults)
{
var id = result.Id;
torrentInfos.Add(new TorrentInfo()
torrentInfos.Add(new TorrentInfo
{
Guid = string.Format("HDBits-{0}", id),
Guid = $"HDBits-{id}",
Title = result.Name,
Size = result.Size,
InfoHash = result.Hash,

View File

@ -72,7 +72,7 @@ namespace NzbDrone.Core.Indexers.HDBits
if (TryAddSearchParameters(query, searchCriteria))
{
query.Search = string.Format("{0:yyyy}-{0:MM}-{0:dd}", searchCriteria.AirDate);
query.Search = searchCriteria.AirDate.ToString("yyyy-MM-dd");
pageableRequests.Add(GetRequest(query));
}
@ -87,7 +87,7 @@ namespace NzbDrone.Core.Indexers.HDBits
if (TryAddSearchParameters(query, searchCriteria))
{
query.Search = string.Format("{0}-", searchCriteria.Year);
query.Search = $"{searchCriteria.Year}-";
pageableRequests.Add(GetRequest(query));
}
@ -140,8 +140,9 @@ namespace NzbDrone.Core.Indexers.HDBits
{
if (searchCriteria.Series.TvdbId != 0)
{
query.TvdbInfo = query.TvdbInfo ?? new TvdbInfo();
query.TvdbInfo ??= new TvdbInfo();
query.TvdbInfo.Id = searchCriteria.Series.TvdbId;
return true;
}
@ -162,6 +163,12 @@ namespace NzbDrone.Core.Indexers.HDBits
query.Username = Settings.Username;
query.Passkey = Settings.ApiKey;
query.Category = Settings.Categories.ToArray();
query.Codec = Settings.Codecs.ToArray();
query.Medium = Settings.Mediums.ToArray();
query.Limit = 100;
request.SetContent(query.ToJson());
request.ContentSummary = query.ToJson(Formatting.None);

View File

@ -1,3 +1,5 @@
using System;
using System.Collections.Generic;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Validation;
@ -17,28 +19,41 @@ namespace NzbDrone.Core.Indexers.HDBits
public class HDBitsSettings : ITorrentIndexerSettings
{
private static readonly HDBitsSettingsValidator Validator = new HDBitsSettingsValidator();
private static readonly HDBitsSettingsValidator Validator = new ();
public HDBitsSettings()
{
BaseUrl = "https://hdbits.org";
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
Categories = new[] { (int)HdBitsCategory.Tv, (int)HdBitsCategory.Documentary };
Codecs = Array.Empty<int>();
Mediums = Array.Empty<int>();
}
[FieldDefinition(0, Label = "Username", Privacy = PrivacyLevel.UserName)]
public string Username { get; set; }
[FieldDefinition(1, Label = "ApiKey", Privacy = PrivacyLevel.ApiKey)]
public string ApiKey { get; set; }
[FieldDefinition(2, Label = "IndexerSettingsApiUrl", Advanced = true, HelpText = "IndexerSettingsApiUrlHelpText")]
[FieldDefinition(0, Label = "IndexerSettingsApiUrl", Advanced = true, HelpText = "IndexerSettingsApiUrlHelpText")]
public string BaseUrl { get; set; }
[FieldDefinition(3, Type = FieldType.Number, Label = "IndexerSettingsMinimumSeeders", HelpText = "IndexerSettingsMinimumSeedersHelpText", Advanced = true)]
[FieldDefinition(1, Label = "Username", Privacy = PrivacyLevel.UserName)]
public string Username { get; set; }
[FieldDefinition(2, Label = "ApiKey", Privacy = PrivacyLevel.ApiKey)]
public string ApiKey { get; set; }
[FieldDefinition(3, Label = "IndexerHDBitsSettingsCategories", Type = FieldType.Select, SelectOptions = typeof(HdBitsCategory), HelpText = "IndexerHDBitsSettingsCategoriesHelpText")]
public IEnumerable<int> Categories { get; set; }
[FieldDefinition(4, Label = "IndexerHDBitsSettingsCodecs", Type = FieldType.Select, SelectOptions = typeof(HdBitsCodec), Advanced = true, HelpText = "IndexerHDBitsSettingsCodecsHelpText")]
public IEnumerable<int> Codecs { get; set; }
[FieldDefinition(5, Label = "IndexerHDBitsSettingsMediums", Type = FieldType.Select, SelectOptions = typeof(HdBitsMedium), Advanced = true, HelpText = "IndexerHDBitsSettingsMediumsHelpText")]
public IEnumerable<int> Mediums { get; set; }
[FieldDefinition(6, Type = FieldType.Number, Label = "IndexerSettingsMinimumSeeders", HelpText = "IndexerSettingsMinimumSeedersHelpText", Advanced = true)]
public int MinimumSeeders { get; set; }
[FieldDefinition(4)]
public SeedCriteriaSettings SeedCriteria { get; set; } = new SeedCriteriaSettings();
[FieldDefinition(7)]
public SeedCriteriaSettings SeedCriteria { get; set; } = new ();
public NzbDroneValidationResult Validate()
{
@ -48,31 +63,49 @@ namespace NzbDrone.Core.Indexers.HDBits
public enum HdBitsCategory
{
[FieldOption(label: "Movie")]
Movie = 1,
[FieldOption(label: "TV")]
Tv = 2,
[FieldOption(label: "Documentary")]
Documentary = 3,
[FieldOption(label: "Music")]
Music = 4,
[FieldOption(label: "Sport")]
Sport = 5,
[FieldOption(label: "Audio Track")]
Audio = 6,
[FieldOption(label: "XXX")]
Xxx = 7,
[FieldOption(label: "Misc/Demo")]
MiscDemo = 8
}
public enum HdBitsCodec
{
[FieldOption(label: "H.264")]
H264 = 1,
[FieldOption(label: "MPEG-2")]
Mpeg2 = 2,
[FieldOption(label: "VC-1")]
Vc1 = 3,
[FieldOption(label: "XviD")]
Xvid = 4,
[FieldOption(label: "HEVC")]
Hevc = 5
}
public enum HdBitsMedium
{
[FieldOption(label: "Blu-ray/HD DVD")]
Bluray = 1,
[FieldOption(label: "Encode")]
Encode = 3,
[FieldOption(label: "Capture")]
Capture = 4,
[FieldOption(label: "Remux")]
Remux = 5,
[FieldOption(label: "WEB-DL")]
WebDl = 6
}
}

View File

@ -770,6 +770,12 @@
"Indexer": "Indexer",
"IndexerDownloadClientHealthCheckMessage": "Indexers with invalid download clients: {indexerNames}.",
"IndexerDownloadClientHelpText": "Specify which download client is used for grabs from this indexer",
"IndexerHDBitsSettingsCategories": "Categories",
"IndexerHDBitsSettingsCategoriesHelpText": "If unspecified, all options are used.",
"IndexerHDBitsSettingsCodecs": "Codecs",
"IndexerHDBitsSettingsCodecsHelpText": "If unspecified, all options are used.",
"IndexerHDBitsSettingsMediums": "Mediums",
"IndexerHDBitsSettingsMediumsHelpText": "If unspecified, all options are used.",
"IndexerIPTorrentsSettingsFeedUrl": "Feed URL",
"IndexerIPTorrentsSettingsFeedUrlHelpText": "The full RSS feed url generated by IPTorrents, using only the categories you selected (HD, SD, x264, etc ...)",
"IndexerJackettAllHealthCheckMessage": "Indexers using the unsupported Jackett 'all' endpoint: {indexerNames}",