Cleanup SearchCriteria, Pass Cats from Search to Indexers

This commit is contained in:
Qstick
2020-11-18 15:35:14 -05:00
parent 529102ebcf
commit 6100adc515
25 changed files with 89 additions and 176 deletions
@@ -69,15 +69,10 @@ namespace NzbDrone.Core.Indexers.Torznab
};
}
private TorznabSettings GetSettings(string url, string apiPath = null, int[] categories = null)
private TorznabSettings GetSettings(string url, string apiPath = null)
{
var settings = new TorznabSettings { BaseUrl = url };
if (categories != null)
{
settings.Categories = categories;
}
if (apiPath.IsNotNullOrWhiteSpace())
{
settings.ApiPath = apiPath;
@@ -110,17 +105,6 @@ namespace NzbDrone.Core.Indexers.Torznab
{
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
var notSupported = Settings.Categories.Except(CategoryIds(capabilities.Categories));
if (notSupported.Any())
{
_logger.Warn($"{Definition.Name} does not support the following categories: {string.Join(", ", notSupported)}. You should probably remove them.");
if (notSupported.Count() == Settings.Categories.Count())
{
return new ValidationFailure(string.Empty, $"This indexer does not support any of the selected categories! (You may need to turn on advanced settings to see them)");
}
}
if (capabilities.SearchParams != null && capabilities.SearchParams.Contains(SearchParam.Q))
{
return null;
@@ -28,14 +28,6 @@ namespace NzbDrone.Core.Indexers.Torznab
public TorznabSettingsValidator()
{
RuleFor(c => c).Custom((c, context) =>
{
if (c.Categories.Empty())
{
context.AddFailure("'Categories' must be provided");
}
});
RuleFor(c => c.BaseUrl).ValidRootUrl();
RuleFor(c => c.ApiPath).ValidUrlBase("/api");
RuleFor(c => c.ApiKey).NotEmpty().When(ShouldHaveApiKey);