From 07f816f9fdca64db91168e1293264657385f156b Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 18 Jul 2023 03:29:29 +0300 Subject: [PATCH] Fixed: (BeyondHD) Add search types option --- .../Indexers/Definitions/BeyondHD.cs | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/NzbDrone.Core/Indexers/Definitions/BeyondHD.cs b/src/NzbDrone.Core/Indexers/Definitions/BeyondHD.cs index 29d1004ba..412f75c4b 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BeyondHD.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BeyondHD.cs @@ -132,6 +132,20 @@ namespace NzbDrone.Core.Indexers.Definitions body.Add("categories", string.Join(",", cats)); } + if (_settings.SearchTypes.Any()) + { + var searchTypes = _settings.SearchTypes + .Cast() + .Select(x => x.GetAttribute()?.Label) + .Where(x => x != null) + .ToHashSet(); + + if (searchTypes.Any()) + { + body.Add("types", string.Join(",", searchTypes)); + } + } + if (searchCriteria.Limit is > 0 && searchCriteria.Offset is > 0) { var page = (int)(searchCriteria.Offset / searchCriteria.Limit) + 1; @@ -309,6 +323,7 @@ namespace NzbDrone.Core.Indexers.Definitions LimitedOnly = false; RefundOnly = false; RewindOnly = false; + SearchTypes = Array.Empty(); } [FieldDefinition(2, Label = "API Key", HelpText = "API Key from the Site (Found in My Security => API Key)", Privacy = PrivacyLevel.ApiKey)] @@ -329,12 +344,72 @@ namespace NzbDrone.Core.Indexers.Definitions [FieldDefinition(7, Label = "Rewind Only", Type = FieldType.Checkbox, HelpText = "Search rewind only")] public bool RewindOnly { get; set; } + [FieldDefinition(8, Label = "Search Types", Type = FieldType.TagSelect, SelectOptions = typeof(BeyondHDSearchType), Advanced = true, HelpText = "Select the types of releases that you are interested in. If none selected, all options are used.")] + public IEnumerable SearchTypes { get; set; } + public override NzbDroneValidationResult Validate() { return new NzbDroneValidationResult(Validator.Validate(this)); } } + public enum BeyondHDSearchType + { + [FieldOption(Label = "UHD 100")] + TypeUhd100, + + [FieldOption(Label = "UHD 66")] + TypeUhd66, + + [FieldOption(Label = "UHD 50")] + TypeUhd50, + + [FieldOption(Label = "UHD Remux")] + TypeUhdRemux, + + [FieldOption(Label = "BD 50")] + TypeBd50, + + [FieldOption(Label = "BD 25")] + TypeBd25, + + [FieldOption(Label = "BD Remux")] + TypeBdRemux, + + [FieldOption(Label = "2160p")] + Type2160P, + + [FieldOption(Label = "1080p")] + Type1080P, + + [FieldOption(Label = "1080i")] + Type1080I, + + [FieldOption(Label = "720p")] + Type720P, + + [FieldOption(Label = "576p")] + Type576P, + + [FieldOption(Label = "540p")] + Type540P, + + [FieldOption(Label = "DVD 9")] + TypeDvd9, + + [FieldOption(Label = "DVD 5")] + TypeDvd5, + + [FieldOption(Label = "DVD Remux")] + TypeDvdRemux, + + [FieldOption(Label = "480p")] + Type480P, + + [FieldOption(Label = "Other")] + TypeOther, + } + public class BeyondHDResponse { [JsonProperty(PropertyName = "status_code")]