pull/158/head
tidusjar 9 years ago
parent 08cbf927ee
commit 3efd54c1b6

@ -87,6 +87,12 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PlexRequests.Helpers\PlexRequests.Helpers.csproj">
<Project>{1252336D-42A3-482A-804C-836E60173DFA}</Project>
<Name>PlexRequests.Helpers</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

@ -1,6 +1,6 @@
namespace PlexRequests.Api.Models.SickRage
{
public class SickRageBase<T>
public abstract class SickRageBase<T>
{
public T data { get; set; }
public string message { get; set; }

@ -1,6 +1,33 @@
namespace PlexRequests.Api.Models.SickRage
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using PlexRequests.Helpers;
namespace PlexRequests.Api.Models.SickRage
{
public class SickRageSeasonList : SickRageBase<int[]>
public class SickRageSeasonList : SickRageBase<object>
{
[JsonIgnore]
public int[] Data => ParseObjectToArray<int>(data);
protected T[] ParseObjectToArray<T>(object ambiguousObject)
{
var json = ambiguousObject.ToString();
if (string.IsNullOrWhiteSpace(json))
{
return new T[0]; // Could return null here instead.
}
if (json.TrimStart().StartsWith("["))
{
return JsonConvert.DeserializeObject<T[]>(json);
}
if (json.TrimStart().Equals("{}"))
{
return new T[0];
}
return new T[1] { JsonConvert.DeserializeObject<T>(json) };
}
}
}

@ -25,6 +25,7 @@
// ************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
@ -33,13 +34,19 @@ using Newtonsoft.Json;
using NLog;
using PlexRequests.Api.Interfaces;
using PlexRequests.Helpers;
using RestSharp;
namespace PlexRequests.Api
{
public class ApiRequest : IApiRequest
{
private JsonSerializerSettings Settings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
MissingMemberHandling = MissingMemberHandling.Ignore
};
private static Logger Log = LogManager.GetCurrentClassLogger();
/// <summary>
/// An API request handler
@ -108,7 +115,7 @@ namespace PlexRequests.Api
}
var json = JsonConvert.DeserializeObject<T>(response.Content);
var json = JsonConvert.DeserializeObject<T>(response.Content, Settings);
return json;
}
@ -129,4 +136,6 @@ namespace PlexRequests.Api
}
}
}
}

@ -84,7 +84,7 @@ namespace PlexRequests.Api
while (seasonIncrement < seasonCount)
{
seasonList = VerifyShowHasLoaded(tvdbId, apiKey, baseUrl);
seasonIncrement = seasonList.data?.Length ?? 0;
seasonIncrement = seasonList.Data?.Length ?? 0;
if (sw.ElapsedMilliseconds > 30000) // Break out after 30 seconds, it's not going to get added
{

@ -14,14 +14,14 @@
<!-- Scripts -->
<script src="/Content/jquery-2.2.1.min.js"></script>
<script src="/Content/handlebars.min.js"></script>
<script src="/Content/bootstrap.min.js"></script>
<script src="/Content/bootstrap-notify.min.js"></script>
<script src="/Content/site.js"></script>
<script src="/Content/pace.min.js"></script>
<script src="/Content/jquery.mixitup.js"></script>
<script src="/Content/moment.min.js"></script>
<script src="~/Content/jquery-2.2.1.min.js"></script>
<script src="~/Content/handlebars.min.js"></script>
<script src="~/Content/bootstrap.min.js"></script>
<script src="~/Content/bootstrap-notify.min.js"></script>
<script src="~/Content/site.js"></script>
<script src="~/Content/pace.min.js"></script>
<script src="~/Content/jquery.mixitup.js"></script>
<script src="~/Content/moment.min.js"></script>
</head>
<body>

Loading…
Cancel
Save