mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
Fixed: Warn if user has movie/date sorting enabled in Sabnzbd for the Sonarr category.
This commit is contained in:
parent
c29e49da95
commit
949d8bf49b
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// On some properties sab serializes array of single item as plain string.
|
||||
/// </summary>
|
||||
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<string>() };
|
||||
}
|
||||
else if (reader.TokenType == JsonToken.StartArray)
|
||||
{
|
||||
return JArray.Load(reader).ToObject<string[]>();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonReaderException("Expected array");
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return objectType == typeof(string[]);
|
||||
}
|
||||
}
|
||||
}
|
@ -376,6 +376,34 @@ private ValidationFailure TestCategory()
|
||||
}
|
||||
}
|
||||
|
||||
if (config.Misc.enable_movie_sorting)
|
||||
{
|
||||
if (!config.Misc.movie_categories.Any<string>() ||
|
||||
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<string>() ||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class SabnzbdConfigMisc
|
||||
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; }
|
||||
}
|
||||
|
||||
|
@ -396,6 +396,7 @@
|
||||
<Compile Include="Download\Clients\qBittorrent\QBittorrentSettings.cs" />
|
||||
<Compile Include="Download\Clients\qBittorrent\QBittorrentTorrent.cs" />
|
||||
<Compile Include="Download\Clients\Sabnzbd\JsonConverters\SabnzbdPriorityTypeConverter.cs" />
|
||||
<Compile Include="Download\Clients\Sabnzbd\JsonConverters\SabnzbdStringArrayConverter.cs" />
|
||||
<Compile Include="Download\Clients\Sabnzbd\JsonConverters\SabnzbdQueueTimeConverter.cs" />
|
||||
<Compile Include="Download\Clients\Sabnzbd\Responses\SabnzbdRetryResponse.cs" />
|
||||
<Compile Include="Download\Clients\Sabnzbd\Responses\SabnzbdAddResponse.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user