From c7c423b13d534f57ce796ac5a071b985bf0a067c Mon Sep 17 00:00:00 2001 From: fhscholl Date: Fri, 10 Nov 2017 10:11:09 -0500 Subject: [PATCH] Added: Functionality to XBMC and Plex to update indivdual titles. Also: Notification Cleanup (#2240) --- .../SynologyIndexerFixture.cs | 26 +- .../Xbmc/Http/ActivePlayersFixture.cs | 70 ------ .../Xbmc/Http/CheckForErrorFixture.cs | 35 --- .../Xbmc/Http/GetSeriesPathFixture.cs | 94 ------- .../Xbmc/Http/UpdateFixture.cs | 75 ------ .../Xbmc/Json/GetMoviePathFixture.cs | 91 +++++++ .../Xbmc/Json/GetSeriesPathFixture.cs | 106 -------- .../Xbmc/Json/UpdateFixture.cs | 68 ----- .../Xbmc/Json/UpdateMovieFixture.cs | 68 +++++ .../Xbmc/OnDownloadFixture.cs | 8 +- .../NzbDrone.Core.Test.csproj | 8 +- .../Notifications/Boxcar/Boxcar.cs | 4 - .../CustomScript/CustomScript.cs | 4 - .../Notifications/DownloadMessage.cs | 3 - .../Notifications/Email/Email.cs | 4 - .../Notifications/GrabMessage.cs | 2 - .../Notifications/Growl/Growl.cs | 4 - .../Notifications/Growl/GrowlService.cs | 4 +- .../Notifications/INotification.cs | 1 - src/NzbDrone.Core/Notifications/Join/Join.cs | 4 - .../MediaBrowser/MediaBrowser.cs | 8 - .../MediaBrowser/MediaBrowserProxy.cs | 10 - .../MediaBrowser/MediaBrowserService.cs | 7 - .../Notifications/NotificationBase.cs | 1 - .../Notifications/NotificationService.cs | 132 +--------- .../NotifyMyAndroid/NotifyMyAndroid.cs | 4 - .../Notifications/Plex/PlexClient.cs | 4 - .../Notifications/Plex/PlexHomeTheater.cs | 5 - .../Notifications/Plex/PlexServer.cs | 5 - .../Notifications/Plex/PlexServerProxy.cs | 12 +- .../Notifications/Plex/PlexServerService.cs | 51 +--- .../Notifications/Prowl/Prowl.cs | 4 - .../Notifications/PushBullet/PushBullet.cs | 4 - .../Notifications/Pushalot/Pushalot.cs | 4 - .../Notifications/Pushover/Pushover.cs | 4 - .../Notifications/Slack/Slack.cs | 15 -- .../Notifications/Synology/SynologyIndexer.cs | 8 - .../Notifications/Telegram/Telegram.cs | 4 - .../Notifications/Twitter/Twitter.cs | 4 - .../Notifications/Webhook/Webhook.cs | 4 - .../Notifications/Webhook/WebhookProxy.cs | 9 + .../Notifications/Webhook/WebhookSettings.cs | 6 + .../Notifications/Xbmc/HttpApiProvider.cs | 236 ------------------ .../Notifications/Xbmc/IApiProvider.cs | 1 - .../Notifications/Xbmc/JsonApiProvider.cs | 63 +---- .../{TvShowResponse.cs => MovieResponse.cs} | 4 +- .../Model/{TvShowResult.cs => MovieResult.cs} | 8 +- .../Xbmc/Model/{TvShow.cs => XbmcMovie.cs} | 4 +- src/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs | 26 -- .../Notifications/Xbmc/XbmcJsonApiProxy.cs | 8 +- .../Notifications/Xbmc/XbmcService.cs | 7 - src/NzbDrone.Core/NzbDrone.Core.csproj | 7 +- src/NzbDrone.Core/packages.config | 2 +- 53 files changed, 243 insertions(+), 1107 deletions(-) delete mode 100644 src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/ActivePlayersFixture.cs delete mode 100644 src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/CheckForErrorFixture.cs delete mode 100644 src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/GetSeriesPathFixture.cs delete mode 100644 src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/UpdateFixture.cs create mode 100644 src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetMoviePathFixture.cs delete mode 100644 src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetSeriesPathFixture.cs delete mode 100644 src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateFixture.cs create mode 100644 src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateMovieFixture.cs delete mode 100644 src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs rename src/NzbDrone.Core/Notifications/Xbmc/Model/{TvShowResponse.cs => MovieResponse.cs} (65%) rename src/NzbDrone.Core/Notifications/Xbmc/Model/{TvShowResult.cs => MovieResult.cs} (56%) rename src/NzbDrone.Core/Notifications/Xbmc/Model/{TvShow.cs => XbmcMovie.cs} (74%) diff --git a/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs index 7014fb825..b80f35309 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs @@ -19,29 +19,29 @@ namespace NzbDrone.Core.Test.NotificationTests [SetUp] public void SetUp() { - _movie = new Movie() + _movie = new Movie { Path = @"C:\Test\".AsOsAgnostic() }; - _upgrade = new DownloadMessage() + _upgrade = new DownloadMessage { Movie = _movie, MovieFile = new MovieFile { - RelativePath = "file1.S01E01E02.mkv" + RelativePath = "moviefile1.mkv" }, OldMovieFiles = new List { new MovieFile { - RelativePath = "file1.S01E01.mkv" + RelativePath = "oldmoviefile1.mkv" }, new MovieFile { - RelativePath = "file1.S01E02.mkv" + RelativePath = "oldmoviefile2.mkv" } } }; @@ -63,37 +63,37 @@ namespace NzbDrone.Core.Test.NotificationTests Subject.OnMovieRename(_movie); Mocker.GetMock() - .Verify(v => v.UpdateFolder(_movie.Path), Times.Never()); + .Verify(v => v.UpdateFolder(_movie.Path), Times.Never()); } [Test] - public void should_remove_old_episodes_on_upgrade() + public void should_remove_old_movie_on_upgrade() { Subject.OnDownload(_upgrade); Mocker.GetMock() - .Verify(v => v.DeleteFile(@"C:\Test\file1.S01E01.mkv".AsOsAgnostic()), Times.Once()); + .Verify(v => v.DeleteFile(@"C:\Test\oldmoviefile1.mkv".AsOsAgnostic()), Times.Once()); Mocker.GetMock() - .Verify(v => v.DeleteFile(@"C:\Test\file1.S01E02.mkv".AsOsAgnostic()), Times.Once()); + .Verify(v => v.DeleteFile(@"C:\Test\oldmoviefile2.mkv".AsOsAgnostic()), Times.Once()); } [Test] - public void should_add_new_episode_on_upgrade() + public void should_add_new_movie_on_upgrade() { Subject.OnDownload(_upgrade); Mocker.GetMock() - .Verify(v => v.AddFile(@"C:\Test\file1.S01E01E02.mkv".AsOsAgnostic()), Times.Once()); + .Verify(v => v.AddFile(@"C:\Test\moviefile1.mkv".AsOsAgnostic()), Times.Once()); } [Test] - public void should_update_entire_series_folder_on_rename() + public void should_update_entire_movie_folder_on_rename() { Subject.OnMovieRename(_movie); Mocker.GetMock() - .Verify(v => v.UpdateFolder(@"C:\Test\".AsOsAgnostic()), Times.Once()); + .Verify(v => v.UpdateFolder(@"C:\Test\".AsOsAgnostic()), Times.Once()); } } } diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/ActivePlayersFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/ActivePlayersFixture.cs deleted file mode 100644 index bf5f4de2b..000000000 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/ActivePlayersFixture.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Http; -using NzbDrone.Core.Notifications.Xbmc; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http -{ - [TestFixture] - public class ActivePlayersFixture : CoreTest - { - private XbmcSettings _settings; - private string _expectedUrl; - - private void WithNoActivePlayers() - { - Mocker.GetMock() - .Setup(s => s.DownloadString(_expectedUrl, _settings.Username, _settings.Password)) - .Returns("
  • Filename:[Nothing Playing]"); - } - - private void WithVideoPlayerActive() - { - var activePlayers = @"
  • Filename:C:\Test\TV\2 Broke Girls\Season 01\2 Broke Girls - S01E01 - Pilot [SDTV].avi" + - "
  • PlayStatus:Playing
  • VideoNo:0
  • Type:Video
  • Thumb:special://masterprofile/Thumbnails/Video/a/auto-a664d5a2.tbn" + - "
  • Time:00:06
  • Duration:21:35
  • Percentage:0
  • File size:183182590
  • Changed:True"; - - Mocker.GetMock() - .Setup(s => s.DownloadString(_expectedUrl, _settings.Username, _settings.Password)) - .Returns(activePlayers); - } - - [SetUp] - public void Setup() - { - _settings = new XbmcSettings - { - Host = "localhost", - Port = 8080, - Username = "xbmc", - Password = "xbmc", - AlwaysUpdate = false, - CleanLibrary = false, - UpdateLibrary = true - }; - - _expectedUrl = string.Format("http://{0}/xbmcCmds/xbmcHttp?command={1}", _settings.Address, "getcurrentlyplaying"); - } - - [Test] - public void _should_be_empty_when_no_active_players() - { - WithNoActivePlayers(); - - Subject.GetActivePlayers(_settings).Should().BeEmpty(); - } - - [Test] - public void should_have_active_video_player() - { - WithVideoPlayerActive(); - - var result = Subject.GetActivePlayers(_settings); - - result.Should().HaveCount(1); - result.First().Type.Should().Be("video"); - } - } -} diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/CheckForErrorFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/CheckForErrorFixture.cs deleted file mode 100644 index ea32b1b90..000000000 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/CheckForErrorFixture.cs +++ /dev/null @@ -1,35 +0,0 @@ -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Notifications.Xbmc; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http -{ - [TestFixture] - public class CheckForErrorFixture : CoreTest - { - [Test] - public void should_be_true_when_the_response_contains_an_error() - { - const string response = "html>
  • Error:Unknown command"; - - Subject.CheckForError(response).Should().BeTrue(); - } - - [Test] - public void JsonError_true_empty_response() - { - var response = string.Empty; - - Subject.CheckForError(response).Should().BeTrue(); - } - - [Test] - public void JsonError_false() - { - const string response = "html>
  • Filename:[Nothing Playing]"; - - Subject.CheckForError(response).Should().BeFalse(); - } - } -} diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/GetSeriesPathFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/GetSeriesPathFixture.cs deleted file mode 100644 index 15ec93960..000000000 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/GetSeriesPathFixture.cs +++ /dev/null @@ -1,94 +0,0 @@ -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Http; -using NzbDrone.Core.Notifications.Xbmc; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http -{ - [TestFixture] - public class GetSeriesPathFixture : CoreTest - { - private XbmcSettings _settings; - private Series _series; - - [SetUp] - public void Setup() - { - _settings = new XbmcSettings - { - Host = "localhost", - Port = 8080, - Username = "xbmc", - Password = "xbmc", - AlwaysUpdate = false, - CleanLibrary = false, - UpdateLibrary = true - }; - - _series = new Series - { - TvdbId = 79488, - Title = "30 Rock" - }; - - const string setResponseUrl = "http://localhost:8080/xbmcCmds/xbmcHttp?command=SetResponseFormat(webheader;false;webfooter;false;header;;footer;;opentag;;closetag;;closefinaltag;false)"; - const string resetResponseUrl = "http://localhost:8080/xbmcCmds/xbmcHttp?command=SetResponseFormat()"; - - Mocker.GetMock() - .Setup(s => s.DownloadString(setResponseUrl, _settings.Username, _settings.Password)) - .Returns("OK"); - - Mocker.GetMock() - .Setup(s => s.DownloadString(resetResponseUrl, _settings.Username, _settings.Password)) - .Returns(@" -
  • OK - "); - } - - [Test] - public void should_get_series_path() - { - const string queryResult = @"smb://xbmc:xbmc@HOMESERVER/TV/30 Rock/"; - var query = string.Format("http://localhost:8080/xbmcCmds/xbmcHttp?command=QueryVideoDatabase(select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = 79488 and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath)"); - - Mocker.GetMock() - .Setup(s => s.DownloadString(query, _settings.Username, _settings.Password)) - .Returns(queryResult); - - Subject.GetSeriesPath(_settings, _series) - .Should().Be("smb://xbmc:xbmc@HOMESERVER/TV/30 Rock/"); - } - - [Test] - public void should_get_null_for_series_path() - { - const string queryResult = @""; - var query = string.Format("http://localhost:8080/xbmcCmds/xbmcHttp?command=QueryVideoDatabase(select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = 79488 and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath)"); - - Mocker.GetMock() - .Setup(s => s.DownloadString(query, _settings.Username, _settings.Password)) - .Returns(queryResult); - - - Subject.GetSeriesPath(_settings, _series) - .Should().BeNull(); - } - - [Test] - public void should_get_series_path_with_special_characters_in_it() - { - const string queryResult = @"smb://xbmc:xbmc@HOMESERVER/TV/Law & Order- Special Victims Unit/"; - var query = string.Format("http://localhost:8080/xbmcCmds/xbmcHttp?command=QueryVideoDatabase(select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = 79488 and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath)"); - - Mocker.GetMock() - .Setup(s => s.DownloadString(query, _settings.Username, _settings.Password)) - .Returns(queryResult); - - - Subject.GetSeriesPath(_settings, _series) - .Should().Be("smb://xbmc:xbmc@HOMESERVER/TV/Law & Order- Special Victims Unit/"); - } - } -} diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/UpdateFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/UpdateFixture.cs deleted file mode 100644 index aad928f95..000000000 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/UpdateFixture.cs +++ /dev/null @@ -1,75 +0,0 @@ -using FizzWare.NBuilder; -using NUnit.Framework; -using NzbDrone.Common.Http; -using NzbDrone.Core.Notifications.Xbmc; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http -{ - [TestFixture] - public class UpdateFixture : CoreTest - { - private XbmcSettings _settings; - private string _seriesQueryUrl = "http://localhost:8080/xbmcCmds/xbmcHttp?command=QueryVideoDatabase(select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = 79488 and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath)"; - private Series _fakeSeries; - - [SetUp] - public void Setup() - { - _settings = new XbmcSettings - { - Host = "localhost", - Port = 8080, - Username = "xbmc", - Password = "xbmc", - AlwaysUpdate = false, - CleanLibrary = false, - UpdateLibrary = true - }; - - _fakeSeries = Builder.CreateNew() - .With(s => s.TvdbId = 79488) - .With(s => s.Title = "30 Rock") - .Build(); - } - - private void WithSeriesPath() - { - Mocker.GetMock() - .Setup(s => s.DownloadString(_seriesQueryUrl, _settings.Username, _settings.Password)) - .Returns("smb://xbmc:xbmc@HOMESERVER/TV/30 Rock/"); - } - - private void WithoutSeriesPath() - { - Mocker.GetMock() - .Setup(s => s.DownloadString(_seriesQueryUrl, _settings.Username, _settings.Password)) - .Returns(""); - } - - [Test] - public void should_update_using_series_path() - { - WithSeriesPath(); - const string url = "http://localhost:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(video,smb://xbmc:xbmc@HOMESERVER/TV/30 Rock/))"; - - Mocker.GetMock().Setup(s => s.DownloadString(url, _settings.Username, _settings.Password)); - - Subject.Update(_settings, _fakeSeries); - Mocker.VerifyAllMocks(); - } - - [Test] - public void should_update_all_paths_when_series_path_not_found() - { - WithoutSeriesPath(); - const string url = "http://localhost:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(video))"; - - Mocker.GetMock().Setup(s => s.DownloadString(url, _settings.Username, _settings.Password)); - - Subject.Update(_settings, _fakeSeries); - Mocker.VerifyAllMocks(); - } - } -} diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetMoviePathFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetMoviePathFixture.cs new file mode 100644 index 000000000..f75a5dddf --- /dev/null +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetMoviePathFixture.cs @@ -0,0 +1,91 @@ +using System.Collections.Generic; +using System.Linq; +using FizzWare.NBuilder; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Notifications.Xbmc; +using NzbDrone.Core.Notifications.Xbmc.Model; +using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Tv; + +namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json +{ + [TestFixture] + public class GetMoviePathFixture : CoreTest + { + private const string IMDB_ID = "tt67890"; + private XbmcSettings _settings; + private Movie _movie; + private List _xbmcMovies; + + [SetUp] + public void Setup() + { + _settings = Builder.CreateNew() + .Build(); + + _xbmcMovies = Builder.CreateListOfSize(3) + .All() + .With(s => s.ImdbNumber = "tt00000") + .TheFirst(1) + .With(s => s.ImdbNumber = IMDB_ID) + .Build() + .ToList(); + + Mocker.GetMock() + .Setup(s => s.GetMovies(_settings)) + .Returns(_xbmcMovies); + } + + private void GivenMatchingImdbId() + { + _movie = new Movie + { + ImdbId = IMDB_ID, + Title = "Movie" + }; + } + + private void GivenMatchingTitle() + { + _movie = new Movie + { + ImdbId = "tt01000", + Title = _xbmcMovies.First().Label + }; + } + + private void GivenMatchingMovie() + { + _movie = new Movie + { + ImdbId = "tt01000", + Title = "Does not exist" + }; + } + + [Test] + public void should_return_null_when_movie_is_not_found() + { + GivenMatchingMovie(); + + Subject.GetMoviePath(_settings, _movie).Should().BeNull(); + } + + [Test] + public void should_return_path_when_tvdbId_matches() + { + GivenMatchingImdbId(); + + Subject.GetMoviePath(_settings, _movie).Should().Be(_xbmcMovies.First().File); + } + + [Test] + public void should_return_path_when_title_matches() + { + GivenMatchingTitle(); + + Subject.GetMoviePath(_settings, _movie).Should().Be(_xbmcMovies.First().File); + } + } +} diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetSeriesPathFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetSeriesPathFixture.cs deleted file mode 100644 index b4b29dff2..000000000 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetSeriesPathFixture.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Notifications.Xbmc; -using NzbDrone.Core.Notifications.Xbmc.Model; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json -{ - [TestFixture] - public class GetSeriesPathFixture : CoreTest - { - private const int TVDB_ID = 5; - private XbmcSettings _settings; - private Series _series; - private List _xbmcSeries; - - [SetUp] - public void Setup() - { - _settings = Builder.CreateNew() - .Build(); - - _xbmcSeries = Builder.CreateListOfSize(3) - .All() - .With(s => s.ImdbNumber = "0") - .TheFirst(1) - .With(s => s.ImdbNumber = TVDB_ID.ToString()) - .Build() - .ToList(); - - Mocker.GetMock() - .Setup(s => s.GetSeries(_settings)) - .Returns(_xbmcSeries); - } - - private void GivenMatchingTvdbId() - { - _series = new Series - { - TvdbId = TVDB_ID, - Title = "TV Show" - }; - } - - private void GivenMatchingTitle() - { - _series = new Series - { - TvdbId = 1000, - Title = _xbmcSeries.First().Label - }; - } - - private void GivenMatchingSeries() - { - _series = new Series - { - TvdbId = 1000, - Title = "Does not exist" - }; - } - - [Test] - public void should_return_null_when_series_is_not_found() - { - GivenMatchingSeries(); - - Subject.GetSeriesPath(_settings, _series).Should().BeNull(); - } - - [Test] - public void should_return_path_when_tvdbId_matches() - { - GivenMatchingTvdbId(); - - Subject.GetSeriesPath(_settings, _series).Should().Be(_xbmcSeries.First().File); - } - - [Test] - public void should_return_path_when_title_matches() - { - GivenMatchingTitle(); - - Subject.GetSeriesPath(_settings, _series).Should().Be(_xbmcSeries.First().File); - } - - [Test] - public void should_not_throw_when_imdb_number_is_not_a_number() - { - GivenMatchingTvdbId(); - - _xbmcSeries.ForEach(s => s.ImdbNumber = "tt12345"); - _xbmcSeries.Last().ImdbNumber = TVDB_ID.ToString(); - - Mocker.GetMock() - .Setup(s => s.GetSeries(_settings)) - .Returns(_xbmcSeries); - - Subject.GetSeriesPath(_settings, _series).Should().NotBeNull(); - } - } -} diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateFixture.cs deleted file mode 100644 index 408f2eeba..000000000 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateFixture.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using Moq; -using NUnit.Framework; -using NzbDrone.Core.Notifications.Xbmc; -using NzbDrone.Core.Notifications.Xbmc.Model; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json -{ - [TestFixture] - public class UpdateFixture : CoreTest - { - private const int TVDB_ID = 5; - private XbmcSettings _settings; - private List _xbmcSeries; - - [SetUp] - public void Setup() - { - _settings = Builder.CreateNew() - .Build(); - - _xbmcSeries = Builder.CreateListOfSize(3) - .TheFirst(1) - .With(s => s.ImdbNumber = TVDB_ID.ToString()) - .Build() - .ToList(); - - Mocker.GetMock() - .Setup(s => s.GetSeries(_settings)) - .Returns(_xbmcSeries); - - Mocker.GetMock() - .Setup(s => s.GetActivePlayers(_settings)) - .Returns(new List()); - } - - [Test] - public void should_update_using_series_path() - { - var series = Builder.CreateNew() - .With(s => s.TvdbId = TVDB_ID) - .Build(); - - Subject.Update(_settings, series); - - Mocker.GetMock() - .Verify(v => v.UpdateLibrary(_settings, It.IsAny()), Times.Once()); - } - - [Test] - public void should_update_all_paths_when_series_path_not_found() - { - var fakeSeries = Builder.CreateNew() - .With(s => s.TvdbId = 1000) - .With(s => s.Title = "Not 30 Rock") - .Build(); - - Subject.Update(_settings, fakeSeries); - - Mocker.GetMock() - .Verify(v => v.UpdateLibrary(_settings, null), Times.Once()); - } - } -} diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateMovieFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateMovieFixture.cs new file mode 100644 index 000000000..3989646bf --- /dev/null +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateMovieFixture.cs @@ -0,0 +1,68 @@ +using System.Collections.Generic; +using System.Linq; +using FizzWare.NBuilder; +using Moq; +using NUnit.Framework; +using NzbDrone.Core.Notifications.Xbmc; +using NzbDrone.Core.Notifications.Xbmc.Model; +using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Tv; + +namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json +{ + [TestFixture] + public class UpdateMovieFixture : CoreTest + { + private const string IMDB_ID = "tt67890"; + private XbmcSettings _settings; + private List _xbmcMovies; + + [SetUp] + public void Setup() + { + _settings = Builder.CreateNew() + .Build(); + + _xbmcMovies = Builder.CreateListOfSize(3) + .TheFirst(1) + .With(s => s.ImdbNumber = IMDB_ID) + .Build() + .ToList(); + + Mocker.GetMock() + .Setup(s => s.GetMovies(_settings)) + .Returns(_xbmcMovies); + + Mocker.GetMock() + .Setup(s => s.GetActivePlayers(_settings)) + .Returns(new List()); + } + + [Test] + public void should_update_using_movie_path() + { + var movie = Builder.CreateNew() + .With(s => s.ImdbId = IMDB_ID) + .Build(); + + Subject.UpdateMovie(_settings, movie); + + Mocker.GetMock() + .Verify(v => v.UpdateLibrary(_settings, It.IsAny()), Times.Once()); + } + + [Test] + public void should_update_all_paths_when_movie_path_not_found() + { + var fakeMovie = Builder.CreateNew() + .With(s => s.ImdbId = "tt01000") + .With(s => s.Title = "Not A Real Movie") + .Build(); + + Subject.UpdateMovie(_settings, fakeMovie); + + Mocker.GetMock() + .Verify(v => v.UpdateLibrary(_settings, null), Times.Once()); + } + } +} diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/OnDownloadFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/OnDownloadFixture.cs index e92d49336..f1676bace 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/OnDownloadFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/OnDownloadFixture.cs @@ -41,8 +41,8 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc private void GivenOldFiles() { _downloadMessage.OldMovieFiles = Builder.CreateListOfSize(1) - .Build() - .ToList(); + .Build() + .ToList(); Subject.Definition.Settings = new XbmcSettings { @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc } [Test] - public void should_not_clean_if_no_episode_was_replaced() + public void should_not_clean_if_no_movie_was_replaced() { Subject.OnDownload(_downloadMessage); @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc } [Test] - public void should_clean_if_episode_was_replaced() + public void should_clean_if_movie_was_replaced() { GivenOldFiles(); Subject.OnDownload(_downloadMessage); diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 5fd386f93..a56079e96 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -317,12 +317,6 @@ - - - - - - @@ -395,6 +389,8 @@ Always + + diff --git a/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs b/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs index aa83d5c90..222597904 100644 --- a/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs +++ b/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs @@ -34,10 +34,6 @@ namespace NzbDrone.Core.Notifications.Boxcar { } - public override void OnRename(Series series) - { - } - public override string Name => "Boxcar"; public override bool SupportsOnRename => false; diff --git a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs index a7eb5b9cb..3d39c56e1 100755 --- a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs +++ b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs @@ -96,10 +96,6 @@ namespace NzbDrone.Core.Notifications.CustomScript ExecuteScript(environmentVariables); } - public override void OnRename(Series series) - { - } - public override string Name => "Custom Script"; public override ValidationResult Test() diff --git a/src/NzbDrone.Core/Notifications/DownloadMessage.cs b/src/NzbDrone.Core/Notifications/DownloadMessage.cs index cc3f06168..75a163bad 100644 --- a/src/NzbDrone.Core/Notifications/DownloadMessage.cs +++ b/src/NzbDrone.Core/Notifications/DownloadMessage.cs @@ -7,10 +7,7 @@ namespace NzbDrone.Core.Notifications public class DownloadMessage { public string Message { get; set; } - public Series Series { get; set; } public Movie Movie { get; set; } - public EpisodeFile EpisodeFile { get; set; } - public List OldFiles { get; set; } public MovieFile MovieFile { get; set; } public List OldMovieFiles { get; set; } public string SourcePath { get; set; } diff --git a/src/NzbDrone.Core/Notifications/Email/Email.cs b/src/NzbDrone.Core/Notifications/Email/Email.cs index 06cb6b250..754f8ee1a 100644 --- a/src/NzbDrone.Core/Notifications/Email/Email.cs +++ b/src/NzbDrone.Core/Notifications/Email/Email.cs @@ -36,10 +36,6 @@ namespace NzbDrone.Core.Notifications.Email { } - public override void OnRename(Series series) - { - } - public override string Name => "Email"; public override bool SupportsOnRename => false; diff --git a/src/NzbDrone.Core/Notifications/GrabMessage.cs b/src/NzbDrone.Core/Notifications/GrabMessage.cs index d2a2ac25d..a412e26ab 100644 --- a/src/NzbDrone.Core/Notifications/GrabMessage.cs +++ b/src/NzbDrone.Core/Notifications/GrabMessage.cs @@ -7,10 +7,8 @@ namespace NzbDrone.Core.Notifications public class GrabMessage { public string Message { get; set; } - public Series Series { get; set; } public Movie Movie { get; set; } public RemoteMovie RemoteMovie { get; set; } - public RemoteEpisode Episode { get; set; } public QualityModel Quality { get; set; } public override string ToString() diff --git a/src/NzbDrone.Core/Notifications/Growl/Growl.cs b/src/NzbDrone.Core/Notifications/Growl/Growl.cs index 85d1cb012..6917b2777 100644 --- a/src/NzbDrone.Core/Notifications/Growl/Growl.cs +++ b/src/NzbDrone.Core/Notifications/Growl/Growl.cs @@ -34,10 +34,6 @@ namespace NzbDrone.Core.Notifications.Growl { } - public override void OnRename(Series series) - { - } - public override string Name => "Growl"; public override bool SupportsOnRename => false; diff --git a/src/NzbDrone.Core/Notifications/Growl/GrowlService.cs b/src/NzbDrone.Core/Notifications/Growl/GrowlService.cs index dbb5dec04..740f8b59f 100644 --- a/src/NzbDrone.Core/Notifications/Growl/GrowlService.cs +++ b/src/NzbDrone.Core/Notifications/Growl/GrowlService.cs @@ -133,8 +133,8 @@ namespace NzbDrone.Core.Notifications.Growl { var notificationTypes = new List(); notificationTypes.Add(new NotificationType("TEST", "Test")); - notificationTypes.Add(new NotificationType("GRAB", "Episode Grabbed")); - notificationTypes.Add(new NotificationType("DOWNLOAD", "Episode Complete")); + notificationTypes.Add(new NotificationType("GRAB", "Movie Grabbed")); + notificationTypes.Add(new NotificationType("DOWNLOAD", "Movie Complete")); return notificationTypes.ToArray(); } diff --git a/src/NzbDrone.Core/Notifications/INotification.cs b/src/NzbDrone.Core/Notifications/INotification.cs index ec3ef1464..05468ae3c 100644 --- a/src/NzbDrone.Core/Notifications/INotification.cs +++ b/src/NzbDrone.Core/Notifications/INotification.cs @@ -9,7 +9,6 @@ namespace NzbDrone.Core.Notifications void OnGrab(GrabMessage grabMessage); void OnDownload(DownloadMessage message); - void OnRename(Series series); void OnMovieRename(Movie movie); bool SupportsOnGrab { get; } bool SupportsOnDownload { get; } diff --git a/src/NzbDrone.Core/Notifications/Join/Join.cs b/src/NzbDrone.Core/Notifications/Join/Join.cs index ae392e5df..9ec70d66b 100644 --- a/src/NzbDrone.Core/Notifications/Join/Join.cs +++ b/src/NzbDrone.Core/Notifications/Join/Join.cs @@ -34,10 +34,6 @@ namespace NzbDrone.Core.Notifications.Join { } - public override void OnRename(Series series) - { - } - public override string Name => "Join"; public override bool SupportsOnRename => false; diff --git a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowser.cs b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowser.cs index f293a6ecd..5d8915c4f 100644 --- a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowser.cs +++ b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowser.cs @@ -49,14 +49,6 @@ namespace NzbDrone.Core.Notifications.MediaBrowser } } - public override void OnRename(Series series) - { - if (Settings.UpdateLibrary) - { - _mediaBrowserService.Update(Settings, series); - } - } - public override string Name => "Emby (Media Browser)"; public override ValidationResult Test() diff --git a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserProxy.cs b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserProxy.cs index 6ca0bca54..79e8e8c9c 100644 --- a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserProxy.cs +++ b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserProxy.cs @@ -31,16 +31,6 @@ namespace NzbDrone.Core.Notifications.MediaBrowser ProcessRequest(request, settings); } - public void Update(MediaBrowserSettings settings, int tvdbId) - { - var path = string.Format("/Library/Series/Updated?tvdbid={0}", tvdbId); - var request = BuildRequest(path, settings); - request.Headers.Add("Content-Length", "0"); - - ProcessRequest(request, settings); - } - - public void UpdateMovies(MediaBrowserSettings settings, string imdbid) { var path = string.Format("/Library/Movies/Updated?ImdbId={0}", imdbid); diff --git a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs index 950cceb8e..7d050e90d 100644 --- a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs +++ b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs @@ -10,7 +10,6 @@ namespace NzbDrone.Core.Notifications.MediaBrowser public interface IMediaBrowserService { void Notify(MediaBrowserSettings settings, string title, string message); - void Update(MediaBrowserSettings settings, Series series); void UpdateMovies(MediaBrowserSettings settings, Movie movie); ValidationFailure Test(MediaBrowserSettings settings); } @@ -31,12 +30,6 @@ namespace NzbDrone.Core.Notifications.MediaBrowser _proxy.Notify(settings, title, message); } - public void Update(MediaBrowserSettings settings, Series series) - { - _proxy.Update(settings, series.TvdbId); - } - - public void UpdateMovies(MediaBrowserSettings settings, Movie movie) { _proxy.UpdateMovies(settings, movie.ImdbId); diff --git a/src/NzbDrone.Core/Notifications/NotificationBase.cs b/src/NzbDrone.Core/Notifications/NotificationBase.cs index 70129c2ed..27dee4b37 100644 --- a/src/NzbDrone.Core/Notifications/NotificationBase.cs +++ b/src/NzbDrone.Core/Notifications/NotificationBase.cs @@ -26,7 +26,6 @@ namespace NzbDrone.Core.Notifications public abstract void OnGrab(GrabMessage grabMessage); public abstract void OnDownload(DownloadMessage message); - public abstract void OnRename(Series series); public abstract void OnMovieRename(Movie movie); public virtual bool SupportsOnGrab => true; diff --git a/src/NzbDrone.Core/Notifications/NotificationService.cs b/src/NzbDrone.Core/Notifications/NotificationService.cs index ae626242e..63149acc7 100644 --- a/src/NzbDrone.Core/Notifications/NotificationService.cs +++ b/src/NzbDrone.Core/Notifications/NotificationService.cs @@ -30,47 +30,6 @@ namespace NzbDrone.Core.Notifications _logger = logger; } - private string GetMessage(Series series, List episodes, QualityModel quality) - { - var qualityString = quality.Quality.ToString(); - - if (quality.Revision.Version > 1) - { - if (series.SeriesType == SeriesTypes.Anime) - { - qualityString += " v" + quality.Revision.Version; - } - - else - { - qualityString += " Proper"; - } - } - - if (series.SeriesType == SeriesTypes.Daily) - { - var episode = episodes.First(); - - return string.Format("{0} - {1} - {2} [{3}]", - series.Title, - episode.AirDate, - episode.Title, - qualityString); - } - - var episodeNumbers = string.Concat(episodes.Select(e => e.EpisodeNumber) - .Select(i => string.Format("x{0:00}", i))); - - var episodeTitles = string.Join(" + ", episodes.Select(e => e.Title)); - - return string.Format("{0} - {1}{2} - {3} [{4}]", - series.Title, - episodes.First().SeasonNumber, - episodeNumbers, - episodeTitles, - qualityString); - } - private string GetMessage(Movie movie, QualityModel quality) { var qualityString = quality.Quality.ToString(); @@ -100,7 +59,7 @@ namespace NzbDrone.Core.Notifications if (notificationDefinition.Tags.Intersect(movie.Tags).Any()) { - _logger.Debug("Notification and series have one or more matching tags."); + _logger.Debug("Notification and movie have one or more matching tags."); return true; } @@ -109,49 +68,9 @@ namespace NzbDrone.Core.Notifications return false; } - private bool ShouldHandleSeries(ProviderDefinition definition, Series series) - { - var notificationDefinition = (NotificationDefinition) definition; - - if (notificationDefinition.Tags.Empty()) - { - _logger.Debug("No tags set for this notification."); - return true; - } - - if (notificationDefinition.Tags.Intersect(series.Tags).Any()) - { - _logger.Debug("Notification and series have one or more matching tags."); - return true; - } - - //TODO: this message could be more clear - _logger.Debug("{0} does not have any tags that match {1}'s tags", notificationDefinition.Name, series.Title); - return false; - } - public void Handle(EpisodeGrabbedEvent message) { - var grabMessage = new GrabMessage { - Message = GetMessage(message.Episode.Series, message.Episode.Episodes, message.Episode.ParsedEpisodeInfo.Quality), - Series = message.Episode.Series, - Quality = message.Episode.ParsedEpisodeInfo.Quality, - Episode = message.Episode - }; - - foreach (var notification in _notificationFactory.OnGrabEnabled()) - { - try - { - if (!ShouldHandleSeries(notification.Definition, message.Episode.Series)) continue; - notification.OnGrab(grabMessage); - } - - catch (Exception ex) - { - _logger.Error(ex, "Unable to send OnGrab notification to: " + notification.Definition.Name); - } - } + throw new NotImplementedException("Remove Series/Season/Episode"); } public void Handle(MovieGrabbedEvent message) @@ -159,9 +78,7 @@ namespace NzbDrone.Core.Notifications var grabMessage = new GrabMessage { Message = GetMessage(message.Movie.Movie, message.Movie.ParsedMovieInfo.Quality), - Series = null, Quality = message.Movie.ParsedMovieInfo.Quality, - Episode = null, Movie = message.Movie.Movie, RemoteMovie = message.Movie }; @@ -183,42 +100,15 @@ namespace NzbDrone.Core.Notifications public void Handle(EpisodeDownloadedEvent message) { - var downloadMessage = new DownloadMessage(); - downloadMessage.Message = GetMessage(message.Episode.Series, message.Episode.Episodes, message.Episode.Quality); - downloadMessage.Series = message.Episode.Series; - downloadMessage.EpisodeFile = message.EpisodeFile; - downloadMessage.OldFiles = message.OldFiles; - downloadMessage.SourcePath = message.Episode.Path; - - foreach (var notification in _notificationFactory.OnDownloadEnabled()) - { - try - { - if (ShouldHandleSeries(notification.Definition, message.Episode.Series)) - { - if (downloadMessage.OldFiles.Empty() || ((NotificationDefinition)notification.Definition).OnUpgrade) - { - notification.OnDownload(downloadMessage); - } - } - } - - catch (Exception ex) - { - _logger.Warn(ex, "Unable to send OnDownload notification to: " + notification.Definition.Name); - } - } + throw new NotImplementedException("Remove Series/Season/Episode"); } public void Handle(MovieDownloadedEvent message) { var downloadMessage = new DownloadMessage(); downloadMessage.Message = GetMessage(message.Movie.Movie, message.Movie.Quality); - downloadMessage.Series = null; - downloadMessage.EpisodeFile = null; downloadMessage.MovieFile = message.MovieFile; downloadMessage.Movie = message.Movie.Movie; - downloadMessage.OldFiles = null; downloadMessage.OldMovieFiles = message.OldFiles; downloadMessage.SourcePath = message.Movie.Path; downloadMessage.DownloadId = message.DownloadId; @@ -245,21 +135,7 @@ namespace NzbDrone.Core.Notifications public void Handle(SeriesRenamedEvent message) { - foreach (var notification in _notificationFactory.OnRenameEnabled()) - { - try - { - if (ShouldHandleSeries(notification.Definition, message.Series)) - { - notification.OnRename(message.Series); - } - } - - catch (Exception ex) - { - _logger.Warn(ex, "Unable to send OnRename notification to: " + notification.Definition.Name); - } - } + throw new NotImplementedException("Remove Series/Season/Episode"); } public void Handle(MovieRenamedEvent message) diff --git a/src/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroid.cs b/src/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroid.cs index 502fa8f5f..ad328faf6 100644 --- a/src/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroid.cs +++ b/src/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroid.cs @@ -35,10 +35,6 @@ namespace NzbDrone.Core.Notifications.NotifyMyAndroid { } - public override void OnRename(Series series) - { - } - public override string Name => "Notify My Android"; public override bool SupportsOnRename => false; diff --git a/src/NzbDrone.Core/Notifications/Plex/PlexClient.cs b/src/NzbDrone.Core/Notifications/Plex/PlexClient.cs index a330468a4..10c3bb237 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexClient.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexClient.cs @@ -32,10 +32,6 @@ namespace NzbDrone.Core.Notifications.Plex { } - public override void OnRename(Series series) - { - } - public override string Name => "Plex Media Center"; public override bool SupportsOnRename => false; diff --git a/src/NzbDrone.Core/Notifications/Plex/PlexHomeTheater.cs b/src/NzbDrone.Core/Notifications/Plex/PlexHomeTheater.cs index 817d4f50c..32c180d87 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexHomeTheater.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexHomeTheater.cs @@ -39,11 +39,6 @@ namespace NzbDrone.Core.Notifications.Plex { } - public override void OnRename(Series series) - { - - } - public override string Name => "Plex Home Theater"; public override bool SupportsOnRename => false; diff --git a/src/NzbDrone.Core/Notifications/Plex/PlexServer.cs b/src/NzbDrone.Core/Notifications/Plex/PlexServer.cs index cf52620d7..fe7f26758 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexServer.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexServer.cs @@ -30,11 +30,6 @@ namespace NzbDrone.Core.Notifications.Plex UpdateIfEnabled(movie); } - public override void OnRename(Series series) - { - //UpdateIfEnabled(movie); - } - private void UpdateIfEnabled(Movie movie) { if (Settings.UpdateLibrary) diff --git a/src/NzbDrone.Core/Notifications/Plex/PlexServerProxy.cs b/src/NzbDrone.Core/Notifications/Plex/PlexServerProxy.cs index 0eb0002c3..885626f86 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexServerProxy.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexServerProxy.cs @@ -19,10 +19,10 @@ namespace NzbDrone.Core.Notifications.Plex List GetTvSections(PlexServerSettings settings); List GetMovieSections(PlexServerSettings settings); void Update(int sectionId, PlexServerSettings settings); - void UpdateSeries(int metadataId, PlexServerSettings settings); + void UpdateItem(int metadataId, PlexServerSettings settings); string Version(PlexServerSettings settings); List Preferences(PlexServerSettings settings); - int? GetMetadataId(int sectionId, int tvdbId, string language, PlexServerSettings settings); + int? GetMetadataId(int sectionId, string imdbId, string language, PlexServerSettings settings); } public class PlexServerProxy : IPlexServerProxy @@ -109,14 +109,14 @@ namespace NzbDrone.Core.Notifications.Plex CheckForError(response, settings); } - public void UpdateSeries(int metadataId, PlexServerSettings settings) + public void UpdateItem(int metadataId, PlexServerSettings settings) { var resource = string.Format("library/metadata/{0}/refresh", metadataId); var request = GetPlexServerRequest(resource, Method.PUT, settings); var client = GetPlexServerClient(settings); var response = client.Execute(request); - _logger.Trace("Update Series response: {0}", response.Content); + _logger.Trace("Update Item response: {0}", response.Content); CheckForError(response, settings); } @@ -160,9 +160,9 @@ namespace NzbDrone.Core.Notifications.Plex .Preferences; } - public int? GetMetadataId(int sectionId, int tvdbId, string language, PlexServerSettings settings) + public int? GetMetadataId(int sectionId, string imdbId, string language, PlexServerSettings settings) { - var guid = string.Format("com.plexapp.agents.thetvdb://{0}?lang={1}", tvdbId, language); + var guid = string.Format("com.plexapp.agents.imdb://{0}?lang={1}", imdbId, language); var resource = string.Format("library/sections/{0}/all?guid={1}", sectionId, System.Web.HttpUtility.UrlEncode(guid)); var request = GetPlexServerRequest(resource, Method.GET, settings); var client = GetPlexServerClient(settings); diff --git a/src/NzbDrone.Core/Notifications/Plex/PlexServerService.cs b/src/NzbDrone.Core/Notifications/Plex/PlexServerService.cs index c2d0e9e80..7b5b07c64 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexServerService.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexServerService.cs @@ -13,7 +13,6 @@ namespace NzbDrone.Core.Notifications.Plex { public interface IPlexServerService { - void UpdateLibrary(Series series, PlexServerSettings settings); void UpdateMovieSections(Movie movie, PlexServerSettings settings); ValidationFailure Test(PlexServerSettings settings); } @@ -33,7 +32,7 @@ namespace NzbDrone.Core.Notifications.Plex _logger = logger; } - public void UpdateLibrary(Series series, PlexServerSettings settings) + public void UpdateMovieSections(Movie movie, PlexServerSettings settings) { try { @@ -47,7 +46,7 @@ namespace NzbDrone.Core.Notifications.Plex if (partialUpdates) { - UpdatePartialSection(series, sections, settings); + UpdatePartialSection(movie, sections, settings); } else @@ -56,38 +55,6 @@ namespace NzbDrone.Core.Notifications.Plex } } - catch(Exception ex) - { - _logger.Warn(ex, "Failed to Update Plex host: " + settings.Host); - throw; - } - } - - public void UpdateMovieSections(Movie movie, PlexServerSettings settings) - { - try - { - _logger.Debug("Sending Update Request to Plex Server"); - - var version = _versionCache.Get(settings.Host, () => GetVersion(settings), TimeSpan.FromHours(2)); - ValidateVersion(version); - - var sections = GetSections(settings); - var partialUpdates = _partialUpdateCache.Get(settings.Host, () => PartialUpdatesAllowed(settings, version), TimeSpan.FromHours(2)); - - // TODO: Investiate partial updates later, for now just update all movie sections... - - //if (partialUpdates) - //{ - // UpdatePartialSection(series, sections, settings); - //} - - //else - //{ - sections.ForEach(s => UpdateSection(s.Id, settings)); - //} - } - catch (Exception ex) { _logger.Warn(ex, "Failed to Update Plex host: " + settings.Host); @@ -163,18 +130,18 @@ namespace NzbDrone.Core.Notifications.Plex _plexServerProxy.Update(sectionId, settings); } - private void UpdatePartialSection(Series series, List sections, PlexServerSettings settings) + private void UpdatePartialSection(Movie movie, List sections, PlexServerSettings settings) { var partiallyUpdated = false; foreach (var section in sections) { - var metadataId = GetMetadataId(section.Id, series, section.Language, settings); + var metadataId = GetMetadataId(section.Id, movie, section.Language, settings); if (metadataId.HasValue) { - _logger.Debug("Updating Plex host: {0}, Section: {1}, Series: {2}", settings.Host, section.Id, series); - _plexServerProxy.UpdateSeries(metadataId.Value, settings); + _logger.Debug("Updating Plex host: {0}, Section: {1}, Movie: {2}", settings.Host, section.Id, movie); + _plexServerProxy.UpdateItem(metadataId.Value, settings); partiallyUpdated = true; } @@ -188,11 +155,11 @@ namespace NzbDrone.Core.Notifications.Plex } } - private int? GetMetadataId(int sectionId, Series series, string language, PlexServerSettings settings) + private int? GetMetadataId(int sectionId, Movie movie, string language, PlexServerSettings settings) { - _logger.Debug("Getting metadata from Plex host: {0} for series: {1}", settings.Host, series); + _logger.Debug("Getting metadata from Plex host: {0} for movie: {1}", settings.Host, movie); - return _plexServerProxy.GetMetadataId(sectionId, series.TvdbId, language, settings); + return _plexServerProxy.GetMetadataId(sectionId, movie.ImdbId, language, settings); } public ValidationFailure Test(PlexServerSettings settings) diff --git a/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs b/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs index 17357df0d..2231a974c 100644 --- a/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs +++ b/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs @@ -35,10 +35,6 @@ namespace NzbDrone.Core.Notifications.Prowl { } - public override void OnRename(Series series) - { - } - public override string Name => "Prowl"; public override bool SupportsOnRename => false; diff --git a/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs b/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs index b8a2e9736..5381af2ef 100644 --- a/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs +++ b/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs @@ -33,10 +33,6 @@ namespace NzbDrone.Core.Notifications.PushBullet public override void OnMovieRename(Movie movie) { } - - public override void OnRename(Series series) - { - } public override string Name => "Pushbullet"; diff --git a/src/NzbDrone.Core/Notifications/Pushalot/Pushalot.cs b/src/NzbDrone.Core/Notifications/Pushalot/Pushalot.cs index 953c08a8c..af853a086 100644 --- a/src/NzbDrone.Core/Notifications/Pushalot/Pushalot.cs +++ b/src/NzbDrone.Core/Notifications/Pushalot/Pushalot.cs @@ -34,10 +34,6 @@ namespace NzbDrone.Core.Notifications.Pushalot { } - public override void OnRename(Series series) - { - } - public override string Name => "Pushalot"; public override bool SupportsOnRename => false; diff --git a/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs b/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs index d590099f5..504d27076 100644 --- a/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs +++ b/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs @@ -34,10 +34,6 @@ namespace NzbDrone.Core.Notifications.Pushover { } - public override void OnRename(Series series) - { - } - public override string Name => "Pushover"; public override bool SupportsOnRename => false; diff --git a/src/NzbDrone.Core/Notifications/Slack/Slack.cs b/src/NzbDrone.Core/Notifications/Slack/Slack.cs index 471986dc7..9b28b69d0 100644 --- a/src/NzbDrone.Core/Notifications/Slack/Slack.cs +++ b/src/NzbDrone.Core/Notifications/Slack/Slack.cs @@ -78,21 +78,6 @@ namespace NzbDrone.Core.Notifications.Slack _proxy.SendPayload(payload, Settings); } - public override void OnRename(Series series) - { - var attachments = new List - { - new Attachment - { - Title = series.Title, - } - }; - - var payload = CreatePayload("Renamed", attachments); - - _proxy.SendPayload(payload, Settings); - } - public override ValidationResult Test() { var failures = new List(); diff --git a/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs b/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs index a05eab45c..a7289151a 100644 --- a/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs +++ b/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs @@ -50,14 +50,6 @@ namespace NzbDrone.Core.Notifications.Synology } } - public override void OnRename(Series series) - { - if (Settings.UpdateLibrary) - { - _indexerProxy.UpdateFolder(series.Path); - } - } - public override string Name => "Synology Indexer"; public override ValidationResult Test() diff --git a/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs b/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs index 477872409..d1b080ef2 100644 --- a/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs +++ b/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs @@ -34,10 +34,6 @@ namespace NzbDrone.Core.Notifications.Telegram { } - public override void OnRename(Series series) - { - } - public override string Name => "Telegram"; public override bool SupportsOnRename => false; diff --git a/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs b/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs index 037fb947c..2ba5f81f0 100644 --- a/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs +++ b/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs @@ -33,10 +33,6 @@ namespace NzbDrone.Core.Notifications.Twitter { } - public override void OnRename(Series series) - { - } - public override object RequestAction(string action, IDictionary query) { if (action == "startOAuth") diff --git a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs index 4f10e89c9..4b02821ef 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs @@ -61,10 +61,6 @@ namespace NzbDrone.Core.Notifications.Webhook _proxy.SendWebhook(payload, Settings); } - public override void OnRename(Series series) - { - } - public override string Name => "Webhook"; public override ValidationResult Test() diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookProxy.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookProxy.cs index 328c838b8..bb9c6b40b 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookProxy.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookProxy.cs @@ -1,6 +1,8 @@ using NzbDrone.Common.Http; using NzbDrone.Common.Serializer; using NzbDrone.Core.Rest; +using System; +using System.Text; namespace NzbDrone.Core.Notifications.Webhook { @@ -30,6 +32,13 @@ namespace NzbDrone.Core.Notifications.Webhook request.Headers.ContentType = "application/json"; request.SetContent(body.ToJson()); + if (!String.IsNullOrEmpty(settings.Username) || !String.IsNullOrEmpty(settings.Password)) + { + var authInfo = settings.Username + ":" + settings.Password; + authInfo = Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes(authInfo)); + request.Headers.Set("Authorization", "Basic " + authInfo); + } + _httpClient.Execute(request); } catch (RestException ex) diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookSettings.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookSettings.cs index 38ac3ee12..1219c70b4 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookSettings.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookSettings.cs @@ -29,6 +29,12 @@ namespace NzbDrone.Core.Notifications.Webhook [FieldDefinition(1, Label = "Method", Type = FieldType.Select, SelectOptions = typeof(WebhookMethod), HelpText = "Which HTTP method to use submit to the Webservice")] public int Method { get; set; } + [FieldDefinition(2, Label = "Username")] + public string Username { get; set; } + + [FieldDefinition(3, Label = "Password", Type = FieldType.Password)] + public string Password { get; set; } + public NzbDroneValidationResult Validate() { return new NzbDroneValidationResult(Validator.Validate(this)); diff --git a/src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs b/src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs deleted file mode 100644 index 44e4f64d2..000000000 --- a/src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs +++ /dev/null @@ -1,236 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Xml.Linq; -using NLog; -using NzbDrone.Common.Http; -using NzbDrone.Core.Notifications.Xbmc.Model; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Notifications.Xbmc -{ - public class HttpApiProvider : IApiProvider - { - private readonly IHttpProvider _httpProvider; - private readonly Logger _logger; - - public HttpApiProvider(IHttpProvider httpProvider, Logger logger) - { - _httpProvider = httpProvider; - _logger = logger; - } - - public bool CanHandle(XbmcVersion version) - { - return version < new XbmcVersion(5); - } - - public void Notify(XbmcSettings settings, string title, string message) - { - var notification = string.Format("Notification({0},{1},{2},{3})", title, message, settings.DisplayTime * 1000, "https://raw.github.com/Radarr/Radarr/develop/Logo/64.png"); - var command = BuildExecBuiltInCommand(notification); - - SendCommand(settings, command); - } - - public void Update(XbmcSettings settings, Series series) - { - if (!settings.AlwaysUpdate) - { - _logger.Debug("Determining if there are any active players on XBMC host: {0}", settings.Address); - var activePlayers = GetActivePlayers(settings); - - if (activePlayers.Any(a => a.Type.Equals("video"))) - { - _logger.Debug("Video is currently playing, skipping library update"); - return; - } - } - - UpdateLibrary(settings, series); - } - - public void UpdateMovie(XbmcSettings settings, Movie movie) - { - if (!settings.AlwaysUpdate) - { - _logger.Debug("Determining if there are any active players on XBMC host: {0}", settings.Address); - var activePlayers = GetActivePlayers(settings); - - if (activePlayers.Any(a => a.Type.Equals("video"))) - { - _logger.Debug("Video is currently playing, skipping library update"); - return; - } - } - - UpdateMovieLibrary(settings, movie); - } - - - public void Clean(XbmcSettings settings) - { - const string cleanVideoLibrary = "CleanLibrary(video)"; - var command = BuildExecBuiltInCommand(cleanVideoLibrary); - - SendCommand(settings, command); - } - - internal List GetActivePlayers(XbmcSettings settings) - { - try - { - var result = new List(); - var response = SendCommand(settings, "getcurrentlyplaying"); - - if (response.Contains("
  • Filename:[Nothing Playing]")) return new List(); - if (response.Contains("
  • Type:Video")) result.Add(new ActivePlayer(1, "video")); - - return result; - } - - catch (Exception ex) - { - _logger.Debug(ex, ex.Message); - } - - return new List(); - } - - internal string GetSeriesPath(XbmcSettings settings, Series series) - { - var query = - string.Format( - "select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = {0} and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath", - series.TvdbId); - var command = string.Format("QueryVideoDatabase({0})", query); - - const string setResponseCommand = - "SetResponseFormat(webheader;false;webfooter;false;header;;footer;;opentag;;closetag;;closefinaltag;false)"; - const string resetResponseCommand = "SetResponseFormat()"; - - SendCommand(settings, setResponseCommand); - var response = SendCommand(settings, command); - SendCommand(settings, resetResponseCommand); - - if (string.IsNullOrEmpty(response)) - return string.Empty; - - var xDoc = XDocument.Load(new StringReader(response.Replace("&", "&"))); - var xml = xDoc.Descendants("xml").Select(x => x).FirstOrDefault(); - - if (xml == null) - return null; - - var field = xml.Descendants("field").FirstOrDefault(); - - if (field == null) - return null; - - return field.Value; - } - - internal bool CheckForError(string response) - { - _logger.Debug("Looking for error in response: {0}", response); - - if (string.IsNullOrWhiteSpace(response)) - { - _logger.Debug("Invalid response from XBMC, the response is not valid JSON"); - return true; - } - - var errorIndex = response.IndexOf("Error", StringComparison.InvariantCultureIgnoreCase); - - if (errorIndex > -1) - { - var errorMessage = response.Substring(errorIndex + 6); - errorMessage = errorMessage.Substring(0, errorMessage.IndexOfAny(new char[] { '<', ';' })); - - _logger.Debug("Error found in response: {0}", errorMessage); - return true; - } - - return false; - } - - private void UpdateLibrary(XbmcSettings settings, Series series) - { - try - { - _logger.Debug("Sending Update DB Request to XBMC Host: {0}", settings.Address); - var xbmcSeriesPath = GetSeriesPath(settings, series); - - //If the path is found update it, else update the whole library - if (!string.IsNullOrEmpty(xbmcSeriesPath)) - { - _logger.Debug("Updating series [{0}] on XBMC host: {1}", series, settings.Address); - var command = BuildExecBuiltInCommand(string.Format("UpdateLibrary(video,{0})", xbmcSeriesPath)); - SendCommand(settings, command); - } - - else - { - //Update the entire library - _logger.Debug("Series [{0}] doesn't exist on XBMC host: {1}, Updating Entire Library", series, settings.Address); - var command = BuildExecBuiltInCommand("UpdateLibrary(video)"); - SendCommand(settings, command); - } - } - - catch (Exception ex) - { - _logger.Debug(ex, ex.Message); - } - } - - private void UpdateMovieLibrary(XbmcSettings settings, Movie movie) - { - try - { - //_logger.Debug("Sending Update DB Request to XBMC Host: {0}", settings.Address); - //var xbmcSeriesPath = GetSeriesPath(settings, series); - - ////If the path is found update it, else update the whole library - //if (!string.IsNullOrEmpty(xbmcSeriesPath)) - //{ - // _logger.Debug("Updating series [{0}] on XBMC host: {1}", series, settings.Address); - // var command = BuildExecBuiltInCommand(string.Format("UpdateLibrary(video,{0})", xbmcSeriesPath)); - // SendCommand(settings, command); - //} - - //else - //{ - //Update the entire library - _logger.Debug("Series [{0}] doesn't exist on XBMC host: {1}, Updating Entire Library", movie, settings.Address); - var command = BuildExecBuiltInCommand("UpdateLibrary(video)"); - SendCommand(settings, command); - //} - } - - catch (Exception ex) - { - _logger.Debug(ex, ex.Message); - } - } - - - private string SendCommand(XbmcSettings settings, string command) - { - var url = string.Format("http://{0}/xbmcCmds/xbmcHttp?command={1}", settings.Address, command); - - if (!string.IsNullOrEmpty(settings.Username)) - { - return _httpProvider.DownloadString(url, settings.Username, settings.Password); - } - - return _httpProvider.DownloadString(url); - } - - private string BuildExecBuiltInCommand(string command) - { - return string.Format("ExecBuiltIn({0})", command); - } - } -} diff --git a/src/NzbDrone.Core/Notifications/Xbmc/IApiProvider.cs b/src/NzbDrone.Core/Notifications/Xbmc/IApiProvider.cs index 94bf80862..93ef1f30a 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/IApiProvider.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/IApiProvider.cs @@ -6,7 +6,6 @@ namespace NzbDrone.Core.Notifications.Xbmc public interface IApiProvider { void Notify(XbmcSettings settings, string title, string message); - void Update(XbmcSettings settings, Series series); void UpdateMovie(XbmcSettings settings, Movie movie); void Clean(XbmcSettings settings); bool CanHandle(XbmcVersion version); diff --git a/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs b/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs index 378bb0774..5b98342f2 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs @@ -28,23 +28,6 @@ namespace NzbDrone.Core.Notifications.Xbmc _proxy.Notify(settings, title, message); } - public void Update(XbmcSettings settings, Series series) - { - if (!settings.AlwaysUpdate) - { - _logger.Debug("Determining if there are any active players on XBMC host: {0}", settings.Address); - var activePlayers = _proxy.GetActivePlayers(settings); - - if (activePlayers.Any(a => a.Type.Equals("video"))) - { - _logger.Debug("Video is currently playing, skipping library update"); - return; - } - } - - UpdateLibrary(settings, series); - } - public void UpdateMovie(XbmcSettings settings, Movie movie) { if (!settings.AlwaysUpdate) @@ -73,65 +56,45 @@ namespace NzbDrone.Core.Notifications.Xbmc return _proxy.GetActivePlayers(settings); } - public string GetSeriesPath(XbmcSettings settings, Series series) + public string GetMoviePath(XbmcSettings settings, Movie movie) { - var allSeries = _proxy.GetSeries(settings); + var allMovies = _proxy.GetMovies(settings); - if (!allSeries.Any()) + if (!allMovies.Any()) { - _logger.Debug("No TV shows returned from XBMC"); + _logger.Debug("No Movies returned from XBMC"); return null; } - var matchingSeries = allSeries.FirstOrDefault(s => + var matchingMovies = allMovies.FirstOrDefault(s => { - var tvdbId = 0; - int.TryParse(s.ImdbNumber, out tvdbId); + return s.ImdbNumber == movie.ImdbId || s.Label == movie.Title; - return tvdbId == series.TvdbId || s.Label == series.Title; }); - if (matchingSeries != null) return matchingSeries.File; + if (matchingMovies != null) return matchingMovies.File; return null; } - private void UpdateLibrary(XbmcSettings settings, Series series) + private void UpdateMovieLibrary(XbmcSettings settings, Movie movie) { try { - var seriesPath = GetSeriesPath(settings, series); + var moviePath = GetMoviePath(settings, movie); - if (seriesPath != null) + if (moviePath != null) { - _logger.Debug("Updating series {0} (Path: {1}) on XBMC host: {2}", series, seriesPath, settings.Address); + _logger.Debug("Updating movie {0} (Path: {1}) on XBMC host: {2}", movie, moviePath, settings.Address); } else { - _logger.Debug("Series {0} doesn't exist on XBMC host: {1}, Updating Entire Library", series, + _logger.Debug("Movie {0} doesn't exist on XBMC host: {1}, Updating Entire Library", movie, settings.Address); } - var response = _proxy.UpdateLibrary(settings, seriesPath); - - if (!response.Equals("OK", StringComparison.InvariantCultureIgnoreCase)) - { - _logger.Debug("Failed to update library for: {0}", settings.Address); - } - } - - catch (Exception ex) - { - _logger.Debug(ex, ex.Message); - } - } - - private void UpdateMovieLibrary(XbmcSettings settings, Movie movie) - { - try - { - var response = _proxy.UpdateLibrary(settings, null); + var response = _proxy.UpdateLibrary(settings, moviePath); if (!response.Equals("OK", StringComparison.InvariantCultureIgnoreCase)) { diff --git a/src/NzbDrone.Core/Notifications/Xbmc/Model/TvShowResponse.cs b/src/NzbDrone.Core/Notifications/Xbmc/Model/MovieResponse.cs similarity index 65% rename from src/NzbDrone.Core/Notifications/Xbmc/Model/TvShowResponse.cs rename to src/NzbDrone.Core/Notifications/Xbmc/Model/MovieResponse.cs index 079ede558..cf326b5b0 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/Model/TvShowResponse.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/Model/MovieResponse.cs @@ -1,9 +1,9 @@ namespace NzbDrone.Core.Notifications.Xbmc.Model { - public class TvShowResponse + public class MovieResponse { public string Id { get; set; } public string JsonRpc { get; set; } - public TvShowResult Result { get; set; } + public MovieResult Result { get; set; } } } diff --git a/src/NzbDrone.Core/Notifications/Xbmc/Model/TvShowResult.cs b/src/NzbDrone.Core/Notifications/Xbmc/Model/MovieResult.cs similarity index 56% rename from src/NzbDrone.Core/Notifications/Xbmc/Model/TvShowResult.cs rename to src/NzbDrone.Core/Notifications/Xbmc/Model/MovieResult.cs index f3fb4dd4a..4a26dd754 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/Model/TvShowResult.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/Model/MovieResult.cs @@ -2,14 +2,14 @@ namespace NzbDrone.Core.Notifications.Xbmc.Model { - public class TvShowResult + public class MovieResult { public Dictionary Limits { get; set; } - public List TvShows; + public List Movies; - public TvShowResult() + public MovieResult() { - TvShows = new List(); + Movies = new List(); } } } diff --git a/src/NzbDrone.Core/Notifications/Xbmc/Model/TvShow.cs b/src/NzbDrone.Core/Notifications/Xbmc/Model/XbmcMovie.cs similarity index 74% rename from src/NzbDrone.Core/Notifications/Xbmc/Model/TvShow.cs rename to src/NzbDrone.Core/Notifications/Xbmc/Model/XbmcMovie.cs index 437285107..2a6b313e6 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/Model/TvShow.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/Model/XbmcMovie.cs @@ -1,8 +1,8 @@ namespace NzbDrone.Core.Notifications.Xbmc.Model { - public class TvShow + public class XbmcMovie { - public int TvShowId { get; set; } + public int movieId { get; set; } public string Label { get; set; } public string ImdbNumber { get; set; } public string File { get; set; } diff --git a/src/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs b/src/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs index 890e0516d..25f995e33 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs @@ -41,11 +41,6 @@ namespace NzbDrone.Core.Notifications.Xbmc UpdateAndCleanMovie(movie); } - public override void OnRename(Series series) - { - UpdateAndClean(series); - } - public override string Name => "Kodi (XBMC)"; public override ValidationResult Test() @@ -73,27 +68,6 @@ namespace NzbDrone.Core.Notifications.Xbmc } } - private void UpdateAndClean(Series series, bool clean = true) - { - try - { - if (Settings.UpdateLibrary) - { - _xbmcService.Update(Settings, series); - } - - if (clean && Settings.CleanLibrary) - { - _xbmcService.Clean(Settings); - } - } - catch (SocketException ex) - { - var logMessage = string.Format("Unable to connect to XBMC Host: {0}:{1}", Settings.Host, Settings.Port); - _logger.Debug(ex, logMessage); - } - } - private void UpdateAndCleanMovie(Movie movie, bool clean = true) { try diff --git a/src/NzbDrone.Core/Notifications/Xbmc/XbmcJsonApiProxy.cs b/src/NzbDrone.Core/Notifications/Xbmc/XbmcJsonApiProxy.cs index 1d46d47cb..c7f6d85eb 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/XbmcJsonApiProxy.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/XbmcJsonApiProxy.cs @@ -16,7 +16,7 @@ namespace NzbDrone.Core.Notifications.Xbmc string UpdateLibrary(XbmcSettings settings, string path); void CleanLibrary(XbmcSettings settings); List GetActivePlayers(XbmcSettings settings); - List GetSeries(XbmcSettings settings); + List GetMovies(XbmcSettings settings); } public class XbmcJsonApiProxy : IXbmcJsonApiProxy @@ -79,15 +79,15 @@ namespace NzbDrone.Core.Notifications.Xbmc return Json.Deserialize(response).Result; } - public List GetSeries(XbmcSettings settings) + public List GetMovies(XbmcSettings settings) { var request = new RestRequest(); var parameters = new Dictionary(); parameters.Add("properties", new[] { "file", "imdbnumber" }); - var response = ProcessRequest(request, settings, "VideoLibrary.GetTvShows", parameters); + var response = ProcessRequest(request, settings, "VideoLibrary.GetMovies", parameters); - return Json.Deserialize(response).Result.TvShows; + return Json.Deserialize(response).Result.Movies; } private string ProcessRequest(IRestRequest request, XbmcSettings settings, string method, Dictionary parameters = null) diff --git a/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs b/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs index 85dbc99c5..51a0ccaaf 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs @@ -14,7 +14,6 @@ namespace NzbDrone.Core.Notifications.Xbmc public interface IXbmcService { void Notify(XbmcSettings settings, string title, string message); - void Update(XbmcSettings settings, Series series); void UpdateMovie(XbmcSettings settings, Movie movie); void Clean(XbmcSettings settings); ValidationFailure Test(XbmcSettings settings, string message); @@ -46,12 +45,6 @@ namespace NzbDrone.Core.Notifications.Xbmc provider.Notify(settings, title, message); } - public void Update(XbmcSettings settings, Series series) - { - var provider = GetApiProvider(settings); - provider.Update(settings, series); - } - public void UpdateMovie(XbmcSettings settings, Movie movie) { var provider = GetApiProvider(settings); diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 4c4ac5cf1..febdc3e10 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -1091,7 +1091,6 @@ - @@ -1099,9 +1098,6 @@ - - - @@ -1307,6 +1303,9 @@ + + + diff --git a/src/NzbDrone.Core/packages.config b/src/NzbDrone.Core/packages.config index 1595582c5..43156d083 100644 --- a/src/NzbDrone.Core/packages.config +++ b/src/NzbDrone.Core/packages.config @@ -11,4 +11,4 @@ - \ No newline at end of file +