1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-10 11:10:40 +02:00

XbmcProvider will use the HTTP API when updating the library for Eden clients (EventServer was failing).

This commit is contained in:
Mark McDowall 2012-01-09 23:10:53 -08:00
parent 8415d4a440
commit b52585d62a
3 changed files with 21 additions and 9 deletions

View File

@ -1,7 +1,6 @@
// ReSharper disable RedundantUsingDirective
using System;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Model.Xbmc;

View File

@ -510,8 +510,13 @@ public void UpdateWithJson_Single()
fakeHttp.Setup(s => s.PostCommand(host, username, password, It.Is<string>(e => e.Replace(" ", "").Replace("\r\n", "").Replace("\t", "") == expectedJson.Replace(" ", ""))))
.Returns(tvshows);
var fakeEventClient = Mocker.GetMock<EventClientProvider>();
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("<html><li>OK</html>");
//var fakeEventClient = Mocker.GetMock<EventClientProvider>();
//fakeEventClient.Setup(s => s.SendAction("localhost", ActionType.ExecBuiltin, "ExecBuiltIn(UpdateLibrary(video,smb://HOMESERVER/TV/30 Rock/))"));
//Act
var result = Mocker.Resolve<XbmcProvider>().UpdateWithJson(fakeSeries, host, username, password);
@ -541,8 +546,13 @@ public void UpdateWithJson_All()
fakeHttp.Setup(s => s.PostCommand(host, username, password, It.Is<string>(e => e.Replace(" ", "").Replace("\r\n", "").Replace("\t", "") == expectedJson.Replace(" ", ""))))
.Returns(tvshows);
var fakeEventClient = Mocker.GetMock<EventClientProvider>();
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("<html><li>OK</html>");
//var fakeEventClient = Mocker.GetMock<EventClientProvider>();
//fakeEventClient.Setup(s => s.SendAction("localhost", ActionType.ExecBuiltin, "ExecBuiltIn(UpdateLibrary(video))"));
//Act
var result = Mocker.Resolve<XbmcProvider>().UpdateWithJson(fakeSeries, host, username, password);

View File

@ -120,20 +120,23 @@ public virtual bool UpdateWithJson(Series series, string host, string username,
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);
}
}