From 96345c0a0bbc5005bf8346d095909931da5f4384 Mon Sep 17 00:00:00 2001 From: Stevie Robinson Date: Thu, 22 Sep 2022 18:48:03 +0200 Subject: [PATCH] Fixed: Remove non-functional filters for Trakt Lists Co-authored-by: Qstick --- .../Trakt/Popular/TraktPopularSettings.cs | 23 +++++++++++++++++ .../ImportLists/Trakt/TraktSettingsBase.cs | 25 ------------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/NzbDrone.Core/ImportLists/Trakt/Popular/TraktPopularSettings.cs b/src/NzbDrone.Core/ImportLists/Trakt/Popular/TraktPopularSettings.cs index 4d2f03cdc..24dcc097d 100644 --- a/src/NzbDrone.Core/ImportLists/Trakt/Popular/TraktPopularSettings.cs +++ b/src/NzbDrone.Core/ImportLists/Trakt/Popular/TraktPopularSettings.cs @@ -1,4 +1,6 @@ +using System.Text.RegularExpressions; using FluentValidation; +using NzbDrone.Common.Extensions; using NzbDrone.Core.Annotations; namespace NzbDrone.Core.ImportLists.Trakt.Popular @@ -9,6 +11,18 @@ namespace NzbDrone.Core.ImportLists.Trakt.Popular : base() { RuleFor(c => c.TraktListType).NotNull(); + + // Loose validation @TODO + RuleFor(c => c.Rating) + .Matches(@"^\d+\-\d+$", RegexOptions.IgnoreCase) + .When(c => c.Rating.IsNotNullOrWhiteSpace()) + .WithMessage("Not a valid rating"); + + // Loose validation @TODO + RuleFor(c => c.Years) + .Matches(@"^\d+(\-\d+)?$", RegexOptions.IgnoreCase) + .When(c => c.Years.IsNotNullOrWhiteSpace()) + .WithMessage("Not a valid year or range of years"); } } @@ -23,5 +37,14 @@ namespace NzbDrone.Core.ImportLists.Trakt.Popular [FieldDefinition(1, Label = "List Type", Type = FieldType.Select, SelectOptions = typeof(TraktPopularListType), HelpText = "Type of list you're seeking to import from")] public int TraktListType { get; set; } + + [FieldDefinition(2, Label = "Rating", HelpText = "Filter series by rating range (0-100)")] + public string Rating { get; set; } + + [FieldDefinition(4, Label = "Genres", HelpText = "Filter series by Trakt Genre Slug (Comma Separated) Only for Popular Lists")] + public string Genres { get; set; } + + [FieldDefinition(5, Label = "Years", HelpText = "Filter series by year or year range")] + public string Years { get; set; } } } diff --git a/src/NzbDrone.Core/ImportLists/Trakt/TraktSettingsBase.cs b/src/NzbDrone.Core/ImportLists/Trakt/TraktSettingsBase.cs index 8aa846746..6b7ed65c7 100644 --- a/src/NzbDrone.Core/ImportLists/Trakt/TraktSettingsBase.cs +++ b/src/NzbDrone.Core/ImportLists/Trakt/TraktSettingsBase.cs @@ -1,5 +1,4 @@ using System; -using System.Text.RegularExpressions; using FluentValidation; using NzbDrone.Common.Extensions; using NzbDrone.Core.Annotations; @@ -28,18 +27,6 @@ namespace NzbDrone.Core.ImportLists.Trakt .WithMessage("Must authenticate with Trakt") .When(c => c.AccessToken.IsNotNullOrWhiteSpace() && c.RefreshToken.IsNotNullOrWhiteSpace()); - // Loose validation @TODO - RuleFor(c => c.Rating) - .Matches(@"^\d+\-\d+$", RegexOptions.IgnoreCase) - .When(c => c.Rating.IsNotNullOrWhiteSpace()) - .WithMessage("Not a valid rating"); - - // Loose validation @TODO - RuleFor(c => c.Years) - .Matches(@"^\d+(\-\d+)?$", RegexOptions.IgnoreCase) - .When(c => c.Years.IsNotNullOrWhiteSpace()) - .WithMessage("Not a valid year or range of years"); - // Limit not smaller than 1 and not larger than 100 RuleFor(c => c.Limit) .GreaterThan(0) @@ -56,9 +43,6 @@ namespace NzbDrone.Core.ImportLists.Trakt { BaseUrl = "https://api.trakt.tv"; SignIn = "startOAuth"; - Rating = "0-100"; - Genres = ""; - Years = ""; Limit = 100; } @@ -76,15 +60,6 @@ namespace NzbDrone.Core.ImportLists.Trakt [FieldDefinition(0, Label = "Auth User", Type = FieldType.Textbox, Hidden = HiddenType.Hidden)] public string AuthUser { get; set; } - [FieldDefinition(1, Label = "Rating", HelpText = "Filter series by rating range (0-100)")] - public string Rating { get; set; } - - [FieldDefinition(3, Label = "Genres", HelpText = "Filter series by Trakt Genre Slug (Comma Separated)")] - public string Genres { get; set; } - - [FieldDefinition(4, Label = "Years", HelpText = "Filter series by year or year range")] - public string Years { get; set; } - [FieldDefinition(5, Label = "Limit", HelpText = "Limit the number of series to get")] public int Limit { get; set; }