From b52585d62af28410bab37269b073106ed4a48f41 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 9 Jan 2012 23:10:53 -0800 Subject: [PATCH] XbmcProvider will use the HTTP API when updating the library for Eden clients (EventServer was failing). --- .../ProviderTests/EventClientProviderTest.cs | 1 - .../ProviderTests/XbmcProviderTest.cs | 18 ++++++++++++++---- NzbDrone.Core/Providers/XbmcProvider.cs | 11 +++++++---- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/NzbDrone.Core.Test/ProviderTests/EventClientProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/EventClientProviderTest.cs index bdbcbaaf8..c61f54024 100644 --- a/NzbDrone.Core.Test/ProviderTests/EventClientProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/EventClientProviderTest.cs @@ -1,7 +1,6 @@ // ReSharper disable RedundantUsingDirective using System; - using Moq; using NUnit.Framework; using NzbDrone.Core.Model.Xbmc; diff --git a/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs index 7cc4769bb..2d50b3986 100644 --- a/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs @@ -510,8 +510,13 @@ namespace NzbDrone.Core.Test.ProviderTests fakeHttp.Setup(s => s.PostCommand(host, username, password, It.Is(e => e.Replace(" ", "").Replace("\r\n", "").Replace("\t", "") == expectedJson.Replace(" ", "")))) .Returns(tvshows); - var fakeEventClient = Mocker.GetMock(); - fakeEventClient.Setup(s => s.SendAction("localhost", ActionType.ExecBuiltin, "ExecBuiltIn(UpdateLibrary(video,smb://HOMESERVER/TV/30 Rock/))")); + var command = "ExecBuiltIn(UpdateLibrary(video,smb://HOMESERVER/TV/30 Rock/))"; + var url = String.Format("http://{0}/xbmcCmds/xbmcHttp?command={1}", host, command); + + fakeHttp.Setup(s => s.DownloadString(url, username, password)).Returns("
  • OK"); + + //var fakeEventClient = Mocker.GetMock(); + //fakeEventClient.Setup(s => s.SendAction("localhost", ActionType.ExecBuiltin, "ExecBuiltIn(UpdateLibrary(video,smb://HOMESERVER/TV/30 Rock/))")); //Act var result = Mocker.Resolve().UpdateWithJson(fakeSeries, host, username, password); @@ -541,8 +546,13 @@ namespace NzbDrone.Core.Test.ProviderTests fakeHttp.Setup(s => s.PostCommand(host, username, password, It.Is(e => e.Replace(" ", "").Replace("\r\n", "").Replace("\t", "") == expectedJson.Replace(" ", "")))) .Returns(tvshows); - var fakeEventClient = Mocker.GetMock(); - fakeEventClient.Setup(s => s.SendAction("localhost", ActionType.ExecBuiltin, "ExecBuiltIn(UpdateLibrary(video))")); + var command = "ExecBuiltIn(UpdateLibrary(video))"; + var url = String.Format("http://{0}/xbmcCmds/xbmcHttp?command={1}", host, command); + + fakeHttp.Setup(s => s.DownloadString(url, username, password)).Returns("
  • OK"); + + //var fakeEventClient = Mocker.GetMock(); + //fakeEventClient.Setup(s => s.SendAction("localhost", ActionType.ExecBuiltin, "ExecBuiltIn(UpdateLibrary(video))")); //Act var result = Mocker.Resolve().UpdateWithJson(fakeSeries, host, username, password); diff --git a/NzbDrone.Core/Providers/XbmcProvider.cs b/NzbDrone.Core/Providers/XbmcProvider.cs index dc71d01d4..30b9b3a87 100644 --- a/NzbDrone.Core/Providers/XbmcProvider.cs +++ b/NzbDrone.Core/Providers/XbmcProvider.cs @@ -120,20 +120,23 @@ namespace NzbDrone.Core.Providers else path = xbmcShows.FirstOrDefault(s => s.ImdbNumber == series.SeriesId || s.Label == series.Title); - var hostOnly = GetHostWithoutPort(host); + //var hostOnly = GetHostWithoutPort(host); if (path != null) { Logger.Trace("Updating series [{0}] (Path: {1}) on XBMC host: {2}", series.Title, path.File, host); - var command = String.Format("ExecBuiltIn(UpdateLibrary(video, {0}))", path.File); - _eventClientProvider.SendAction(hostOnly, ActionType.ExecBuiltin, command); + //var command = String.Format("ExecBuiltIn(UpdateLibrary(video, {0}))", path.File); + //_eventClientProvider.SendAction(hostOnly, ActionType.ExecBuiltin, command); + var command = String.Format("ExecBuiltIn(UpdateLibrary(video,{0}))", path.File); + SendCommand(host, command, username, password); } else { Logger.Trace("Series [{0}] doesn't exist on XBMC host: {1}, Updating Entire Library", series.Title, host); var command = String.Format("ExecBuiltIn(UpdateLibrary(video))"); - _eventClientProvider.SendAction(hostOnly, ActionType.ExecBuiltin, command); + //_eventClientProvider.SendAction(hostOnly, ActionType.ExecBuiltin, command); + SendCommand(host, "ExecBuiltIn(UpdateLibrary(video))", username, password); } }