diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/ActivePlayersFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/ActivePlayersFixture.cs index bf5f4de2b..1cb41de43 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/ActivePlayersFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/ActivePlayersFixture.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using FluentAssertions; using NUnit.Framework; using NzbDrone.Common.Http; @@ -23,7 +23,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http 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" + + "
  • PlayStatus:Playing
  • VideoNo:0
  • Type:Audio
  • Thumb:special://masterprofile/Thumbnails/Video/a/auto-a664d5a2.tbn" + "
  • Time:00:06
  • Duration:21:35
  • Percentage:0
  • File size:183182590
  • Changed:True"; Mocker.GetMock() @@ -57,14 +57,14 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http } [Test] - public void should_have_active_video_player() + public void should_have_active_audio_player() { WithVideoPlayerActive(); var result = Subject.GetActivePlayers(_settings); result.Should().HaveCount(1); - result.First().Type.Should().Be("video"); + result.First().Type.Should().Be("audio"); } } } diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/GetSeriesPathFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/GetArtistPathFixture.cs similarity index 63% rename from src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/GetSeriesPathFixture.cs rename to src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/GetArtistPathFixture.cs index 7b48db3de..37c292379 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/GetSeriesPathFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/GetArtistPathFixture.cs @@ -8,7 +8,7 @@ using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http { [TestFixture] - public class GetSeriesPathFixture : CoreTest + public class GetArtistPathFixture : CoreTest { private XbmcSettings _settings; private Artist _artist; @@ -29,8 +29,8 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http _artist = new Artist { - ForeignArtistId = "123d45d-d154f5d-1f5d1-5df18d5", - Name = "30 Rock" + ForeignArtistId = "9f4e41c3-2648-428e-b8c7-dc10465b49ac", + Name = "Shawn Desman" }; const string setResponseUrl = "http://localhost:8080/xbmcCmds/xbmcHttp?command=SetResponseFormat(webheader;false;webfooter;false;header;;footer;;opentag;;closetag;;closefinaltag;false)"; @@ -48,47 +48,47 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http } [Test] - public void should_get_series_path() + public void should_get_artist_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)"); + const string queryResult = @"smb://xbmc:xbmc@HOMESERVER/Music/Shawn Desman/"; + var query = string.Format("http://localhost:8080/xbmcCmds/xbmcHttp?command=QueryMusicDatabase(select path.strPath from path, artist, artistlinkpath where artist.c12 = 9f4e41c3-2648-428e-b8c7-dc10465b49ac and artistlinkpath.idArtist = artist.idArtist and artistlinkpath.idPath = path.idPath)"); Mocker.GetMock() .Setup(s => s.DownloadString(query, _settings.Username, _settings.Password)) .Returns(queryResult); - Subject.GetSeriesPath(_settings, _artist) - .Should().Be("smb://xbmc:xbmc@HOMESERVER/TV/30 Rock/"); + Subject.GetArtistPath(_settings, _artist) + .Should().Be("smb://xbmc:xbmc@HOMESERVER/Music/Shawn Desman/"); } [Test] - public void should_get_null_for_series_path() + public void should_get_null_for_artist_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)"); + var query = string.Format("http://localhost:8080/xbmcCmds/xbmcHttp?command=QueryMusicDatabase(select path.strPath from path, artist, artistlinkpath where artist.c12 = 9f4e41c3-2648-428e-b8c7-dc10465b49ac and artistlinkpath.idArtist = artist.idArtist and artistlinkpath.idPath = path.idPath)"); Mocker.GetMock() .Setup(s => s.DownloadString(query, _settings.Username, _settings.Password)) .Returns(queryResult); - Subject.GetSeriesPath(_settings, _artist) + Subject.GetArtistPath(_settings, _artist) .Should().BeNull(); } [Test] - public void should_get_series_path_with_special_characters_in_it() + public void should_get_artist_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)"); + const string queryResult = @"smb://xbmc:xbmc@HOMESERVER/Music/-wumpscut-/"; + var query = string.Format("http://localhost:8080/xbmcCmds/xbmcHttp?command=QueryMusicDatabase(select path.strPath from path, artist, artistlinkpath where artist.c12 = 9f4e41c3-2648-428e-b8c7-dc10465b49ac and artistlinkpath.idArtist = artist.idArtist and artistlinkpath.idPath = path.idPath)"); Mocker.GetMock() .Setup(s => s.DownloadString(query, _settings.Username, _settings.Password)) .Returns(queryResult); - Subject.GetSeriesPath(_settings, _artist) - .Should().Be("smb://xbmc:xbmc@HOMESERVER/TV/Law & Order- Special Victims Unit/"); + Subject.GetArtistPath(_settings, _artist) + .Should().Be("smb://xbmc:xbmc@HOMESERVER/Music/-wumpscut-/"); } } } diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/UpdateFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/UpdateFixture.cs index d11ab4ad4..7b780f725 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/UpdateFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Http/UpdateFixture.cs @@ -11,8 +11,8 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http 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 Artist _fakeSeries; + private string _artistQueryUrl = "http://localhost:8080/xbmcCmds/xbmcHttp?command=QueryMusicDatabase(select path.strPath from path, artist, artistlinkpath where artist.c12 = 9f4e41c3-2648-428e-b8c7-dc10465b49ac and artistlinkpath.idArtist = artist.idArtist and artistlinkpath.idPath = path.idPath)"; + private Artist _fakeArtist; [SetUp] public void Setup() @@ -28,47 +28,47 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http UpdateLibrary = true }; - _fakeSeries = Builder.CreateNew() - .With(s => s.ForeignArtistId = "79488") - .With(s => s.Name = "30 Rock") + _fakeArtist = Builder.CreateNew() + .With(s => s.ForeignArtistId = "9f4e41c3-2648-428e-b8c7-dc10465b49ac") + .With(s => s.Name = "Shawn Desman") .Build(); } - private void WithSeriesPath() + private void WithArtistPath() { Mocker.GetMock() - .Setup(s => s.DownloadString(_seriesQueryUrl, _settings.Username, _settings.Password)) - .Returns("smb://xbmc:xbmc@HOMESERVER/TV/30 Rock/"); + .Setup(s => s.DownloadString(_artistQueryUrl, _settings.Username, _settings.Password)) + .Returns("smb://xbmc:xbmc@HOMESERVER/Music/Shawn Desman/"); } - private void WithoutSeriesPath() + private void WithoutArtistPath() { Mocker.GetMock() - .Setup(s => s.DownloadString(_seriesQueryUrl, _settings.Username, _settings.Password)) + .Setup(s => s.DownloadString(_artistQueryUrl, _settings.Username, _settings.Password)) .Returns(""); } [Test] - public void should_update_using_series_path() + public void should_update_using_artist_path() { - WithSeriesPath(); - const string url = "http://localhost:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(video,smb://xbmc:xbmc@HOMESERVER/TV/30 Rock/))"; + WithArtistPath(); + const string url = "http://localhost:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(music,smb://xbmc:xbmc@HOMESERVER/Music/Shawn Desman/))"; Mocker.GetMock().Setup(s => s.DownloadString(url, _settings.Username, _settings.Password)); - Subject.Update(_settings, _fakeSeries); + Subject.Update(_settings, _fakeArtist); Mocker.VerifyAllMocks(); } [Test] - public void should_update_all_paths_when_series_path_not_found() + public void should_update_all_paths_when_artist_path_not_found() { - WithoutSeriesPath(); - const string url = "http://localhost:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(video))"; + WithoutArtistPath(); + const string url = "http://localhost:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(music))"; Mocker.GetMock().Setup(s => s.DownloadString(url, _settings.Username, _settings.Password)); - Subject.Update(_settings, _fakeSeries); + Subject.Update(_settings, _fakeArtist); Mocker.VerifyAllMocks(); } } diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetSeriesPathFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetArtistPathFixture.cs similarity index 50% rename from src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetSeriesPathFixture.cs rename to src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetArtistPathFixture.cs index 650939619..19e62a0cb 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetSeriesPathFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/GetArtistPathFixture.cs @@ -11,12 +11,12 @@ using NzbDrone.Core.Music; namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json { [TestFixture] - public class GetSeriesPathFixture : CoreTest + public class GetArtistPathFixture : CoreTest { - private const string MB_ID = "5"; + private const string MB_ID = "9f4e41c3-2648-428e-b8c7-dc10465b49ac"; private XbmcSettings _settings; - private Artist _artist; - private List _xbmcSeries; + private Music.Artist _artist; + private List _xbmcArtist; [SetUp] public void Setup() @@ -24,25 +24,25 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json _settings = Builder.CreateNew() .Build(); - _xbmcSeries = Builder.CreateListOfSize(3) + _xbmcArtist = Builder.CreateListOfSize(3) .All() - .With(s => s.ImdbNumber = "0") + .With(s => s.MusicbrainzArtistId = new List{"0"}) .TheFirst(1) - .With(s => s.ImdbNumber = MB_ID.ToString()) + .With(s => s.MusicbrainzArtistId = new List {MB_ID.ToString()}) .Build() .ToList(); Mocker.GetMock() .Setup(s => s.GetArtist(_settings)) - .Returns(_xbmcSeries); + .Returns(_xbmcArtist); } - private void GivenMatchingTvdbId() + private void GivenMatchingMusicbrainzId() { _artist = new Artist { ForeignArtistId = MB_ID, - Name = "TV Show" + Name = "Artist" }; } @@ -51,11 +51,11 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json _artist = new Artist { ForeignArtistId = "1000", - Name = _xbmcSeries.First().Label + Name = _xbmcArtist.First().Label }; } - private void GivenMatchingSeries() + private void GivenMatchingArtist() { _artist = new Artist { @@ -65,19 +65,19 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json } [Test] - public void should_return_null_when_series_is_not_found() + public void should_return_null_when_artist_is_not_found() { - GivenMatchingSeries(); + GivenMatchingArtist(); - Subject.GetSeriesPath(_settings, _artist).Should().BeNull(); + Subject.GetArtistPath(_settings, _artist).Should().BeNull(); } [Test] - public void should_return_path_when_tvdbId_matches() + public void should_return_path_when_musicbrainzId_matches() { - GivenMatchingTvdbId(); + GivenMatchingMusicbrainzId(); - Subject.GetSeriesPath(_settings, _artist).Should().Be(_xbmcSeries.First().File); + Subject.GetArtistPath(_settings, _artist).Should().Be(_xbmcArtist.First().File); } [Test] @@ -85,22 +85,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json { GivenMatchingTitle(); - Subject.GetSeriesPath(_settings, _artist).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 = MB_ID.ToString(); - - Mocker.GetMock() - .Setup(s => s.GetArtist(_settings)) - .Returns(_xbmcSeries); - - Subject.GetSeriesPath(_settings, _artist).Should().NotBeNull(); + Subject.GetArtistPath(_settings, _artist).Should().Be(_xbmcArtist.First().File); } } } diff --git a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateFixture.cs index 4e84fbd0c..32d247242 100644 --- a/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateFixture.cs +++ b/src/NzbDrone.Core.Test/NotificationTests/Xbmc/Json/UpdateFixture.cs @@ -13,9 +13,9 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json [TestFixture] public class UpdateFixture : CoreTest { - private const string MB_ID = "5"; + private const string MB_ID = "9f4e41c3-2648-428e-b8c7-dc10465b49ac"; private XbmcSettings _settings; - private List _xbmcArtist; + private List _xbmcArtist; [SetUp] public void Setup() @@ -23,9 +23,9 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json _settings = Builder.CreateNew() .Build(); - _xbmcArtist = Builder.CreateListOfSize(3) + _xbmcArtist = Builder.CreateListOfSize(3) .TheFirst(1) - .With(s => s.ImdbNumber = MB_ID.ToString()) + .With(s => s.MusicbrainzArtistId = new List { MB_ID.ToString()}) .Build() .ToList(); @@ -39,27 +39,27 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json } [Test] - public void should_update_using_series_path() + public void should_update_using_artist_path() { - var series = Builder.CreateNew() + var artist = Builder.CreateNew() .With(s => s.ForeignArtistId = MB_ID) .Build(); - Subject.Update(_settings, series); + Subject.Update(_settings, artist); Mocker.GetMock() .Verify(v => v.UpdateLibrary(_settings, It.IsAny()), Times.Once()); } [Test] - public void should_update_all_paths_when_series_path_not_found() + public void should_update_all_paths_when_artist_path_not_found() { - var fakeSeries = Builder.CreateNew() - .With(s => s.ForeignArtistId = "1000") - .With(s => s.Name = "Not 30 Rock") + var fakeArtist = Builder.CreateNew() + .With(s => s.ForeignArtistId = "9f4e41c3-2648-428e-b8c7-dc10465b49ad") + .With(s => s.Name = "Not Shawn Desman") .Build(); - Subject.Update(_settings, fakeSeries); + Subject.Update(_settings, fakeArtist); Mocker.GetMock() .Verify(v => v.UpdateLibrary(_settings, null), Times.Once()); diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 62130c46a..63cce569f 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -305,9 +305,9 @@ - + - + diff --git a/src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs b/src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs index 564cdc397..080aa29b5 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs @@ -41,9 +41,9 @@ namespace NzbDrone.Core.Notifications.Xbmc _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"))) + if (activePlayers.Any(a => a.Type.Equals("audio"))) { - _logger.Debug("Video is currently playing, skipping library update"); + _logger.Debug("Audio is currently playing, skipping library update"); return; } } @@ -53,8 +53,8 @@ namespace NzbDrone.Core.Notifications.Xbmc public void Clean(XbmcSettings settings) { - const string cleanVideoLibrary = "CleanLibrary(video)"; - var command = BuildExecBuiltInCommand(cleanVideoLibrary); + const string cleanMusicLibrary = "CleanLibrary(music)"; + var command = BuildExecBuiltInCommand(cleanMusicLibrary); SendCommand(settings, command); } @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Notifications.Xbmc 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")); + if (response.Contains("
  • Type:Audio")) result.Add(new ActivePlayer(1, "audio")); return result; } @@ -80,13 +80,13 @@ namespace NzbDrone.Core.Notifications.Xbmc return new List(); } - internal string GetSeriesPath(XbmcSettings settings, Artist artist) + internal string GetArtistPath(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", + "select path.strPath from path, artist, artistlinkpath where artist.c12 = {0} and artistlinkpath.idArtist = artist.idArtist and artistlinkpath.idPath = path.idPath", artist.ForeignArtistId); - var command = string.Format("QueryVideoDatabase({0})", query); + var command = string.Format("QueryMusicDatabase({0})", query); const string setResponseCommand = "SetResponseFormat(webheader;false;webfooter;false;header;;footer;;opentag;;closetag;;closefinaltag;false)"; @@ -142,13 +142,13 @@ namespace NzbDrone.Core.Notifications.Xbmc try { _logger.Debug("Sending Update DB Request to XBMC Host: {0}", settings.Address); - var xbmcSeriesPath = GetSeriesPath(settings, artist); + var xbmcArtistPath = GetArtistPath(settings, artist); //If the path is found update it, else update the whole library - if (!string.IsNullOrEmpty(xbmcSeriesPath)) + if (!string.IsNullOrEmpty(xbmcArtistPath)) { _logger.Debug("Updating artist [{0}] on XBMC host: {1}", artist, settings.Address); - var command = BuildExecBuiltInCommand(string.Format("UpdateLibrary(video,{0})", xbmcSeriesPath)); + var command = BuildExecBuiltInCommand(string.Format("UpdateLibrary(music,{0})", xbmcArtistPath)); SendCommand(settings, command); } @@ -156,7 +156,7 @@ namespace NzbDrone.Core.Notifications.Xbmc { //Update the entire library _logger.Debug("Artist [{0}] doesn't exist on XBMC host: {1}, Updating Entire Library", artist, settings.Address); - var command = BuildExecBuiltInCommand("UpdateLibrary(video)"); + var command = BuildExecBuiltInCommand("UpdateLibrary(music)"); SendCommand(settings, command); } } diff --git a/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs b/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs index b61830ffc..22cc896d1 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs @@ -35,9 +35,9 @@ namespace NzbDrone.Core.Notifications.Xbmc _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"))) + if (activePlayers.Any(a => a.Type.Equals("audio"))) { - _logger.Debug("Video is currently playing, skipping library update"); + _logger.Debug("Audio is currently playing, skipping library update"); return; } } @@ -55,38 +55,35 @@ namespace NzbDrone.Core.Notifications.Xbmc return _proxy.GetActivePlayers(settings); } - public string GetSeriesPath(XbmcSettings settings, Artist artist) + public string GetArtistPath(XbmcSettings settings, Artist artist) { - var allSeries = _proxy.GetArtist(settings); + var allArtists = _proxy.GetArtist(settings); - if (!allSeries.Any()) + if (!allArtists.Any()) { _logger.Debug("No Artists returned from XBMC"); return null; } - var matchingSeries = allSeries.FirstOrDefault(s => + var matchingArtist = allArtists.FirstOrDefault(s => { - var tvdbId = "0"; - //int.TryParse(s.ImdbNumber, out tvdbId); + var musicBrainzId = s.MusicbrainzArtistId.FirstOrDefault(); - return tvdbId == artist.ForeignArtistId || s.Label == artist.Name; + return musicBrainzId == artist.ForeignArtistId || s.Label == artist.Name; }); - if (matchingSeries != null) return matchingSeries.File; - - return null; + return matchingArtist?.File; } private void UpdateLibrary(XbmcSettings settings, Artist artist) { try { - var seriesPath = GetSeriesPath(settings, artist); + var artistPath = GetArtistPath(settings, artist); - if (seriesPath != null) + if (artistPath != null) { - _logger.Debug("Updating artist {0} (Path: {1}) on XBMC host: {2}", artist, seriesPath, settings.Address); + _logger.Debug("Updating artist {0} (Path: {1}) on XBMC host: {2}", artist, artistPath, settings.Address); } else @@ -95,7 +92,7 @@ namespace NzbDrone.Core.Notifications.Xbmc settings.Address); } - var response = _proxy.UpdateLibrary(settings, seriesPath); + var response = _proxy.UpdateLibrary(settings, artistPath); if (!response.Equals("OK", StringComparison.InvariantCultureIgnoreCase)) { diff --git a/src/NzbDrone.Core/Notifications/Xbmc/Model/ArtistResponse.cs b/src/NzbDrone.Core/Notifications/Xbmc/Model/ArtistResponse.cs new file mode 100644 index 000000000..bf1911901 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Xbmc/Model/ArtistResponse.cs @@ -0,0 +1,9 @@ +namespace NzbDrone.Core.Notifications.Xbmc.Model +{ + public class ArtistResponse + { + public string Id { get; set; } + public string JsonRpc { get; set; } + public ArtistResult Result { get; set; } + } +} diff --git a/src/NzbDrone.Core/Notifications/Xbmc/Model/ArtistResult.cs b/src/NzbDrone.Core/Notifications/Xbmc/Model/ArtistResult.cs new file mode 100644 index 000000000..9acb0ad11 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Xbmc/Model/ArtistResult.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace NzbDrone.Core.Notifications.Xbmc.Model +{ + public class ArtistResult + { + public Dictionary Limits { get; set; } + public List Artists; + + public ArtistResult() + { + Artists = new List(); + } + } +} diff --git a/src/NzbDrone.Core/Notifications/Xbmc/Model/KodiArtist.cs b/src/NzbDrone.Core/Notifications/Xbmc/Model/KodiArtist.cs new file mode 100644 index 000000000..1e86c7c9d --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Xbmc/Model/KodiArtist.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace NzbDrone.Core.Notifications.Xbmc.Model +{ + public class KodiArtist + { + public int ArtistId { get; set; } + public string Label { get; set; } + public List MusicbrainzArtistId { get; set; } + public string File { get; set; } + } +} diff --git a/src/NzbDrone.Core/Notifications/Xbmc/Model/TvShow.cs b/src/NzbDrone.Core/Notifications/Xbmc/Model/TvShow.cs deleted file mode 100644 index 437285107..000000000 --- a/src/NzbDrone.Core/Notifications/Xbmc/Model/TvShow.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace NzbDrone.Core.Notifications.Xbmc.Model -{ - public class TvShow - { - public int TvShowId { 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/Model/TvShowResponse.cs b/src/NzbDrone.Core/Notifications/Xbmc/Model/TvShowResponse.cs deleted file mode 100644 index 079ede558..000000000 --- a/src/NzbDrone.Core/Notifications/Xbmc/Model/TvShowResponse.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace NzbDrone.Core.Notifications.Xbmc.Model -{ - public class TvShowResponse - { - public string Id { get; set; } - public string JsonRpc { get; set; } - public TvShowResult Result { get; set; } - } -} diff --git a/src/NzbDrone.Core/Notifications/Xbmc/Model/TvShowResult.cs b/src/NzbDrone.Core/Notifications/Xbmc/Model/TvShowResult.cs deleted file mode 100644 index f3fb4dd4a..000000000 --- a/src/NzbDrone.Core/Notifications/Xbmc/Model/TvShowResult.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; - -namespace NzbDrone.Core.Notifications.Xbmc.Model -{ - public class TvShowResult - { - public Dictionary Limits { get; set; } - public List TvShows; - - public TvShowResult() - { - TvShows = new List(); - } - } -} diff --git a/src/NzbDrone.Core/Notifications/Xbmc/XbmcJsonApiProxy.cs b/src/NzbDrone.Core/Notifications/Xbmc/XbmcJsonApiProxy.cs index 5d5f42386..26dd25b14 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 GetArtist(XbmcSettings settings); + List GetArtist(XbmcSettings settings); } public class XbmcJsonApiProxy : IXbmcJsonApiProxy @@ -58,7 +58,7 @@ namespace NzbDrone.Core.Notifications.Xbmc parameters = null; } - var response = ProcessRequest(request, settings, "VideoLibrary.Scan", parameters); + var response = ProcessRequest(request, settings, "AudioLibrary.Scan", parameters); return Json.Deserialize>(response).Result; } @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Notifications.Xbmc { var request = new RestRequest(); - ProcessRequest(request, settings, "VideoLibrary.Clean"); + ProcessRequest(request, settings, "AudioLibrary.Clean"); } public List GetActivePlayers(XbmcSettings settings) @@ -79,15 +79,15 @@ namespace NzbDrone.Core.Notifications.Xbmc return Json.Deserialize(response).Result; } - public List GetArtist(XbmcSettings settings) + public List GetArtist(XbmcSettings settings) { var request = new RestRequest(); var parameters = new Dictionary(); - parameters.Add("properties", new[] { "file", "imdbnumber" }); + parameters.Add("properties", new[] { "musicbrainzartistid" }); //TODO: Figure out why AudioLibrary doesnt list file location like videoLibray - var response = ProcessRequest(request, settings, "VideoLibrary.GetTvShows", parameters); + var response = ProcessRequest(request, settings, "AudioLibrary.GetArtists", parameters); - return Json.Deserialize(response).Result.TvShows; + return Json.Deserialize(response).Result.Artists; } private string ProcessRequest(IRestRequest request, XbmcSettings settings, string method, Dictionary parameters = null) diff --git a/src/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs b/src/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs index f861dd654..21293e843 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs @@ -1,4 +1,4 @@ -using System.ComponentModel; +using System.ComponentModel; using FluentValidation; using Newtonsoft.Json; using NzbDrone.Core.Annotations; @@ -51,7 +51,7 @@ namespace NzbDrone.Core.Notifications.Xbmc [FieldDefinition(7, Label = "Clean Library", HelpText = "Clean Library after update?", Type = FieldType.Checkbox)] public bool CleanLibrary { get; set; } - [FieldDefinition(8, Label = "Always Update", HelpText = "Update Library even when a video is playing?", Type = FieldType.Checkbox)] + [FieldDefinition(8, Label = "Always Update", HelpText = "Update Library even when a file is playing?", Type = FieldType.Checkbox)] public bool AlwaysUpdate { get; set; } [JsonIgnore] diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 7f556015e..7d23eeb97 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -968,9 +968,9 @@ - - - + + +