mirror of https://github.com/Sonarr/Sonarr
Fixed: Logging invalid version when failing to connect to Kodi
Closes #927
This commit is contained in:
parent
b02b9f026f
commit
ea6ae85f7a
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using FluentValidation.Results;
|
using FluentValidation.Results;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
@ -59,32 +60,27 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
||||||
|
|
||||||
private XbmcVersion GetJsonVersion(XbmcSettings settings)
|
private XbmcVersion GetJsonVersion(XbmcSettings settings)
|
||||||
{
|
{
|
||||||
try
|
return _xbmcVersionCache.Get(settings.Address, () =>
|
||||||
{
|
{
|
||||||
return _xbmcVersionCache.Get(settings.Address, () =>
|
var response = _proxy.GetJsonVersion(settings);
|
||||||
|
|
||||||
|
_logger.Debug("Getting version from response: " + response);
|
||||||
|
var result = Json.Deserialize<XbmcJsonResult<JObject>>(response);
|
||||||
|
|
||||||
|
var versionObject = result.Result.Property("version");
|
||||||
|
|
||||||
|
if (versionObject.Value.Type == JTokenType.Integer)
|
||||||
{
|
{
|
||||||
|
return new XbmcVersion((int)versionObject.Value);
|
||||||
|
}
|
||||||
|
|
||||||
var response = _proxy.GetJsonVersion(settings);
|
if (versionObject.Value.Type == JTokenType.Object)
|
||||||
|
{
|
||||||
|
return Json.Deserialize<XbmcVersion>(versionObject.Value.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
_logger.Debug("Getting version from response: " + response);
|
throw new InvalidCastException("Unknown Version structure!: " + versionObject);
|
||||||
var result = Json.Deserialize<XbmcJsonResult<JObject>>(response);
|
}, TimeSpan.FromHours(12));
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.DebugException(ex.Message, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new XbmcVersion();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IApiProvider GetApiProvider(XbmcSettings settings)
|
private IApiProvider GetApiProvider(XbmcSettings settings)
|
||||||
|
|
Loading…
Reference in New Issue