diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/JsonConverters/SabnzbdStringArrayConverter.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/JsonConverters/SabnzbdStringArrayConverter.cs
new file mode 100644
index 000000000..84a5a1bc9
--- /dev/null
+++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/JsonConverters/SabnzbdStringArrayConverter.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+namespace NzbDrone.Core.Download.Clients.Sabnzbd.JsonConverters
+{
+ ///
+ /// On some properties sab serializes array of single item as plain string.
+ ///
+ public class SabnzbdStringArrayConverter : JsonConverter
+ {
+ public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ {
+ var stringArray = (string[])value;
+ writer.WriteStartArray();
+
+ for (int i = 0; i < stringArray.Length; i++)
+ {
+ writer.WriteValue(stringArray[i]);
+ }
+
+ writer.WriteEnd();
+ }
+
+ public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ {
+ if (reader.TokenType == JsonToken.String || reader.TokenType == JsonToken.Null)
+ {
+ return new string[] { JValue.Load(reader).ToObject() };
+ }
+ else if (reader.TokenType == JsonToken.StartArray)
+ {
+ return JArray.Load(reader).ToObject();
+ }
+ else
+ {
+ throw new JsonReaderException("Expected array");
+ }
+ }
+
+ public override bool CanConvert(Type objectType)
+ {
+ return objectType == typeof(string[]);
+ }
+ }
+}
diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs
index 06054da8c..8632de04e 100644
--- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs
+++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs
@@ -376,6 +376,34 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
}
}
+ if (config.Misc.enable_movie_sorting)
+ {
+ if (!config.Misc.movie_categories.Any() ||
+ config.Misc.movie_categories.Contains(Settings.TvCategory) ||
+ (Settings.TvCategory.IsNullOrWhiteSpace() && config.Misc.movie_categories.Contains("Default")))
+ {
+ return new NzbDroneValidationFailure("TvCategory", "Disable Movie Sorting")
+ {
+ InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/sorting/", Settings.Host, Settings.Port),
+ DetailedDescription = "You must disable Sabnzbd Movie Sorting for the category Sonarr uses to prevent import issues. Go to Sabnzbd to fix it."
+ };
+ }
+ }
+
+ if (config.Misc.enable_date_sorting)
+ {
+ if (!config.Misc.date_categories.Any() ||
+ config.Misc.date_categories.Contains(Settings.TvCategory) ||
+ (Settings.TvCategory.IsNullOrWhiteSpace() && config.Misc.date_categories.Contains("Default")))
+ {
+ return new NzbDroneValidationFailure("TvCategory", "Disable Date Sorting")
+ {
+ InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/sorting/", Settings.Host, Settings.Port),
+ DetailedDescription = "You must disable Sabnzbd Date Sorting for the category Sonarr uses to prevent import issues. Go to Sabnzbd to fix it."
+ };
+ }
+ }
+
return null;
}
}
diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdCategory.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdCategory.cs
index d8885c567..08df67a74 100644
--- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdCategory.cs
+++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdCategory.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
+using Newtonsoft.Json;
using NzbDrone.Common.Disk;
+using NzbDrone.Core.Download.Clients.Sabnzbd.JsonConverters;
namespace NzbDrone.Core.Download.Clients.Sabnzbd
{
@@ -18,6 +20,11 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
public string complete_dir { get; set; }
public string[] tv_categories { get; set; }
public bool enable_tv_sorting { get; set; }
+ public string[] movie_categories { get; set; }
+ public bool enable_movie_sorting { get; set; }
+ [JsonConverter(typeof(SabnzbdStringArrayConverter))]
+ public string[] date_categories { get; set; }
+ public bool enable_date_sorting { get; set; }
public bool pre_check { get; set; }
}
diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj
index 4a0eb35b5..d3640bc17 100644
--- a/src/NzbDrone.Core/NzbDrone.Core.csproj
+++ b/src/NzbDrone.Core/NzbDrone.Core.csproj
@@ -396,6 +396,7 @@
+