1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-21 23:42:23 +00:00

New: Support SABnzb's new format for sorters

(cherry picked from commit d484553b310af4257c841c37a503ef54650c1426)

Closes #9351
This commit is contained in:
Mark McDowall 2023-10-29 14:19:47 -07:00 committed by Bogdan
parent d72f78d979
commit 4c4073ce1c
3 changed files with 76 additions and 0 deletions

View file

@ -543,6 +543,52 @@ public void should_test_develop_version_successfully()
result.HasWarnings.Should().BeTrue();
}
[Test]
public void should_test_success_if_sorters_are_empty()
{
_config.Misc.enable_tv_sorting = false;
_config.Misc.tv_categories = null;
_config.Sorters = new List<SabnzbdSorter>();
var result = new NzbDroneValidationResult(Subject.Test());
result.IsValid.Should().BeTrue();
}
[Test]
public void should_test_failed_if_sorter_is_enabled_for_non_tv_category()
{
_config.Misc.enable_tv_sorting = false;
_config.Misc.tv_categories = null;
_config.Sorters = Builder<SabnzbdSorter>.CreateListOfSize(1)
.All()
.With(s => s.is_active = true)
.With(s => s.sort_cats = new List<string> { "movie-custom" })
.Build()
.ToList();
var result = new NzbDroneValidationResult(Subject.Test());
result.IsValid.Should().BeTrue();
}
[Test]
public void should_test_failed_if_sorter_is_enabled_for_tv_category()
{
_config.Misc.enable_tv_sorting = false;
_config.Misc.tv_categories = null;
_config.Sorters = Builder<SabnzbdSorter>.CreateListOfSize(1)
.All()
.With(s => s.is_active = true)
.With(s => s.sort_cats = new List<string> { "movie" })
.Build()
.ToList();
var result = new NzbDroneValidationResult(Subject.Test());
result.IsValid.Should().BeFalse();
}
[Test]
public void should_test_success_if_tv_sorting_disabled()
{

View file

@ -482,6 +482,16 @@ private ValidationFailure TestCategory()
}
}
// New in SABnzbd 4.1, but on older versions this will be empty and not apply
if (config.Sorters.Any(s => s.is_active && ContainsCategory(s.sort_cats, Settings.MovieCategory)))
{
return new NzbDroneValidationFailure("MovieCategory", "Disable TV Sorting")
{
InfoLink = _proxy.GetBaseUrl(Settings, "config/sorting/"),
DetailedDescription = "You must disable sorting for the category Radarr uses to prevent import issues. Go to Sabnzbd to fix it."
};
}
if (config.Misc.enable_tv_sorting && ContainsCategory(config.Misc.tv_categories, Settings.MovieCategory))
{
return new NzbDroneValidationFailure("MovieCategory", "Disable TV Sorting")

View file

@ -11,11 +11,13 @@ public SabnzbdConfig()
{
Categories = new List<SabnzbdCategory>();
Servers = new List<object>();
Sorters = new List<SabnzbdSorter>();
}
public SabnzbdConfigMisc Misc { get; set; }
public List<SabnzbdCategory> Categories { get; set; }
public List<object> Servers { get; set; }
public List<SabnzbdSorter> Sorters { get; set; }
}
public class SabnzbdConfigMisc
@ -42,4 +44,22 @@ public class SabnzbdCategory
public OsPath FullPath { get; set; }
}
public class SabnzbdSorter
{
public SabnzbdSorter()
{
sort_cats = new List<string>();
sort_type = new List<int>();
}
public string name { get; set; }
public int order { get; set; }
public string min_size { get; set; }
public string multipart_label { get; set; }
public string sort_string { get; set; }
public List<string> sort_cats { get; set; }
public List<int> sort_type { get; set; }
public bool is_active { get; set; }
}
}