Fixed: SABnzbd queue checking will not fail when items in queue are being repaired.

SabQueue priority is parsed with a custom converter to prevent blowing up because SAB decides to use Repair as a queue priority type.
This commit is contained in:
Mark McDowall 2012-05-19 13:07:30 -07:00
commit c4b57c4a23
6 changed files with 270 additions and 1 deletions

View file

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using NzbDrone.Core.Model.Sabnzbd;
namespace NzbDrone.Core.Helpers
{
public class SabnzbdPriorityTypeConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var priorityType = (SabPriorityType)value;
writer.WriteValue(priorityType.ToString());
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var queuePriority = reader.Value.ToString();
SabPriorityType output;
Enum.TryParse(queuePriority, out output);
return output;
}
public override bool CanConvert(Type objectType)
{
return objectType == typeof(SabPriorityType);
}
}
}