From 864549b1f3af6a8e77bc32d94cb94ef442fb1c8a Mon Sep 17 00:00:00 2001 From: Qstick Date: Fri, 22 Sep 2017 21:59:24 -0400 Subject: [PATCH] Initial Notification Support, XBMC and PLEX still need work. --- .../NotificationBaseFixture.cs | 6 +- .../SynologyIndexerFixture.cs | 24 ++--- .../Xbmc/Http/GetSeriesPathFixture.cs | 18 ++-- .../Xbmc/Http/UpdateFixture.cs | 12 +-- .../Xbmc/Json/GetSeriesPathFixture.cs | 44 ++++----- .../Xbmc/Json/UpdateFixture.cs | 26 +++--- .../Xbmc/OnDownloadFixture.cs | 16 ++-- .../Notifications/Boxcar/Boxcar.cs | 4 +- .../CustomScript/CustomScript.cs | 91 +++++++++---------- .../Notifications/DownloadMessage.cs | 10 +- .../Notifications/Email/Email.cs | 4 +- .../Notifications/GrabMessage.cs | 8 +- .../Notifications/Growl/Growl.cs | 4 +- .../Notifications/INotification.cs | 6 +- src/NzbDrone.Core/Notifications/Join/Join.cs | 4 +- .../MediaBrowser/MediaBrowser.cs | 14 +-- .../MediaBrowser/MediaBrowserProxy.cs | 6 +- .../MediaBrowser/MediaBrowserService.cs | 10 +- .../Notifications/NotificationBase.cs | 14 +-- .../Notifications/NotificationService.cs | 91 +++++++++---------- .../NotifyMyAndroid/NotifyMyAndroid.cs | 4 +- .../Notifications/Plex/PlexClient.cs | 4 +- .../Notifications/Plex/PlexHomeTheater.cs | 4 +- .../Notifications/Plex/PlexServer.cs | 14 +-- .../Notifications/Plex/PlexServerProxy.cs | 8 +- .../Notifications/Plex/PlexServerService.cs | 26 +++--- .../Notifications/Prowl/Prowl.cs | 4 +- .../Notifications/PushBullet/PushBullet.cs | 4 +- .../Notifications/Pushalot/Pushalot.cs | 4 +- .../Notifications/Pushover/Pushover.cs | 4 +- .../Notifications/Slack/Slack.cs | 12 +-- .../Notifications/Synology/SynologyIndexer.cs | 12 +-- .../Notifications/Telegram/Telegram.cs | 4 +- .../Notifications/Webhook/Webhook.cs | 12 +-- .../Notifications/Webhook/WebhookAlbum.cs | 26 ++++++ .../Notifications/Webhook/WebhookArtist.cs | 22 +++++ .../Notifications/Webhook/WebhookEpisode.cs | 32 ------- .../Notifications/Webhook/WebhookPayload.cs | 8 +- .../Notifications/Webhook/WebhookSeries.cs | 22 ----- .../Notifications/Webhook/WebhookService.cs | 46 +++++----- .../Notifications/Xbmc/HttpApiProvider.cs | 20 ++-- .../Notifications/Xbmc/IApiProvider.cs | 6 +- .../Notifications/Xbmc/JsonApiProvider.cs | 28 +++--- src/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs | 14 +-- .../Notifications/Xbmc/XbmcJsonApiProxy.cs | 6 +- .../Notifications/Xbmc/XbmcService.cs | 12 +-- src/NzbDrone.Core/NzbDrone.Core.csproj | 4 +- 47 files changed, 378 insertions(+), 396 deletions(-) create mode 100644 src/NzbDrone.Core/Notifications/Webhook/WebhookAlbum.cs create mode 100644 src/NzbDrone.Core/Notifications/Webhook/WebhookArtist.cs delete mode 100644 src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs delete mode 100644 src/NzbDrone.Core/Notifications/Webhook/WebhookSeries.cs diff --git a/src/NzbDrone.Core.Test/NotificationTests/NotificationBaseFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/NotificationBaseFixture.cs index 0230fa5e8..c017a56f2 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/NotificationBaseFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/NotificationBaseFixture.cs @@ -1,10 +1,10 @@ -using System; +using System; using FluentAssertions; using FluentValidation.Results; using NUnit.Framework; using NzbDrone.Core.Notifications; using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Core.Validation; using NzbDrone.Test.Common; @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.NotificationTests TestLogger.Info("OnDownload was called"); } - public override void OnRename(Series series) + public override void OnRename(Artist artist) { TestLogger.Info("OnRename was called"); } diff --git a/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs index 724bfb0d7..53b2f081f 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs @@ -1,11 +1,11 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Moq; using NUnit.Framework; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Notifications; using NzbDrone.Core.Notifications.Synology; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.NotificationTests @@ -13,33 +13,33 @@ namespace NzbDrone.Core.Test.NotificationTests [TestFixture] public class SynologyIndexerFixture : CoreTest { - private Series _series; + private Artist _artist; private DownloadMessage _upgrade; [SetUp] public void SetUp() { - _series = new Series() + _artist = new Artist() { Path = @"C:\Test\".AsOsAgnostic() }; _upgrade = new DownloadMessage() { - Series = _series, + Artist = _artist, - EpisodeFile = new EpisodeFile + TrackFile = new TrackFile { RelativePath = "file1.S01E01E02.mkv" }, - OldFiles = new List + OldFiles = new List { - new EpisodeFile + new TrackFile { RelativePath = "file1.S01E01.mkv" }, - new EpisodeFile + new TrackFile { RelativePath = "file1.S01E02.mkv" } @@ -60,10 +60,10 @@ namespace NzbDrone.Core.Test.NotificationTests { (Subject.Definition.Settings as SynologyIndexerSettings).UpdateLibrary = false; - Subject.OnRename(_series); + Subject.OnRename(_artist); Mocker.GetMock() - .Verify(v => v.UpdateFolder(_series.Path), Times.Never()); + .Verify(v => v.UpdateFolder(_artist.Path), Times.Never()); } [Test] @@ -90,7 +90,7 @@ namespace NzbDrone.Core.Test.NotificationTests [Test] public void should_update_entire_series_folder_on_rename() { - Subject.OnRename(_series); + Subject.OnRename(_artist); Mocker.GetMock() .Verify(v => v.UpdateFolder(@"C:\Test\".AsOsAgnostic()), Times.Once()); diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/GetSeriesPathFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/GetSeriesPathFixture.cs index 15ec93960..7b48db3de 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/GetSeriesPathFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/GetSeriesPathFixture.cs @@ -1,9 +1,9 @@ -using FluentAssertions; +using FluentAssertions; using NUnit.Framework; using NzbDrone.Common.Http; using NzbDrone.Core.Notifications.Xbmc; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http { @@ -11,7 +11,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http public class GetSeriesPathFixture : CoreTest { private XbmcSettings _settings; - private Series _series; + private Artist _artist; [SetUp] public void Setup() @@ -27,10 +27,10 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http UpdateLibrary = true }; - _series = new Series + _artist = new Artist { - TvdbId = 79488, - Title = "30 Rock" + ForeignArtistId = "123d45d-d154f5d-1f5d1-5df18d5", + Name = "30 Rock" }; const string setResponseUrl = "http://localhost:8080/xbmcCmds/xbmcHttp?command=SetResponseFormat(webheader;false;webfooter;false;header;;footer;;opentag;;closetag;;closefinaltag;false)"; @@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http .Setup(s => s.DownloadString(query, _settings.Username, _settings.Password)) .Returns(queryResult); - Subject.GetSeriesPath(_settings, _series) + Subject.GetSeriesPath(_settings, _artist) .Should().Be("smb://xbmc:xbmc@HOMESERVER/TV/30 Rock/"); } @@ -72,7 +72,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http .Returns(queryResult); - Subject.GetSeriesPath(_settings, _series) + Subject.GetSeriesPath(_settings, _artist) .Should().BeNull(); } @@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http .Returns(queryResult); - Subject.GetSeriesPath(_settings, _series) + Subject.GetSeriesPath(_settings, _artist) .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 index aad928f95..d11ab4ad4 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/UpdateFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/UpdateFixture.cs @@ -1,9 +1,9 @@ -using FizzWare.NBuilder; +using FizzWare.NBuilder; using NUnit.Framework; using NzbDrone.Common.Http; using NzbDrone.Core.Notifications.Xbmc; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http { @@ -12,7 +12,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http { 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; + private Artist _fakeSeries; [SetUp] public void Setup() @@ -28,9 +28,9 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http UpdateLibrary = true }; - _fakeSeries = Builder.CreateNew() - .With(s => s.TvdbId = 79488) - .With(s => s.Title = "30 Rock") + _fakeSeries = Builder.CreateNew() + .With(s => s.ForeignArtistId = "79488") + .With(s => s.Name = "30 Rock") .Build(); } diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetSeriesPathFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetSeriesPathFixture.cs index b4b29dff2..650939619 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetSeriesPathFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetSeriesPathFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; using FluentAssertions; @@ -6,16 +6,16 @@ using NUnit.Framework; using NzbDrone.Core.Notifications.Xbmc; using NzbDrone.Core.Notifications.Xbmc.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json { [TestFixture] public class GetSeriesPathFixture : CoreTest { - private const int TVDB_ID = 5; + private const string MB_ID = "5"; private XbmcSettings _settings; - private Series _series; + private Artist _artist; private List _xbmcSeries; [SetUp] @@ -28,39 +28,39 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json .All() .With(s => s.ImdbNumber = "0") .TheFirst(1) - .With(s => s.ImdbNumber = TVDB_ID.ToString()) + .With(s => s.ImdbNumber = MB_ID.ToString()) .Build() .ToList(); Mocker.GetMock() - .Setup(s => s.GetSeries(_settings)) + .Setup(s => s.GetArtist(_settings)) .Returns(_xbmcSeries); } private void GivenMatchingTvdbId() { - _series = new Series - { - TvdbId = TVDB_ID, - Title = "TV Show" + _artist = new Artist + { + ForeignArtistId = MB_ID, + Name = "TV Show" }; } private void GivenMatchingTitle() { - _series = new Series + _artist = new Artist { - TvdbId = 1000, - Title = _xbmcSeries.First().Label + ForeignArtistId = "1000", + Name = _xbmcSeries.First().Label }; } private void GivenMatchingSeries() { - _series = new Series + _artist = new Artist { - TvdbId = 1000, - Title = "Does not exist" + ForeignArtistId = "1000", + Name = "Does not exist" }; } @@ -69,7 +69,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json { GivenMatchingSeries(); - Subject.GetSeriesPath(_settings, _series).Should().BeNull(); + Subject.GetSeriesPath(_settings, _artist).Should().BeNull(); } [Test] @@ -77,7 +77,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json { GivenMatchingTvdbId(); - Subject.GetSeriesPath(_settings, _series).Should().Be(_xbmcSeries.First().File); + Subject.GetSeriesPath(_settings, _artist).Should().Be(_xbmcSeries.First().File); } [Test] @@ -85,7 +85,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json { GivenMatchingTitle(); - Subject.GetSeriesPath(_settings, _series).Should().Be(_xbmcSeries.First().File); + Subject.GetSeriesPath(_settings, _artist).Should().Be(_xbmcSeries.First().File); } [Test] @@ -94,13 +94,13 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json GivenMatchingTvdbId(); _xbmcSeries.ForEach(s => s.ImdbNumber = "tt12345"); - _xbmcSeries.Last().ImdbNumber = TVDB_ID.ToString(); + _xbmcSeries.Last().ImdbNumber = MB_ID.ToString(); Mocker.GetMock() - .Setup(s => s.GetSeries(_settings)) + .Setup(s => s.GetArtist(_settings)) .Returns(_xbmcSeries); - Subject.GetSeriesPath(_settings, _series).Should().NotBeNull(); + Subject.GetSeriesPath(_settings, _artist).Should().NotBeNull(); } } } diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateFixture.cs index 408f2eeba..4e84fbd0c 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; using Moq; @@ -6,16 +6,16 @@ using NUnit.Framework; using NzbDrone.Core.Notifications.Xbmc; using NzbDrone.Core.Notifications.Xbmc.Model; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json { [TestFixture] public class UpdateFixture : CoreTest { - private const int TVDB_ID = 5; + private const string MB_ID = "5"; private XbmcSettings _settings; - private List _xbmcSeries; + private List _xbmcArtist; [SetUp] public void Setup() @@ -23,15 +23,15 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json _settings = Builder.CreateNew() .Build(); - _xbmcSeries = Builder.CreateListOfSize(3) + _xbmcArtist = Builder.CreateListOfSize(3) .TheFirst(1) - .With(s => s.ImdbNumber = TVDB_ID.ToString()) + .With(s => s.ImdbNumber = MB_ID.ToString()) .Build() .ToList(); Mocker.GetMock() - .Setup(s => s.GetSeries(_settings)) - .Returns(_xbmcSeries); + .Setup(s => s.GetArtist(_settings)) + .Returns(_xbmcArtist); Mocker.GetMock() .Setup(s => s.GetActivePlayers(_settings)) @@ -41,8 +41,8 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json [Test] public void should_update_using_series_path() { - var series = Builder.CreateNew() - .With(s => s.TvdbId = TVDB_ID) + var series = Builder.CreateNew() + .With(s => s.ForeignArtistId = MB_ID) .Build(); Subject.Update(_settings, series); @@ -54,9 +54,9 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json [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") + var fakeSeries = Builder.CreateNew() + .With(s => s.ForeignArtistId = "1000") + .With(s => s.Name = "Not 30 Rock") .Build(); Subject.Update(_settings, fakeSeries); diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/OnDownloadFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/OnDownloadFixture.cs index c43786614..2dba7a3af 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/OnDownloadFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/OnDownloadFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; using Moq; @@ -7,7 +7,7 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Notifications; using NzbDrone.Core.Notifications.Xbmc; using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.NotificationTests.Xbmc { @@ -19,16 +19,16 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc [SetUp] public void Setup() { - var series = Builder.CreateNew() + var artist = Builder.CreateNew() .Build(); - var episodeFile = Builder.CreateNew() + var trackFile = Builder.CreateNew() .Build(); _downloadMessage = Builder.CreateNew() - .With(d => d.Series = series) - .With(d => d.EpisodeFile = episodeFile) - .With(d => d.OldFiles = new List()) + .With(d => d.Artist = artist) + .With(d => d.TrackFile = trackFile) + .With(d => d.OldFiles = new List()) .Build(); Subject.Definition = new NotificationDefinition(); @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc private void GivenOldFiles() { - _downloadMessage.OldFiles = Builder.CreateListOfSize(1) + _downloadMessage.OldFiles = Builder.CreateListOfSize(1) .Build() .ToList(); diff --git a/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs b/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs index f5bc2b40c..b38172f43 100644 --- a/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs +++ b/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs @@ -18,12 +18,12 @@ namespace NzbDrone.Core.Notifications.Boxcar public override void OnGrab(GrabMessage grabMessage) { - _proxy.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, Settings); + _proxy.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, Settings); } public override void OnDownload(DownloadMessage message) { - _proxy.SendNotification(EPISODE_DOWNLOADED_TITLE , message.Message, Settings); + _proxy.SendNotification(TRACK_DOWNLOADED_TITLE , message.Message, Settings); } public override ValidationResult Test() diff --git a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs index 0a73f11ff..666ae0d3f 100644 --- a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs +++ b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs @@ -6,7 +6,7 @@ using FluentValidation.Results; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Processes; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Core.Validation; namespace NzbDrone.Core.Notifications.CustomScript @@ -30,27 +30,24 @@ namespace NzbDrone.Core.Notifications.CustomScript public override void OnGrab(GrabMessage message) { - var series = message.Series; - var remoteEpisode = message.Episode; - var releaseGroup = remoteEpisode.ParsedEpisodeInfo.ReleaseGroup; + var artist = message.Artist; + var remoteAlbum = message.Album; + var releaseGroup = remoteAlbum.ParsedAlbumInfo.ReleaseGroup; var environmentVariables = new StringDictionary(); environmentVariables.Add("Lidarr_EventType", "Grab"); - environmentVariables.Add("Lidarr_Series_Id", series.Id.ToString()); - environmentVariables.Add("Lidarr_Series_Title", series.Title); - environmentVariables.Add("Lidarr_Series_TvdbId", series.TvdbId.ToString()); - environmentVariables.Add("Lidarr_Series_Type", series.SeriesType.ToString()); - environmentVariables.Add("Lidarr_Release_EpisodeCount", remoteEpisode.Episodes.Count.ToString()); - environmentVariables.Add("Lidarr_Release_SeasonNumber", remoteEpisode.ParsedEpisodeInfo.SeasonNumber.ToString()); - environmentVariables.Add("Lidarr_Release_EpisodeNumbers", string.Join(",", remoteEpisode.Episodes.Select(e => e.EpisodeNumber))); - environmentVariables.Add("Lidarr_Release_EpisodeAirDates", string.Join(",", remoteEpisode.Episodes.Select(e => e.AirDate))); - environmentVariables.Add("Lidarr_Release_EpisodeAirDatesUtc", string.Join(",", remoteEpisode.Episodes.Select(e => e.AirDateUtc))); - environmentVariables.Add("Lidarr_Release_EpisodeTitles", string.Join("|", remoteEpisode.Episodes.Select(e => e.Title))); - environmentVariables.Add("Lidarr_Release_Title", remoteEpisode.Release.Title); - environmentVariables.Add("Lidarr_Release_Indexer", remoteEpisode.Release.Indexer); - environmentVariables.Add("Lidarr_Release_Size", remoteEpisode.Release.Size.ToString()); - environmentVariables.Add("Lidarr_Release_Quality", remoteEpisode.ParsedEpisodeInfo.Quality.Quality.Name); - environmentVariables.Add("Lidarr_Release_QualityVersion", remoteEpisode.ParsedEpisodeInfo.Quality.Revision.Version.ToString()); + environmentVariables.Add("Lidarr_Artist_Id", artist.Id.ToString()); + environmentVariables.Add("Lidarr_Artist_Name", artist.Name); + environmentVariables.Add("Lidarr_Artist_MBId", artist.ForeignArtistId.ToString()); + //environmentVariables.Add("Lidarr_Artist_Type", artist.SeriesType.ToString()); + environmentVariables.Add("Lidarr_Release_AlbumCount", remoteAlbum.Albums.Count.ToString()); + environmentVariables.Add("Lidarr_Release_AlbumReleaseDates", string.Join(",", remoteAlbum.Albums.Select(e => e.ReleaseDate))); + environmentVariables.Add("Lidarr_Release_AlbumTitles", string.Join("|", remoteAlbum.Albums.Select(e => e.Title))); + environmentVariables.Add("Lidarr_Release_Title", remoteAlbum.Release.Title); + environmentVariables.Add("Lidarr_Release_Indexer", remoteAlbum.Release.Indexer); + environmentVariables.Add("Lidarr_Release_Size", remoteAlbum.Release.Size.ToString()); + environmentVariables.Add("Lidarr_Release_Quality", remoteAlbum.ParsedAlbumInfo.Quality.Quality.Name); + environmentVariables.Add("Lidarr_Release_QualityVersion", remoteAlbum.ParsedAlbumInfo.Quality.Revision.Version.ToString()); environmentVariables.Add("Lidarr_Release_ReleaseGroup", releaseGroup); ExecuteScript(environmentVariables); @@ -58,53 +55,51 @@ namespace NzbDrone.Core.Notifications.CustomScript public override void OnDownload(DownloadMessage message) { - var series = message.Series; - var episodeFile = message.EpisodeFile; + var artist = message.Artist; + var trackFile = message.TrackFile; var sourcePath = message.SourcePath; var environmentVariables = new StringDictionary(); environmentVariables.Add("Lidarr_EventType", "Download"); environmentVariables.Add("LIdarr_IsUpgrade", message.OldFiles.Any().ToString()); - environmentVariables.Add("Lidarr_Series_Id", series.Id.ToString()); - environmentVariables.Add("Lidarr_Series_Title", series.Title); - environmentVariables.Add("Lidarr_Series_Path", series.Path); - environmentVariables.Add("Lidarr_Series_TvdbId", series.TvdbId.ToString()); - environmentVariables.Add("Lidarr_Series_Type", series.SeriesType.ToString()); - environmentVariables.Add("Lidarr_EpisodeFile_Id", episodeFile.Id.ToString()); - environmentVariables.Add("Lidarr_EpisodeFile_EpisodeCount", episodeFile.Episodes.Value.Count.ToString()); - environmentVariables.Add("Lidarr_EpisodeFile_RelativePath", episodeFile.RelativePath); - environmentVariables.Add("Lidarr_EpisodeFile_Path", Path.Combine(series.Path, episodeFile.RelativePath)); - environmentVariables.Add("Lidarr_EpisodeFile_SeasonNumber", episodeFile.SeasonNumber.ToString()); - environmentVariables.Add("Lidarr_EpisodeFile_EpisodeNumbers", string.Join(",", episodeFile.Episodes.Value.Select(e => e.EpisodeNumber))); - environmentVariables.Add("Lidarr_EpisodeFile_EpisodeAirDates", string.Join(",", episodeFile.Episodes.Value.Select(e => e.AirDate))); - environmentVariables.Add("Lidarr_EpisodeFile_EpisodeAirDatesUtc", string.Join(",", episodeFile.Episodes.Value.Select(e => e.AirDateUtc))); - environmentVariables.Add("Lidarr_EpisodeFile_EpisodeTitles", string.Join("|", episodeFile.Episodes.Value.Select(e => e.Title))); - environmentVariables.Add("Lidarr_EpisodeFile_Quality", episodeFile.Quality.Quality.Name); - environmentVariables.Add("Lidarr_EpisodeFile_QualityVersion", episodeFile.Quality.Revision.Version.ToString()); - environmentVariables.Add("Lidarr_EpisodeFile_ReleaseGroup", episodeFile.ReleaseGroup ?? string.Empty); - environmentVariables.Add("Lidarr_EpisodeFile_SceneName", episodeFile.SceneName ?? string.Empty); - environmentVariables.Add("Lidarr_EpisodeFile_SourcePath", sourcePath); - environmentVariables.Add("Lidarr_EpisodeFile_SourceFolder", Path.GetDirectoryName(sourcePath)); + environmentVariables.Add("Lidarr_Artist_Id", artist.Id.ToString()); + environmentVariables.Add("Lidarr_Artist_Name", artist.Name); + environmentVariables.Add("Lidarr_Artist_Path", artist.Path); + environmentVariables.Add("Lidarr_Artist_MBId", artist.ForeignArtistId.ToString()); + //environmentVariables.Add("Lidarr_Artist_Type", artist.SeriesType.ToString()); + environmentVariables.Add("Lidarr_TrackFile_Id", trackFile.Id.ToString()); + environmentVariables.Add("Lidarr_TrackFile_EpisodeCount", trackFile.Tracks.Value.Count.ToString()); + environmentVariables.Add("Lidarr_TrackFile_RelativePath", trackFile.RelativePath); + environmentVariables.Add("Lidarr_TrackFile_Path", Path.Combine(artist.Path, trackFile.RelativePath)); + environmentVariables.Add("Lidarr_TrackFile_TrackNumbers", string.Join(",", trackFile.Tracks.Value.Select(e => e.TrackNumber))); + environmentVariables.Add("Lidarr_TrackFile_TrackReleaseDates", string.Join(",", trackFile.Tracks.Value.Select(e => e.Album.ReleaseDate))); + environmentVariables.Add("Lidarr_TrackFile_TrackTitles", string.Join("|", trackFile.Tracks.Value.Select(e => e.Title))); + environmentVariables.Add("Lidarr_TrackFile_Quality", trackFile.Quality.Quality.Name); + environmentVariables.Add("Lidarr_TrackFile_QualityVersion", trackFile.Quality.Revision.Version.ToString()); + environmentVariables.Add("Lidarr_TrackFile_ReleaseGroup", trackFile.ReleaseGroup ?? string.Empty); + environmentVariables.Add("Lidarr_TrackFile_SceneName", trackFile.SceneName ?? string.Empty); + environmentVariables.Add("Lidarr_TrackFile_SourcePath", sourcePath); + environmentVariables.Add("Lidarr_TrackFile_SourceFolder", Path.GetDirectoryName(sourcePath)); if (message.OldFiles.Any()) { environmentVariables.Add("Lidarr_DeletedRelativePaths", string.Join("|", message.OldFiles.Select(e => e.RelativePath))); - environmentVariables.Add("Lidarr_DeletedPaths", string.Join("|", message.OldFiles.Select(e => Path.Combine(series.Path, e.RelativePath)))); + environmentVariables.Add("Lidarr_DeletedPaths", string.Join("|", message.OldFiles.Select(e => Path.Combine(artist.Path, e.RelativePath)))); } ExecuteScript(environmentVariables); } - public override void OnRename(Series series) + public override void OnRename(Artist artist) { var environmentVariables = new StringDictionary(); environmentVariables.Add("Lidarr_EventType", "Rename"); - environmentVariables.Add("Lidarr_Series_Id", series.Id.ToString()); - environmentVariables.Add("Lidarr_Series_Title", series.Title); - environmentVariables.Add("Lidarr_Series_Path", series.Path); - environmentVariables.Add("Lidarr_Series_TvdbId", series.TvdbId.ToString()); - environmentVariables.Add("Lidarr_Series_Type", series.SeriesType.ToString()); + environmentVariables.Add("Lidarr_Artist_Id", artist.Id.ToString()); + environmentVariables.Add("Lidarr_Artist_Title", artist.Name); + environmentVariables.Add("Lidarr_Artist_Path", artist.Path); + environmentVariables.Add("Lidarr_Artist_TvdbId", artist.ForeignArtistId.ToString()); + //environmentVariables.Add("Lidarr_Artist_Type", artist.SeriesType.ToString()); ExecuteScript(environmentVariables); } diff --git a/src/NzbDrone.Core/Notifications/DownloadMessage.cs b/src/NzbDrone.Core/Notifications/DownloadMessage.cs index a16ecea80..b16725fc8 100644 --- a/src/NzbDrone.Core/Notifications/DownloadMessage.cs +++ b/src/NzbDrone.Core/Notifications/DownloadMessage.cs @@ -1,15 +1,15 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications { public class DownloadMessage { public string Message { get; set; } - public Series Series { get; set; } - public EpisodeFile EpisodeFile { get; set; } - public List OldFiles { get; set; } + public Artist Artist { get; set; } + public TrackFile TrackFile { get; set; } + public List OldFiles { get; set; } public string SourcePath { get; set; } public override string ToString() diff --git a/src/NzbDrone.Core/Notifications/Email/Email.cs b/src/NzbDrone.Core/Notifications/Email/Email.cs index 52597861d..414cbf366 100644 --- a/src/NzbDrone.Core/Notifications/Email/Email.cs +++ b/src/NzbDrone.Core/Notifications/Email/Email.cs @@ -23,14 +23,14 @@ namespace NzbDrone.Core.Notifications.Email { var body = $"{grabMessage.Message} sent to queue."; - _emailService.SendEmail(Settings, EPISODE_GRABBED_TITLE_BRANDED, body); + _emailService.SendEmail(Settings, ALBUM_GRABBED_TITLE_BRANDED, body); } public override void OnDownload(DownloadMessage message) { var body = $"{message.Message} Downloaded and sorted."; - _emailService.SendEmail(Settings, EPISODE_DOWNLOADED_TITLE_BRANDED, body); + _emailService.SendEmail(Settings, TRACK_DOWNLOADED_TITLE_BRANDED, body); } diff --git a/src/NzbDrone.Core/Notifications/GrabMessage.cs b/src/NzbDrone.Core/Notifications/GrabMessage.cs index e62dbe701..c0dcfa574 100644 --- a/src/NzbDrone.Core/Notifications/GrabMessage.cs +++ b/src/NzbDrone.Core/Notifications/GrabMessage.cs @@ -1,14 +1,14 @@ -using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications { public class GrabMessage { public string Message { get; set; } - public Series Series { get; set; } - public RemoteEpisode Episode { get; set; } + public Artist Artist { get; set; } + public RemoteAlbum Album { 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 97232be70..f1236fe84 100644 --- a/src/NzbDrone.Core/Notifications/Growl/Growl.cs +++ b/src/NzbDrone.Core/Notifications/Growl/Growl.cs @@ -21,12 +21,12 @@ namespace NzbDrone.Core.Notifications.Growl public override void OnGrab(GrabMessage grabMessage) { - _growlService.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, "GRAB", Settings.Host, Settings.Port, Settings.Password); + _growlService.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, "GRAB", Settings.Host, Settings.Port, Settings.Password); } public override void OnDownload(DownloadMessage message) { - _growlService.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, "DOWNLOAD", Settings.Host, Settings.Port, Settings.Password); + _growlService.SendNotification(TRACK_DOWNLOADED_TITLE, message.Message, "DOWNLOAD", Settings.Host, Settings.Port, Settings.Password); } diff --git a/src/NzbDrone.Core/Notifications/INotification.cs b/src/NzbDrone.Core/Notifications/INotification.cs index 7c4e105b9..36b01e8db 100644 --- a/src/NzbDrone.Core/Notifications/INotification.cs +++ b/src/NzbDrone.Core/Notifications/INotification.cs @@ -1,5 +1,5 @@ -using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Tv; +using NzbDrone.Core.ThingiProvider; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications { @@ -9,7 +9,7 @@ namespace NzbDrone.Core.Notifications void OnGrab(GrabMessage grabMessage); void OnDownload(DownloadMessage message); - void OnRename(Series series); + void OnRename(Artist artist); bool SupportsOnGrab { get; } bool SupportsOnDownload { get; } bool SupportsOnUpgrade { get; } diff --git a/src/NzbDrone.Core/Notifications/Join/Join.cs b/src/NzbDrone.Core/Notifications/Join/Join.cs index b8122e7f5..c47b4f993 100644 --- a/src/NzbDrone.Core/Notifications/Join/Join.cs +++ b/src/NzbDrone.Core/Notifications/Join/Join.cs @@ -19,12 +19,12 @@ namespace NzbDrone.Core.Notifications.Join public override void OnGrab(GrabMessage message) { - _proxy.SendNotification(EPISODE_GRABBED_TITLE_BRANDED, message.Message, Settings); + _proxy.SendNotification(ALBUM_GRABBED_TITLE_BRANDED, message.Message, Settings); } public override void OnDownload(DownloadMessage message) { - _proxy.SendNotification(EPISODE_DOWNLOADED_TITLE_BRANDED, message.Message, Settings); + _proxy.SendNotification(TRACK_DOWNLOADED_TITLE_BRANDED, message.Message, Settings); } public override ValidationResult Test() diff --git a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowser.cs b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowser.cs index b13409dc7..baa150246 100644 --- a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowser.cs +++ b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowser.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; +using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications.Emby { @@ -22,7 +22,7 @@ namespace NzbDrone.Core.Notifications.Emby { if (Settings.Notify) { - _mediaBrowserService.Notify(Settings, EPISODE_GRABBED_TITLE_BRANDED, grabMessage.Message); + _mediaBrowserService.Notify(Settings, ALBUM_GRABBED_TITLE_BRANDED, grabMessage.Message); } } @@ -30,20 +30,20 @@ namespace NzbDrone.Core.Notifications.Emby { if (Settings.Notify) { - _mediaBrowserService.Notify(Settings, EPISODE_DOWNLOADED_TITLE_BRANDED, message.Message); + _mediaBrowserService.Notify(Settings, TRACK_DOWNLOADED_TITLE_BRANDED, message.Message); } if (Settings.UpdateLibrary) { - _mediaBrowserService.Update(Settings, message.Series); + _mediaBrowserService.Update(Settings, message.Artist); } } - public override void OnRename(Series series) + public override void OnRename(Artist artist) { if (Settings.UpdateLibrary) { - _mediaBrowserService.Update(Settings, series); + _mediaBrowserService.Update(Settings, artist); } } diff --git a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserProxy.cs b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserProxy.cs index b5e1da15a..4df933054 100644 --- a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserProxy.cs +++ b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserProxy.cs @@ -1,4 +1,4 @@ -using NLog; +using NLog; using NzbDrone.Common.Http; using NzbDrone.Common.Serializer; @@ -31,9 +31,9 @@ namespace NzbDrone.Core.Notifications.Emby ProcessRequest(request, settings); } - public void Update(MediaBrowserSettings settings, int tvdbId) + public void Update(MediaBrowserSettings settings, string mbId) { - var path = string.Format("/Library/Series/Updated?tvdbid={0}", tvdbId); + var path = string.Format("/Library/Artist/Updated?tvdbid={0}", mbId); //TODO: Get Emby to add a new Library Route var request = BuildRequest(path, settings); request.Headers.Add("Content-Length", "0"); diff --git a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs index ad1b8fba9..c39b5d1c6 100644 --- a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs +++ b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs @@ -1,16 +1,16 @@ -using System; +using System; using System.Net; using FluentValidation.Results; using NLog; using NzbDrone.Core.Rest; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications.Emby { public interface IMediaBrowserService { void Notify(MediaBrowserSettings settings, string title, string message); - void Update(MediaBrowserSettings settings, Series series); + void Update(MediaBrowserSettings settings, Artist artist); ValidationFailure Test(MediaBrowserSettings settings); } @@ -30,9 +30,9 @@ namespace NzbDrone.Core.Notifications.Emby _proxy.Notify(settings, title, message); } - public void Update(MediaBrowserSettings settings, Series series) + public void Update(MediaBrowserSettings settings, Artist artist) { - _proxy.Update(settings, series.TvdbId); + _proxy.Update(settings, artist.ForeignArtistId); } public ValidationFailure Test(MediaBrowserSettings settings) diff --git a/src/NzbDrone.Core/Notifications/NotificationBase.cs b/src/NzbDrone.Core/Notifications/NotificationBase.cs index 46cc76f60..915d1d4bf 100644 --- a/src/NzbDrone.Core/Notifications/NotificationBase.cs +++ b/src/NzbDrone.Core/Notifications/NotificationBase.cs @@ -1,18 +1,18 @@ -using System; +using System; using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications { public abstract class NotificationBase : INotification where TSettings : IProviderConfig, new() { - protected const string EPISODE_GRABBED_TITLE = "Episode Grabbed"; - protected const string EPISODE_DOWNLOADED_TITLE = "Episode Downloaded"; + protected const string ALBUM_GRABBED_TITLE = "Album Grabbed"; + protected const string TRACK_DOWNLOADED_TITLE = "Track Downloaded"; - protected const string EPISODE_GRABBED_TITLE_BRANDED = "Lidarr - " + EPISODE_GRABBED_TITLE; - protected const string EPISODE_DOWNLOADED_TITLE_BRANDED = "Lidarr - " + EPISODE_DOWNLOADED_TITLE; + protected const string ALBUM_GRABBED_TITLE_BRANDED = "Lidarr - " + ALBUM_GRABBED_TITLE; + protected const string TRACK_DOWNLOADED_TITLE_BRANDED = "Lidarr - " + TRACK_DOWNLOADED_TITLE; public abstract string Name { get; } @@ -37,7 +37,7 @@ namespace NzbDrone.Core.Notifications } - public virtual void OnRename(Series series) + public virtual void OnRename(Artist series) { } diff --git a/src/NzbDrone.Core/Notifications/NotificationService.cs b/src/NzbDrone.Core/Notifications/NotificationService.cs index 7edb106fe..52e21b622 100644 --- a/src/NzbDrone.Core/Notifications/NotificationService.cs +++ b/src/NzbDrone.Core/Notifications/NotificationService.cs @@ -8,14 +8,14 @@ using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Qualities; using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications { public class NotificationService - : IHandle, - IHandle, - IHandle + : IHandle, + IHandle, + IHandle { private readonly INotificationFactory _notificationFactory; private readonly Logger _logger; @@ -26,48 +26,43 @@ namespace NzbDrone.Core.Notifications _logger = logger; } - private string GetMessage(Series series, List episodes, QualityModel quality) + private string GetMessage(Artist artist, List albums, 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"; - } + 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 albumTitles = string.Join(" + ", albums.Select(e => e.Title)); + + return string.Format("{0} - {1} - [{4}]", + artist.Name, + albumTitles, + qualityString); + } + + private string GetTrackMessage(Artist artist, List tracks, QualityModel quality) + { + var qualityString = quality.Quality.ToString(); + + if (quality.Revision.Version > 1) + { + qualityString += " Proper"; } - 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)); + var trackTitles = string.Join(" + ", tracks.Select(e => e.Title)); - return string.Format("{0} - {1}{2} - {3} [{4}]", - series.Title, - episodes.First().SeasonNumber, - episodeNumbers, - episodeTitles, + return string.Format("{0} - {1} - [{4}]", + artist.Name, + trackTitles, qualityString); } - private bool ShouldHandleSeries(ProviderDefinition definition, Series series) + private bool ShouldHandleArtist(ProviderDefinition definition, Artist artist) { if (definition.Tags.Empty()) { @@ -75,32 +70,32 @@ namespace NzbDrone.Core.Notifications return true; } - if (definition.Tags.Intersect(series.Tags).Any()) + if (definition.Tags.Intersect(artist.Tags).Any()) { _logger.Debug("Notification and series have one or more intersecting tags."); return true; } //TODO: this message could be more clear - _logger.Debug("{0} does not have any intersecting tags with {1}. Notification will not be sent.", definition.Name, series.Title); + _logger.Debug("{0} does not have any intersecting tags with {1}. Notification will not be sent.", definition.Name, artist.Name); return false; } - public void Handle(EpisodeGrabbedEvent message) + public void Handle(AlbumGrabbedEvent 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 + Message = GetMessage(message.Album.Artist, message.Album.Albums, message.Album.ParsedAlbumInfo.Quality), + Artist = message.Album.Artist, + Quality = message.Album.ParsedAlbumInfo.Quality, + Album = message.Album }; foreach (var notification in _notificationFactory.OnGrabEnabled()) { try { - if (!ShouldHandleSeries(notification.Definition, message.Episode.Series)) continue; + if (!ShouldHandleArtist(notification.Definition, message.Album.Artist)) continue; notification.OnGrab(grabMessage); } @@ -111,20 +106,20 @@ namespace NzbDrone.Core.Notifications } } - public void Handle(EpisodeDownloadedEvent message) + public void Handle(TrackDownloadedEvent 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.Message = GetTrackMessage(message.Track.Artist, message.Track.Tracks, message.Track.Quality); + downloadMessage.Artist = message.Track.Artist; + downloadMessage.TrackFile = message.TrackFile; downloadMessage.OldFiles = message.OldFiles; - downloadMessage.SourcePath = message.Episode.Path; + downloadMessage.SourcePath = message.Track.Path; foreach (var notification in _notificationFactory.OnDownloadEnabled()) { try { - if (ShouldHandleSeries(notification.Definition, message.Episode.Series)) + if (ShouldHandleArtist(notification.Definition, message.Track.Artist)) { if (downloadMessage.OldFiles.Empty() || ((NotificationDefinition)notification.Definition).OnUpgrade) { @@ -140,15 +135,15 @@ namespace NzbDrone.Core.Notifications } } - public void Handle(SeriesRenamedEvent message) + public void Handle(ArtistRenamedEvent message) { foreach (var notification in _notificationFactory.OnRenameEnabled()) { try { - if (ShouldHandleSeries(notification.Definition, message.Series)) + if (ShouldHandleArtist(notification.Definition, message.Artist)) { - notification.OnRename(message.Series); + notification.OnRename(message.Artist); } } diff --git a/src/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroid.cs b/src/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroid.cs index 693cb6537..995d994ac 100644 --- a/src/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroid.cs +++ b/src/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroid.cs @@ -18,12 +18,12 @@ namespace NzbDrone.Core.Notifications.NotifyMyAndroid public override void OnGrab(GrabMessage grabMessage) { - _proxy.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, Settings.ApiKey, (NotifyMyAndroidPriority)Settings.Priority); + _proxy.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, Settings.ApiKey, (NotifyMyAndroidPriority)Settings.Priority); } public override void OnDownload(DownloadMessage message) { - _proxy.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, Settings.ApiKey, (NotifyMyAndroidPriority)Settings.Priority); + _proxy.SendNotification(TRACK_DOWNLOADED_TITLE, message.Message, Settings.ApiKey, (NotifyMyAndroidPriority)Settings.Priority); } public override ValidationResult Test() diff --git a/src/NzbDrone.Core/Notifications/Plex/PlexClient.cs b/src/NzbDrone.Core/Notifications/Plex/PlexClient.cs index 1294c6a40..6e1999004 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexClient.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexClient.cs @@ -19,12 +19,12 @@ namespace NzbDrone.Core.Notifications.Plex public override void OnGrab(GrabMessage grabMessage) { - _plexClientService.Notify(Settings, EPISODE_GRABBED_TITLE_BRANDED, grabMessage.Message); + _plexClientService.Notify(Settings, ALBUM_GRABBED_TITLE_BRANDED, grabMessage.Message); } public override void OnDownload(DownloadMessage message) { - _plexClientService.Notify(Settings, EPISODE_DOWNLOADED_TITLE_BRANDED, message.Message); + _plexClientService.Notify(Settings, TRACK_DOWNLOADED_TITLE_BRANDED, message.Message); } diff --git a/src/NzbDrone.Core/Notifications/Plex/PlexHomeTheater.cs b/src/NzbDrone.Core/Notifications/Plex/PlexHomeTheater.cs index c90473471..4f779bf83 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexHomeTheater.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexHomeTheater.cs @@ -24,12 +24,12 @@ namespace NzbDrone.Core.Notifications.Plex public override void OnGrab(GrabMessage grabMessage) { - Notify(Settings, EPISODE_GRABBED_TITLE_BRANDED, grabMessage.Message); + Notify(Settings, ALBUM_GRABBED_TITLE_BRANDED, grabMessage.Message); } public override void OnDownload(DownloadMessage message) { - Notify(Settings, EPISODE_DOWNLOADED_TITLE_BRANDED, message.Message); + Notify(Settings, TRACK_DOWNLOADED_TITLE_BRANDED, message.Message); } public override ValidationResult Test() diff --git a/src/NzbDrone.Core/Notifications/Plex/PlexServer.cs b/src/NzbDrone.Core/Notifications/Plex/PlexServer.cs index b691ae282..4d34cba3c 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexServer.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexServer.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; +using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications.Plex { @@ -19,19 +19,19 @@ namespace NzbDrone.Core.Notifications.Plex public override void OnDownload(DownloadMessage message) { - UpdateIfEnabled(message.Series); + UpdateIfEnabled(message.Artist); } - public override void OnRename(Series series) + public override void OnRename(Artist artist) { - UpdateIfEnabled(series); + UpdateIfEnabled(artist); } - private void UpdateIfEnabled(Series series) + private void UpdateIfEnabled(Artist artist) { if (Settings.UpdateLibrary) { - _plexServerService.UpdateLibrary(series, Settings); + _plexServerService.UpdateLibrary(artist, Settings); } } diff --git a/src/NzbDrone.Core/Notifications/Plex/PlexServerProxy.cs b/src/NzbDrone.Core/Notifications/Plex/PlexServerProxy.cs index f9206efc0..f47771395 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexServerProxy.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexServerProxy.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Net; using Newtonsoft.Json.Linq; @@ -21,7 +21,7 @@ namespace NzbDrone.Core.Notifications.Plex void UpdateSeries(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 mdId, string language, PlexServerSettings settings); } public class PlexServerProxy : IPlexServerProxy @@ -128,9 +128,9 @@ namespace NzbDrone.Core.Notifications.Plex .Preferences; } - public int? GetMetadataId(int sectionId, int tvdbId, string language, PlexServerSettings settings) + public int? GetMetadataId(int sectionId, string mbId, string language, PlexServerSettings settings) { - var guid = string.Format("com.plexapp.agents.thetvdb://{0}?lang={1}", tvdbId, language); + var guid = string.Format("com.plexapp.agents.lastfm://{0}?lang={1}", mbId, language); // TODO Plex Route for MB? LastFM? 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 62d8c4e79..b5d71416a 100644 --- a/src/NzbDrone.Core/Notifications/Plex/PlexServerService.cs +++ b/src/NzbDrone.Core/Notifications/Plex/PlexServerService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; @@ -7,13 +7,13 @@ using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Extensions; using NzbDrone.Core.Notifications.Plex.Models; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications.Plex { public interface IPlexServerService { - void UpdateLibrary(Series series, PlexServerSettings settings); + void UpdateLibrary(Artist artist, PlexServerSettings settings); ValidationFailure Test(PlexServerSettings settings); } @@ -32,7 +32,7 @@ namespace NzbDrone.Core.Notifications.Plex _logger = logger; } - public void UpdateLibrary(Series series, PlexServerSettings settings) + public void UpdateLibrary(Artist artist, PlexServerSettings settings) { try { @@ -46,7 +46,7 @@ namespace NzbDrone.Core.Notifications.Plex if (partialUpdates) { - UpdatePartialSection(series, sections, settings); + UpdatePartialSection(artist, sections, settings); } else @@ -130,17 +130,17 @@ namespace NzbDrone.Core.Notifications.Plex _plexServerProxy.Update(sectionId, settings); } - private void UpdatePartialSection(Series series, List sections, PlexServerSettings settings) + private void UpdatePartialSection(Artist artist, 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, artist, section.Language, settings); if (metadataId.HasValue) { - _logger.Debug("Updating Plex host: {0}, Section: {1}, Series: {2}", settings.Host, section.Id, series); + _logger.Debug("Updating Plex host: {0}, Section: {1}, Artist: {2}", settings.Host, section.Id, artist); _plexServerProxy.UpdateSeries(metadataId.Value, settings); partiallyUpdated = true; @@ -150,16 +150,16 @@ namespace NzbDrone.Core.Notifications.Plex // Only update complete sections if all partial updates failed if (!partiallyUpdated) { - _logger.Debug("Unable to update partial section, updating all TV sections"); + _logger.Debug("Unable to update partial section, updating all Music sections"); sections.ForEach(s => UpdateSection(s.Id, settings)); } } - private int? GetMetadataId(int sectionId, Series series, string language, PlexServerSettings settings) + private int? GetMetadataId(int sectionId, Artist artist, 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 series: {1}", settings.Host, artist); - return _plexServerProxy.GetMetadataId(sectionId, series.TvdbId, language, settings); + return _plexServerProxy.GetMetadataId(sectionId, artist.ForeignArtistId, language, settings); } public ValidationFailure Test(PlexServerSettings settings) @@ -170,7 +170,7 @@ namespace NzbDrone.Core.Notifications.Plex if (sections.Empty()) { - return new ValidationFailure("Host", "At least one TV library is required"); + return new ValidationFailure("Host", "At least one Music library is required"); } } catch(PlexAuthenticationException ex) diff --git a/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs b/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs index 2b6352073..01911f2e6 100644 --- a/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs +++ b/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs @@ -20,12 +20,12 @@ namespace NzbDrone.Core.Notifications.Prowl public override void OnGrab(GrabMessage grabMessage) { - _prowlService.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, Settings.ApiKey, (NotificationPriority)Settings.Priority); + _prowlService.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, Settings.ApiKey, (NotificationPriority)Settings.Priority); } public override void OnDownload(DownloadMessage message) { - _prowlService.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, Settings.ApiKey, (NotificationPriority)Settings.Priority); + _prowlService.SendNotification(TRACK_DOWNLOADED_TITLE, message.Message, Settings.ApiKey, (NotificationPriority)Settings.Priority); } public override ValidationResult Test() diff --git a/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs b/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs index 066cd6f57..aee178a50 100644 --- a/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs +++ b/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs @@ -19,12 +19,12 @@ namespace NzbDrone.Core.Notifications.PushBullet public override void OnGrab(GrabMessage grabMessage) { - _proxy.SendNotification(EPISODE_GRABBED_TITLE_BRANDED, grabMessage.Message, Settings); + _proxy.SendNotification(ALBUM_GRABBED_TITLE_BRANDED, grabMessage.Message, Settings); } public override void OnDownload(DownloadMessage message) { - _proxy.SendNotification(EPISODE_DOWNLOADED_TITLE_BRANDED, message.Message, Settings); + _proxy.SendNotification(TRACK_DOWNLOADED_TITLE_BRANDED, message.Message, Settings); } public override ValidationResult Test() diff --git a/src/NzbDrone.Core/Notifications/Pushalot/Pushalot.cs b/src/NzbDrone.Core/Notifications/Pushalot/Pushalot.cs index c505034b8..0d888c5f8 100644 --- a/src/NzbDrone.Core/Notifications/Pushalot/Pushalot.cs +++ b/src/NzbDrone.Core/Notifications/Pushalot/Pushalot.cs @@ -19,12 +19,12 @@ namespace NzbDrone.Core.Notifications.Pushalot public override void OnGrab(GrabMessage grabMessage) { - _proxy.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, Settings); + _proxy.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, Settings); } public override void OnDownload(DownloadMessage message) { - _proxy.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, Settings); + _proxy.SendNotification(TRACK_DOWNLOADED_TITLE, message.Message, Settings); } diff --git a/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs b/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs index 0b7349d71..6755d77c0 100644 --- a/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs +++ b/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs @@ -18,12 +18,12 @@ namespace NzbDrone.Core.Notifications.Pushover public override void OnGrab(GrabMessage grabMessage) { - _proxy.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, Settings); + _proxy.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, Settings); } public override void OnDownload(DownloadMessage message) { - _proxy.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, Settings); + _proxy.SendNotification(TRACK_DOWNLOADED_TITLE, message.Message, Settings); } public override ValidationResult Test() diff --git a/src/NzbDrone.Core/Notifications/Slack/Slack.cs b/src/NzbDrone.Core/Notifications/Slack/Slack.cs index 2d4b5ae43..307ce9616 100644 --- a/src/NzbDrone.Core/Notifications/Slack/Slack.cs +++ b/src/NzbDrone.Core/Notifications/Slack/Slack.cs @@ -1,11 +1,11 @@ -using System; +using System; using System.Collections.Generic; using FluentValidation.Results; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.Notifications.Slack.Payloads; using NzbDrone.Core.Rest; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Core.Validation; using RestSharp; @@ -36,7 +36,7 @@ namespace NzbDrone.Core.Notifications.Slack new Attachment { Fallback = message.Message, - Title = message.Series.Title, + Title = message.Artist.Name, Text = message.Message, Color = "warning" } @@ -58,7 +58,7 @@ namespace NzbDrone.Core.Notifications.Slack new Attachment { Fallback = message.Message, - Title = message.Series.Title, + Title = message.Artist.Name, Text = message.Message, Color = "good" } @@ -68,7 +68,7 @@ namespace NzbDrone.Core.Notifications.Slack NotifySlack(payload); } - public override void OnRename(Series series) + public override void OnRename(Artist artist) { var payload = new SlackPayload { @@ -79,7 +79,7 @@ namespace NzbDrone.Core.Notifications.Slack { new Attachment { - Title = series.Title, + Title = artist.Name, } } }; diff --git a/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs b/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs index 7006b8d29..8631f030d 100644 --- a/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs +++ b/src/NzbDrone.Core/Notifications/Synology/SynologyIndexer.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using FluentValidation.Results; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications.Synology { @@ -26,24 +26,24 @@ namespace NzbDrone.Core.Notifications.Synology { foreach (var oldFile in message.OldFiles) { - var fullPath = Path.Combine(message.Series.Path, oldFile.RelativePath); + var fullPath = Path.Combine(message.Artist.Path, oldFile.RelativePath); _indexerProxy.DeleteFile(fullPath); } { - var fullPath = Path.Combine(message.Series.Path, message.EpisodeFile.RelativePath); + var fullPath = Path.Combine(message.Artist.Path, message.TrackFile.RelativePath); _indexerProxy.AddFile(fullPath); } } } - public override void OnRename(Series series) + public override void OnRename(Artist artist) { if (Settings.UpdateLibrary) { - _indexerProxy.UpdateFolder(series.Path); + _indexerProxy.UpdateFolder(artist.Path); } } diff --git a/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs b/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs index 83648e9f2..e44308bb7 100644 --- a/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs +++ b/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs @@ -18,12 +18,12 @@ namespace NzbDrone.Core.Notifications.Telegram public override void OnGrab(GrabMessage grabMessage) { - _proxy.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, Settings); + _proxy.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, Settings); } public override void OnDownload(DownloadMessage message) { - _proxy.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, Settings); + _proxy.SendNotification(TRACK_DOWNLOADED_TITLE, message.Message, Settings); } public override ValidationResult Test() diff --git a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs index 15f4ff00e..969519bbb 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs @@ -1,7 +1,7 @@ - + using System.Collections.Generic; using FluentValidation.Results; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Common.Extensions; namespace NzbDrone.Core.Notifications.Webhook @@ -19,17 +19,17 @@ namespace NzbDrone.Core.Notifications.Webhook public override void OnGrab(GrabMessage message) { - _service.OnGrab(message.Series, message.Episode, message.Quality, Settings); + _service.OnGrab(message.Artist, message.Album, message.Quality, Settings); } public override void OnDownload(DownloadMessage message) { - _service.OnDownload(message.Series, message.EpisodeFile, Settings); + _service.OnDownload(message.Artist, message.TrackFile, Settings); } - public override void OnRename(Series series) + public override void OnRename(Artist artist) { - _service.OnRename(series, Settings); + _service.OnRename(artist, Settings); } public override string Name => "Webhook"; diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookAlbum.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookAlbum.cs new file mode 100644 index 000000000..433bb7370 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookAlbum.cs @@ -0,0 +1,26 @@ +using NzbDrone.Core.Music; +using System; + +namespace NzbDrone.Core.Notifications.Webhook +{ + public class WebhookAlbum + { + public WebhookAlbum() { } + + public WebhookAlbum(Album album) + { + Id = album.Id; + Title = album.Title; + ReleaseDate = album.ReleaseDate; + } + + public int Id { get; set; } + public string Title { get; set; } + public DateTime? ReleaseDate { get; set; } + + public string Quality { get; set; } + public int QualityVersion { get; set; } + public string ReleaseGroup { get; set; } + public string SceneName { get; set; } + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookArtist.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookArtist.cs new file mode 100644 index 000000000..45f92c142 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookArtist.cs @@ -0,0 +1,22 @@ +using NzbDrone.Core.Music; + +namespace NzbDrone.Core.Notifications.Webhook +{ + public class WebhookArtist + { + public int Id { get; set; } + public string Title { get; set; } + public string Path { get; set; } + public string MBId { get; set; } + + public WebhookArtist() { } + + public WebhookArtist(Artist artist) + { + Id = artist.Id; + Title = artist.Name; + Path = artist.Path; + MBId = artist.ForeignArtistId; + } + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs deleted file mode 100644 index a7979b726..000000000 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs +++ /dev/null @@ -1,32 +0,0 @@ -using NzbDrone.Core.Tv; -using System; - -namespace NzbDrone.Core.Notifications.Webhook -{ - public class WebhookEpisode - { - public WebhookEpisode() { } - - public WebhookEpisode(Episode episode) - { - Id = episode.Id; - SeasonNumber = episode.SeasonNumber; - EpisodeNumber = episode.EpisodeNumber; - Title = episode.Title; - AirDate = episode.AirDate; - AirDateUtc = episode.AirDateUtc; - } - - public int Id { get; set; } - public int EpisodeNumber { get; set; } - public int SeasonNumber { get; set; } - public string Title { get; set; } - public string AirDate { get; set; } - public DateTime? AirDateUtc { get; set; } - - public string Quality { get; set; } - public int QualityVersion { get; set; } - public string ReleaseGroup { get; set; } - public string SceneName { get; set; } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs index 41009a695..f480c185d 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs @@ -1,11 +1,11 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace NzbDrone.Core.Notifications.Webhook { public class WebhookPayload { public string EventType { get; set; } - public WebhookSeries Series { get; set; } - public List Episodes { get; set; } + public WebhookArtist Artist { get; set; } + public List Albums { get; set; } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookSeries.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookSeries.cs deleted file mode 100644 index 222f9eebb..000000000 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookSeries.cs +++ /dev/null @@ -1,22 +0,0 @@ -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Notifications.Webhook -{ - public class WebhookSeries - { - public int Id { get; set; } - public string Title { get; set; } - public string Path { get; set; } - public int TvdbId { get; set; } - - public WebhookSeries() { } - - public WebhookSeries(Series series) - { - Id = series.Id; - Title = series.Title; - Path = series.Path; - TvdbId = series.TvdbId; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookService.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookService.cs index b04efa168..41654297c 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookService.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookService.cs @@ -1,6 +1,6 @@ -using FluentValidation.Results; +using FluentValidation.Results; using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; using NzbDrone.Core.Validation; using NzbDrone.Core.Rest; using RestSharp; @@ -12,53 +12,53 @@ namespace NzbDrone.Core.Notifications.Webhook { public interface IWebhookService { - void OnDownload(Series series, EpisodeFile episodeFile, WebhookSettings settings); - void OnRename(Series series, WebhookSettings settings); - void OnGrab(Series series, RemoteEpisode episode, QualityModel quality, WebhookSettings settings); + void OnDownload(Artist artist, TrackFile trackFile, WebhookSettings settings); + void OnRename(Artist artist, WebhookSettings settings); + void OnGrab(Artist artist, RemoteAlbum album, QualityModel quality, WebhookSettings settings); ValidationFailure Test(WebhookSettings settings); } public class WebhookService : IWebhookService { - public void OnDownload(Series series, EpisodeFile episodeFile, WebhookSettings settings) + public void OnDownload(Artist artist, TrackFile trackFile, WebhookSettings settings) { var payload = new WebhookPayload { EventType = "Download", - Series = new WebhookSeries(series), - Episodes = episodeFile.Episodes.Value.ConvertAll(x => new WebhookEpisode(x) { - Quality = episodeFile.Quality.Quality.Name, - QualityVersion = episodeFile.Quality.Revision.Version, - ReleaseGroup = episodeFile.ReleaseGroup, - SceneName = episodeFile.SceneName + Artist = new WebhookArtist(artist), + Albums = trackFile.Tracks.Value.ConvertAll(x => new WebhookAlbum(x.Album) { + Quality = trackFile.Quality.Quality.Name, + QualityVersion = trackFile.Quality.Revision.Version, + ReleaseGroup = trackFile.ReleaseGroup, + SceneName = trackFile.SceneName }) }; NotifyWebhook(payload, settings); } - public void OnRename(Series series, WebhookSettings settings) + public void OnRename(Artist artist, WebhookSettings settings) { var payload = new WebhookPayload { EventType = "Rename", - Series = new WebhookSeries(series) + Artist = new WebhookArtist(artist) }; NotifyWebhook(payload, settings); } - public void OnGrab(Series series, RemoteEpisode episode, QualityModel quality, WebhookSettings settings) + public void OnGrab(Artist artist, RemoteAlbum album, QualityModel quality, WebhookSettings settings) { var payload = new WebhookPayload { EventType = "Grab", - Series = new WebhookSeries(series), - Episodes = episode.Episodes.ConvertAll(x => new WebhookEpisode(x) + Artist = new WebhookArtist(artist), + Albums = album.Albums.ConvertAll(x => new WebhookAlbum(x) { Quality = quality.Quality.Name, QualityVersion = quality.Revision.Version, - ReleaseGroup = episode.ParsedEpisodeInfo.ReleaseGroup + ReleaseGroup = album.ParsedAlbumInfo.ReleaseGroup }) }; NotifyWebhook(payload, settings); @@ -87,19 +87,17 @@ namespace NzbDrone.Core.Notifications.Webhook new WebhookPayload { EventType = "Test", - Series = new WebhookSeries() + Artist = new WebhookArtist() { Id = 1, Title = "Test Title", Path = "C:\\testpath", - TvdbId = 1234 + MBId = "1234" }, - Episodes = new List() { - new WebhookEpisode() + Albums = new List() { + new WebhookAlbum() { Id = 123, - EpisodeNumber = 1, - SeasonNumber = 1, Title = "Test title" } } diff --git a/src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs b/src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs index e1481fdae..564cdc397 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -6,7 +6,7 @@ using System.Xml.Linq; using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Notifications.Xbmc.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications.Xbmc { @@ -34,7 +34,7 @@ namespace NzbDrone.Core.Notifications.Xbmc SendCommand(settings, command); } - public void Update(XbmcSettings settings, Series series) + public void Update(XbmcSettings settings, Artist artist) { if (!settings.AlwaysUpdate) { @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Notifications.Xbmc } } - UpdateLibrary(settings, series); + UpdateLibrary(settings, artist); } public void Clean(XbmcSettings settings) @@ -80,12 +80,12 @@ namespace NzbDrone.Core.Notifications.Xbmc return new List(); } - internal string GetSeriesPath(XbmcSettings settings, Series series) + internal string GetSeriesPath(XbmcSettings settings, Artist artist) { 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); + artist.ForeignArtistId); var command = string.Format("QueryVideoDatabase({0})", query); const string setResponseCommand = @@ -137,17 +137,17 @@ namespace NzbDrone.Core.Notifications.Xbmc return false; } - private void UpdateLibrary(XbmcSettings settings, Series series) + private void UpdateLibrary(XbmcSettings settings, Artist artist) { try { _logger.Debug("Sending Update DB Request to XBMC Host: {0}", settings.Address); - var xbmcSeriesPath = GetSeriesPath(settings, series); + var xbmcSeriesPath = GetSeriesPath(settings, artist); //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); + _logger.Debug("Updating artist [{0}] on XBMC host: {1}", artist, settings.Address); var command = BuildExecBuiltInCommand(string.Format("UpdateLibrary(video,{0})", xbmcSeriesPath)); SendCommand(settings, command); } @@ -155,7 +155,7 @@ namespace NzbDrone.Core.Notifications.Xbmc else { //Update the entire library - _logger.Debug("Series [{0}] doesn't exist on XBMC host: {1}, Updating Entire Library", series, settings.Address); + _logger.Debug("Artist [{0}] doesn't exist on XBMC host: {1}, Updating Entire Library", artist, settings.Address); var command = BuildExecBuiltInCommand("UpdateLibrary(video)"); SendCommand(settings, command); } diff --git a/src/NzbDrone.Core/Notifications/Xbmc/IApiProvider.cs b/src/NzbDrone.Core/Notifications/Xbmc/IApiProvider.cs index bf250edc3..4c93ac123 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/IApiProvider.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/IApiProvider.cs @@ -1,12 +1,12 @@ -using NzbDrone.Core.Notifications.Xbmc.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Notifications.Xbmc.Model; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications.Xbmc { public interface IApiProvider { void Notify(XbmcSettings settings, string title, string message); - void Update(XbmcSettings settings, Series series); + void Update(XbmcSettings settings, Artist artist); 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 1a0674908..b61830ffc 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs @@ -1,9 +1,9 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using NLog; using NzbDrone.Core.Notifications.Xbmc.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications.Xbmc { @@ -28,7 +28,7 @@ namespace NzbDrone.Core.Notifications.Xbmc _proxy.Notify(settings, title, message); } - public void Update(XbmcSettings settings, Series series) + public void Update(XbmcSettings settings, Artist artist) { if (!settings.AlwaysUpdate) { @@ -42,7 +42,7 @@ namespace NzbDrone.Core.Notifications.Xbmc } } - UpdateLibrary(settings, series); + UpdateLibrary(settings, artist); } public void Clean(XbmcSettings settings) @@ -55,22 +55,22 @@ namespace NzbDrone.Core.Notifications.Xbmc return _proxy.GetActivePlayers(settings); } - public string GetSeriesPath(XbmcSettings settings, Series series) + public string GetSeriesPath(XbmcSettings settings, Artist artist) { - var allSeries = _proxy.GetSeries(settings); + var allSeries = _proxy.GetArtist(settings); if (!allSeries.Any()) { - _logger.Debug("No TV shows returned from XBMC"); + _logger.Debug("No Artists returned from XBMC"); return null; } var matchingSeries = allSeries.FirstOrDefault(s => { - var tvdbId = 0; - int.TryParse(s.ImdbNumber, out tvdbId); + var tvdbId = "0"; + //int.TryParse(s.ImdbNumber, out tvdbId); - return tvdbId == series.TvdbId || s.Label == series.Title; + return tvdbId == artist.ForeignArtistId || s.Label == artist.Name; }); if (matchingSeries != null) return matchingSeries.File; @@ -78,20 +78,20 @@ namespace NzbDrone.Core.Notifications.Xbmc return null; } - private void UpdateLibrary(XbmcSettings settings, Series series) + private void UpdateLibrary(XbmcSettings settings, Artist artist) { try { - var seriesPath = GetSeriesPath(settings, series); + var seriesPath = GetSeriesPath(settings, artist); if (seriesPath != null) { - _logger.Debug("Updating series {0} (Path: {1}) on XBMC host: {2}", series, seriesPath, settings.Address); + _logger.Debug("Updating artist {0} (Path: {1}) on XBMC host: {2}", artist, seriesPath, settings.Address); } else { - _logger.Debug("Series {0} doesn't exist on XBMC host: {1}, Updating Entire Library", series, + _logger.Debug("Artist {0} doesn't exist on XBMC host: {1}, Updating Entire Library", artist, settings.Address); } diff --git a/src/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs b/src/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs index 9bb87f474..e5aaf6b44 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs @@ -1,10 +1,10 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Net.Sockets; using FluentValidation.Results; using NLog; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications.Xbmc { @@ -33,12 +33,12 @@ namespace NzbDrone.Core.Notifications.Xbmc const string header = "Lidarr - Downloaded"; Notify(Settings, header, message.Message); - UpdateAndClean(message.Series, message.OldFiles.Any()); + UpdateAndClean(message.Artist, message.OldFiles.Any()); } - public override void OnRename(Series series) + public override void OnRename(Artist artist) { - UpdateAndClean(series); + UpdateAndClean(artist); } public override string Name => "Kodi (XBMC)"; @@ -68,13 +68,13 @@ namespace NzbDrone.Core.Notifications.Xbmc } } - private void UpdateAndClean(Series series, bool clean = true) + private void UpdateAndClean(Artist artist, bool clean = true) { try { if (Settings.UpdateLibrary) { - _xbmcService.Update(Settings, series); + _xbmcService.Update(Settings, artist); } if (clean && Settings.CleanLibrary) diff --git a/src/NzbDrone.Core/Notifications/Xbmc/XbmcJsonApiProxy.cs b/src/NzbDrone.Core/Notifications/Xbmc/XbmcJsonApiProxy.cs index a4ee40549..5d5f42386 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/XbmcJsonApiProxy.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/XbmcJsonApiProxy.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Serializer; @@ -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 GetArtist(XbmcSettings settings); } public class XbmcJsonApiProxy : IXbmcJsonApiProxy @@ -79,7 +79,7 @@ namespace NzbDrone.Core.Notifications.Xbmc return Json.Deserialize(response).Result; } - public List GetSeries(XbmcSettings settings) + public List GetArtist(XbmcSettings settings) { var request = new RestRequest(); var parameters = new Dictionary(); diff --git a/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs b/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs index d9cacf8f8..040b1a269 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using FluentValidation.Results; @@ -7,14 +7,14 @@ using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Serializer; using NzbDrone.Core.Notifications.Xbmc.Model; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications.Xbmc { public interface IXbmcService { void Notify(XbmcSettings settings, string title, string message); - void Update(XbmcSettings settings, Series series); + void Update(XbmcSettings settings, Artist artist); void Clean(XbmcSettings settings); ValidationFailure Test(XbmcSettings settings, string message); } @@ -45,10 +45,10 @@ namespace NzbDrone.Core.Notifications.Xbmc provider.Notify(settings, title, message); } - public void Update(XbmcSettings settings, Series series) + public void Update(XbmcSettings settings, Artist artist) { var provider = GetApiProvider(settings); - provider.Update(settings, series); + provider.Update(settings, artist); } public void Clean(XbmcSettings settings) @@ -122,4 +122,4 @@ namespace NzbDrone.Core.Notifications.Xbmc return null; } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 7d67bb9c8..2ac10de77 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -936,11 +936,11 @@ - + - +