mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-18 21:34:28 -04:00
added custom IntConverter to get around the mono bug
http://json.codeplex.com/workitem/24176
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
@@ -36,11 +36,11 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||
};
|
||||
|
||||
_logger.Info("Adding report [{0}] to the queue.", title);
|
||||
var response = PostCommand(JsonConvert.SerializeObject(command));
|
||||
var response = PostCommand(command.ToJson());
|
||||
|
||||
CheckForError(response);
|
||||
|
||||
var success = JsonConvert.DeserializeObject<EnqueueResponse>(response).Result;
|
||||
var success = Json.Deserialize<EnqueueResponse>(response).Result;
|
||||
_logger.Debug("Queue Response: [{0}]", success);
|
||||
|
||||
}
|
||||
@@ -61,11 +61,11 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||
Params = null
|
||||
};
|
||||
|
||||
var response = PostCommand(JsonConvert.SerializeObject(command));
|
||||
var response = PostCommand(command.ToJson());
|
||||
|
||||
CheckForError(response);
|
||||
|
||||
var itmes = JsonConvert.DeserializeObject<NzbGetQueue>(response).QueueItems;
|
||||
var itmes = Json.Deserialize<NzbGetQueue>(response).QueueItems;
|
||||
|
||||
foreach (var nzbGetQueueItem in itmes)
|
||||
{
|
||||
@@ -101,11 +101,11 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||
};
|
||||
|
||||
var address = String.Format(@"{0}:{1}", host, port);
|
||||
var response = _httpProvider.PostCommand(address, username, password, JsonConvert.SerializeObject(command));
|
||||
var response = _httpProvider.PostCommand(address, username, password, command.ToJson());
|
||||
|
||||
CheckForError(response);
|
||||
|
||||
return JsonConvert.DeserializeObject<VersionModel>(response);
|
||||
return Json.Deserialize<VersionModel>(response);
|
||||
}
|
||||
|
||||
public virtual string Test(string host, int port, string username, string password)
|
||||
@@ -134,7 +134,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||
|
||||
private void CheckForError(string response)
|
||||
{
|
||||
var result = JsonConvert.DeserializeObject<JsonError>(response);
|
||||
var result = Json.Deserialize<JsonError>(response);
|
||||
|
||||
if (result.Error != null)
|
||||
throw new ApplicationException(result.Error.ToString());
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Cache;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using RestSharp;
|
||||
@@ -107,7 +107,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||
|
||||
CheckForError(response);
|
||||
|
||||
var sabQueue = JsonConvert.DeserializeObject<SabQueue>(JObject.Parse(response).SelectToken("queue").ToString()).Items;
|
||||
var sabQueue = Json.Deserialize<SabQueue>(JObject.Parse(response).SelectToken("queue").ToString()).Items;
|
||||
|
||||
var queueItems = new List<QueueItem>();
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||
|
||||
CheckForError(response);
|
||||
|
||||
var items = JsonConvert.DeserializeObject<SabHistory>(JObject.Parse(response).SelectToken("history").ToString()).Items;
|
||||
var items = Json.Deserialize<SabHistory>(JObject.Parse(response).SelectToken("history").ToString()).Items;
|
||||
return items ?? new List<SabHistoryItem>();
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||
if (String.IsNullOrWhiteSpace(response))
|
||||
return new SabCategoryModel { categories = new List<string>() };
|
||||
|
||||
var categories = JsonConvert.DeserializeObject<SabCategoryModel>(response);
|
||||
var categories = Json.Deserialize<SabCategoryModel>(response);
|
||||
|
||||
return categories;
|
||||
}
|
||||
@@ -199,7 +199,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||
if (String.IsNullOrWhiteSpace(response))
|
||||
return null;
|
||||
|
||||
var version = JsonConvert.DeserializeObject<SabVersionModel>(response);
|
||||
var version = Json.Deserialize<SabVersionModel>(response);
|
||||
|
||||
return version;
|
||||
}
|
||||
@@ -232,7 +232,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||
|
||||
private void CheckForError(string response)
|
||||
{
|
||||
var result = JsonConvert.DeserializeObject<SabJsonError>(response);
|
||||
var result = Json.Deserialize<SabJsonError>(response);
|
||||
|
||||
if (result.Status != null && result.Status.Equals("false", StringComparison.InvariantCultureIgnoreCase))
|
||||
throw new ApplicationException(result.Error);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common.Serializer;
|
||||
|
||||
namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
@@ -25,7 +25,7 @@ namespace NzbDrone.Core.Indexers
|
||||
return new TSetting();
|
||||
}
|
||||
|
||||
return JsonConvert.DeserializeObject<TSetting>(indexerDef.Settings);
|
||||
return Json.Deserialize<TSetting>(indexerDef.Settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common.Serializer;
|
||||
|
||||
namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
@@ -25,7 +25,7 @@ namespace NzbDrone.Core.Notifications
|
||||
return new TSetting();
|
||||
}
|
||||
|
||||
return JsonConvert.DeserializeObject<TSetting>(indexerDef.Settings);
|
||||
return Json.Deserialize<TSetting>(indexerDef.Settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Model.Xbmc;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
||||
if (CheckForError(response))
|
||||
return new List<ActivePlayer>();
|
||||
|
||||
var result = JsonConvert.DeserializeObject<ActivePlayersEdenResult>(response);
|
||||
var result = Json.Deserialize<ActivePlayersEdenResult>(response);
|
||||
|
||||
return result.Result;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
||||
|
||||
if (response.StartsWith("{\"error\""))
|
||||
{
|
||||
var error = JsonConvert.DeserializeObject<ErrorResult>(response);
|
||||
var error = Json.Deserialize<ErrorResult>(response);
|
||||
var code = error.Error["code"];
|
||||
var message = error.Error["message"];
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
||||
if (CheckForError(response)) return;
|
||||
|
||||
_logger.Trace(" from response");
|
||||
var result = JsonConvert.DeserializeObject<XbmcJsonResult<String>>(response);
|
||||
var result = Json.Deserialize<XbmcJsonResult<String>>(response);
|
||||
|
||||
if (!result.Result.Equals("OK", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
@@ -185,7 +185,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
||||
if (CheckForError(response))
|
||||
return new List<TvShow>();
|
||||
|
||||
var result = JsonConvert.DeserializeObject<TvShowResponse>(response);
|
||||
var result = Json.Deserialize<TvShowResponse>(response);
|
||||
var shows = result.Result.TvShows;
|
||||
|
||||
return shows;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Core.Messaging;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model.Xbmc;
|
||||
@@ -63,7 +62,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
||||
var response = _httpProvider.PostCommand(settings.Address, settings.Username, settings.Password, postJson.ToString());
|
||||
|
||||
Logger.Trace("Getting version from response");
|
||||
var result = JsonConvert.DeserializeObject<XbmcJsonResult<JObject>>(response);
|
||||
var result = Json.Deserialize<XbmcJsonResult<JObject>>(response);
|
||||
|
||||
var versionObject = result.Result.Property("version");
|
||||
|
||||
@@ -71,7 +70,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
||||
return new XbmcVersion((int)versionObject.Value);
|
||||
|
||||
if (versionObject.Value.Type == JTokenType.Object)
|
||||
return JsonConvert.DeserializeObject<XbmcVersion>(versionObject.Value.ToString());
|
||||
return Json.Deserialize<XbmcVersion>(versionObject.Value.ToString());
|
||||
|
||||
throw new InvalidCastException("Unknown Version structure!: " + versionObject);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user