|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using FluentValidation.Results;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
@ -58,12 +59,9 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private XbmcVersion GetJsonVersion(XbmcSettings settings)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _xbmcVersionCache.Get(settings.Address, () =>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var response = _proxy.GetJsonVersion(settings);
|
|
|
|
|
|
|
|
|
|
_logger.Debug("Getting version from response: " + response);
|
|
|
|
@ -71,20 +69,18 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|
|
|
|
|
|
|
|
|
var versionObject = result.Result.Property("version");
|
|
|
|
|
|
|
|
|
|
if (versionObject.Value.Type == JTokenType.Integer) return new XbmcVersion((int) versionObject.Value);
|
|
|
|
|
|
|
|
|
|
if (versionObject.Value.Type == JTokenType.Object) return Json.Deserialize<XbmcVersion>(versionObject.Value.ToString());
|
|
|
|
|
|
|
|
|
|
throw new InvalidCastException("Unknown Version structure!: " + versionObject);
|
|
|
|
|
}, TimeSpan.FromHours(12));
|
|
|
|
|
if (versionObject.Value.Type == JTokenType.Integer)
|
|
|
|
|
{
|
|
|
|
|
return new XbmcVersion((int)versionObject.Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
if (versionObject.Value.Type == JTokenType.Object)
|
|
|
|
|
{
|
|
|
|
|
_logger.DebugException(ex.Message, ex);
|
|
|
|
|
return Json.Deserialize<XbmcVersion>(versionObject.Value.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new XbmcVersion();
|
|
|
|
|
throw new InvalidCastException("Unknown Version structure!: " + versionObject);
|
|
|
|
|
}, TimeSpan.FromHours(12));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IApiProvider GetApiProvider(XbmcSettings settings)
|
|
|
|
|