From b239e28898d6db16de4670688903225e154fd1ba Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 26 Sep 2011 17:17:41 -0700 Subject: [PATCH] Added additional logging to XBMC Provider, to trace failure to update library. --- NzbDrone.Core/Providers/Core/HttpProvider.cs | 2 ++ NzbDrone.Core/Providers/XbmcProvider.cs | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/NzbDrone.Core/Providers/Core/HttpProvider.cs b/NzbDrone.Core/Providers/Core/HttpProvider.cs index e5dc637aa..9e22e0ee7 100644 --- a/NzbDrone.Core/Providers/Core/HttpProvider.cs +++ b/NzbDrone.Core/Providers/Core/HttpProvider.cs @@ -70,6 +70,8 @@ public virtual string PostCommand(string address, string username, string passwo { address += "/jsonrpc"; + Logger.Trace("Posting command: {0}, to {1}", command, address); + byte[] byteArray = Encoding.ASCII.GetBytes(command); var request = WebRequest.Create(address); diff --git a/NzbDrone.Core/Providers/XbmcProvider.cs b/NzbDrone.Core/Providers/XbmcProvider.cs index b8eb5af3a..6f05b1b27 100644 --- a/NzbDrone.Core/Providers/XbmcProvider.cs +++ b/NzbDrone.Core/Providers/XbmcProvider.cs @@ -56,6 +56,18 @@ public virtual void Update(Series series) Logger.Trace("Determining version of XBMC Host: {0}", host); var version = GetJsonVersion(host, username, password); + Logger.Trace("Determining if there are any active players on XBMC host: {0}", host); + var activePlayers = GetActivePlayers(host, username, password); + + //If video is currently playing, then skip update + if (activePlayers["video"]) + { + Logger.Debug("Video is currently playing, skipping library update"); + continue; + } + + Logger.Trace("No video playing, proceeding with library update"); + //If Dharma if (version == 2) UpdateWithHttp(series, host, username, password); @@ -206,6 +218,7 @@ public virtual int GetJsonVersion(string host, string username, string password) if (CheckForJsonError(response)) return version; + Logger.Trace("Getting version from response"); var result = serializer.Deserialize(response); result.Result.TryGetValue("version", out version); } @@ -274,6 +287,8 @@ public virtual List GetTvShowsJson(string host, string username, string public virtual bool CheckForJsonError(string response) { + Logger.Trace("Looking for error in response: {0}", response); + if (response.StartsWith("{\"error\"")) { var serializer = new JavaScriptSerializer();