diff --git a/Libraries/XemLib/XemLib.dll b/Libraries/XemLib/XemLib.dll deleted file mode 100644 index b32ae3128..000000000 Binary files a/Libraries/XemLib/XemLib.dll and /dev/null differ diff --git a/Libraries/XemLib/XemLib.pdb b/Libraries/XemLib/XemLib.pdb deleted file mode 100644 index a71ae0ff8..000000000 Binary files a/Libraries/XemLib/XemLib.pdb and /dev/null differ diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 91bf04d2c..42e947a8a 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -128,13 +128,14 @@ + + False + ..\Libraries\TvdbLib.dll + False ..\packages\WebActivator.1.5\lib\net40\WebActivator.dll - - ..\Libraries\XemLib\XemLib.dll - diff --git a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs index d17aa670a..9870924f1 100644 --- a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs @@ -17,7 +17,7 @@ using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; using PetaPoco; -using XemLib.Data; +using TvdbLib.Data; namespace NzbDrone.Core.Test.ProviderTests { @@ -161,7 +161,7 @@ namespace NzbDrone.Core.Test.ProviderTests c => c.Episodes = new List(Builder.CreateListOfSize(episodeCount). All() - .With(l => l.Language = "en") + .With(l => l.Language = new TvdbLanguage(0, "eng", "a")) .Build()) ).With(c => c.Id = seriesId).Build(); @@ -172,7 +172,7 @@ namespace NzbDrone.Core.Test.ProviderTests Db.Insert(fakeSeries); Mocker.GetMock() - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(fakeEpisodes); //Act @@ -195,7 +195,7 @@ namespace NzbDrone.Core.Test.ProviderTests c => c.Episodes = new List(Builder.CreateListOfSize(10). All() - .With(l => l.Language = "en").And(e => e.FirstAired = DateTime.Now) + .With(l => l.Language = new TvdbLanguage(0, "eng", "a")).And(e => e.FirstAired = DateTime.Now) .TheFirst(7).With(e => e.FirstAired = new DateTime(1800, 1, 1)) .Build()) ).With(c => c.Id = seriesId).Build(); @@ -207,7 +207,7 @@ namespace NzbDrone.Core.Test.ProviderTests Db.Insert(fakeSeries); Mocker.GetMock() - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(fakeEpisodes); @@ -236,7 +236,7 @@ namespace NzbDrone.Core.Test.ProviderTests c => c.Episodes = new List(Builder.CreateListOfSize(1) .All() - .With(l => l.Language = "en").And(e => e.FirstAired = DateTime.Now) + .With(l => l.Language = new TvdbLanguage(0, "eng", "a")).And(e => e.FirstAired = DateTime.Now) .TheFirst(1).With(e => e.FirstAired = new DateTime(1800, 1, 1)) .Build()) ).With(c => c.Id = seriesId).Build(); @@ -248,7 +248,7 @@ namespace NzbDrone.Core.Test.ProviderTests Db.Insert(fakeEpisode); Mocker.GetMock() - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(fakeTvDbEpisodes); //Act @@ -271,7 +271,7 @@ namespace NzbDrone.Core.Test.ProviderTests c => c.Episodes = new List(Builder.CreateListOfSize(episodeCount). All() - .With(l => l.Language = "en") + .With(l => l.Language = new TvdbLanguage(0, "eng", "a")) .TheFirst(1) .With(e => e.EpisodeNumber = 0) .With(e => e.SeasonNumber = 15) @@ -285,7 +285,7 @@ namespace NzbDrone.Core.Test.ProviderTests Db.Insert(fakeSeries); Mocker.GetMock() - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(fakeEpisodes); @@ -324,7 +324,7 @@ namespace NzbDrone.Core.Test.ProviderTests Db.Insert(fakeSeries); Mocker.GetMock() - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(fakeEpisodes); @@ -362,7 +362,7 @@ namespace NzbDrone.Core.Test.ProviderTests Db.Insert(fakeSeries); Mocker.GetMock() - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(fakeEpisodes); @@ -395,7 +395,7 @@ namespace NzbDrone.Core.Test.ProviderTests Db.Insert(fakeSeries); Mocker.GetMock() - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(fakeEpisodes); @@ -428,7 +428,7 @@ namespace NzbDrone.Core.Test.ProviderTests Db.Insert(fakeSeries); Mocker.GetMock() - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(fakeEpisodes); @@ -451,7 +451,7 @@ namespace NzbDrone.Core.Test.ProviderTests c => c.Episodes = new List(Builder.CreateListOfSize(episodeCount). All() - .With(l => l.Language = "en") + .With(l => l.Language = new TvdbLanguage(0, "eng", "a")) .With(e => e.SeasonNumber = 0) .Build()) ).With(c => c.Id = seriesId).Build(); @@ -463,7 +463,7 @@ namespace NzbDrone.Core.Test.ProviderTests Db.Insert(fakeSeries); Mocker.GetMock() - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(fakeEpisodes); Mocker.GetMock() @@ -493,7 +493,7 @@ namespace NzbDrone.Core.Test.ProviderTests var currentEpisodes = new List(); Mocker.GetMock(MockBehavior.Strict) - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(tvdbSeries); Mocker.GetMock() @@ -528,7 +528,7 @@ namespace NzbDrone.Core.Test.ProviderTests } Mocker.GetMock(MockBehavior.Strict) - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(tvdbSeries); Mocker.GetMock() @@ -565,7 +565,7 @@ namespace NzbDrone.Core.Test.ProviderTests .Returns(fakeEpisodeList); Mocker.GetMock() - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(fakeTvDbResult); //Act @@ -602,7 +602,7 @@ namespace NzbDrone.Core.Test.ProviderTests var fakeSeries = Builder.CreateNew().With(c => c.SeriesId = seriesId).Build(); Mocker.GetMock(MockBehavior.Strict) - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(tvdbSeries); Mocker.GetMock() @@ -643,7 +643,7 @@ namespace NzbDrone.Core.Test.ProviderTests } Mocker.GetMock(MockBehavior.Strict) - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(tvdbSeries); var updatedEpisodes = new List(); @@ -692,7 +692,7 @@ namespace NzbDrone.Core.Test.ProviderTests } Mocker.GetMock(MockBehavior.Strict) - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(tvdbSeries); var updatedEpisodes = new List(); @@ -738,7 +738,7 @@ namespace NzbDrone.Core.Test.ProviderTests } Mocker.GetMock(MockBehavior.Strict) - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(tvdbSeries); var updatedEpisodes = new List(); @@ -777,7 +777,7 @@ namespace NzbDrone.Core.Test.ProviderTests c => c.Episodes = new List(Builder.CreateListOfSize(episodeCount). All() - .With(l => l.Language = "en") + .With(l => l.Language = new TvdbLanguage(0, "eng", "a")) .With(e => e.SeasonNumber = 5) .TheFirst(1) .With(e => e.EpisodeNumber = 1) @@ -796,7 +796,7 @@ namespace NzbDrone.Core.Test.ProviderTests Db.Insert(fakeEpisode); Mocker.GetMock() - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(tvdbSeries); Mocker.GetMock() @@ -1486,7 +1486,7 @@ namespace NzbDrone.Core.Test.ProviderTests c => c.Episodes = new List(Builder.CreateListOfSize(episodeCount). All() - .With(l => l.Language = "en") + .With(l => l.Language = new TvdbLanguage(0, "eng", "a")) .With(e => e.EpisodeNumber = 0) .TheFirst(1) .With(e => e.SeasonNumber = 1) @@ -1508,7 +1508,7 @@ namespace NzbDrone.Core.Test.ProviderTests Db.Insert(fakeSeries); Mocker.GetMock() - .Setup(c => c.GetSeries(seriesId, true, false, false)) + .Setup(c => c.GetSeries(seriesId, true, false)) .Returns(tvdbSeries); //Act diff --git a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_DeleteInvalidEpisodes.cs b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_DeleteInvalidEpisodes.cs index 2d43a5c03..c4f767a92 100644 --- a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_DeleteInvalidEpisodes.cs +++ b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_DeleteInvalidEpisodes.cs @@ -10,7 +10,7 @@ using NzbDrone.Core.Providers; using NzbDrone.Core.Repository; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; -using XemLib.Data; +using TvdbLib.Data; namespace NzbDrone.Core.Test.ProviderTests { @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.ProviderTests var tvDbSeries = Builder.CreateListOfSize(episodeCount). All() - .With(l => l.Language = "en") + .With(l => l.Language = new TvdbLanguage(0, "eng", "a")) .Build(); @@ -65,7 +65,7 @@ namespace NzbDrone.Core.Test.ProviderTests var tvDbSeries = Builder.CreateListOfSize(episodeCount). All() - .With(l => l.Language = "en") + .With(l => l.Language = new TvdbLanguage(0, "eng", "a")) .Build(); var fakeSeries = Builder.CreateNew() @@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.ProviderTests var tvDbSeries = Builder.CreateListOfSize(episodeCount). All() - .With(l => l.Language = "en") + .With(l => l.Language = new TvdbLanguage(0, "eng", "a")) .Build(); var fakeSeries = Builder.CreateNew() @@ -139,7 +139,7 @@ namespace NzbDrone.Core.Test.ProviderTests var tvDbSeries = Builder.CreateListOfSize(episodeCount). All() - .With(l => l.Language = "en") + .With(l => l.Language = new TvdbLanguage(0, "eng", "a")) .Build(); var fakeSeries = Builder.CreateNew() @@ -179,7 +179,7 @@ namespace NzbDrone.Core.Test.ProviderTests var tvDbSeries = Builder.CreateListOfSize(episodeCount). All() - .With(l => l.Language = "en") + .With(l => l.Language = new TvdbLanguage(0, "eng", "a")) .Build(); var fakeSeries = Builder.CreateNew() diff --git a/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForEpisodeFile_Fixture.cs b/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForEpisodeFile_Fixture.cs index c4822c146..48b8ed3fc 100644 --- a/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForEpisodeFile_Fixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForEpisodeFile_Fixture.cs @@ -17,8 +17,8 @@ using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; using NzbDrone.Test.Common; -using XemLib.Data; -using XemLib.Data.Banner; +using TvdbLib.Data; +using TvdbLib.Data.Banner; namespace NzbDrone.Core.Test.ProviderTests.Metadata { @@ -52,30 +52,31 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata .With(e => e.SeriesId = 79488) .With(e => e.SeasonNumber = 1) .With(e => e.Directors = new List{ "Fake Director" }) - .With(e => e.Writers = new List{ "Fake Writer" }) + .With(e => e.Writer = new List{ "Fake Writer" }) .With(e => e.GuestStars = new List { "Guest Star 1", "Guest Star 2", "Guest Star 3", "" }) .Build(); var seasonBanners = Builder .CreateListOfSize(4) .TheFirst(2) - .With(b => b.SeasonNumber = 1) + .With(b => b.Season = 1) .TheLast(2) - .With(b => b.SeasonNumber = 2) + .With(b => b.Season = 2) .TheFirst(1) - .With(b => b.BannerType = TvdbSeasonBanner.Type.Poster) + .With(b => b.BannerType = TvdbSeasonBanner.Type.season) .With(b => b.BannerPath = "seasons/79488-1-1.jpg") .TheNext(2) - .With(b => b.BannerType = TvdbSeasonBanner.Type.Banner) + .With(b => b.BannerType = TvdbSeasonBanner.Type.seasonwide) .With(b => b.BannerPath = "banners/seasons/79488-test.jpg") .TheLast(1) - .With(b => b.BannerType = TvdbSeasonBanner.Type.Poster) + .With(b => b.BannerType = TvdbSeasonBanner.Type.season) .With(b => b.BannerPath = "seasons/79488-2-1.jpg") .Build(); var seriesActors = Builder .CreateListOfSize(5) .All() + .With(a => a.ActorImage = Builder.CreateNew().Build()) .Build(); tvdbSeries = Builder @@ -84,10 +85,9 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata .With(s => s.SeriesName = "30 Rock") .With(s => s.TvdbActors = seriesActors.ToList()) .With(s => s.Episodes = tvdbEpisodes.ToList()) - .With(s => s.Banners = new TvdbBanners()) .Build(); - tvdbSeries.Banners.SeasonBanners.AddRange(seasonBanners); + tvdbSeries.Banners.AddRange(seasonBanners); } private void WithUseBanners() @@ -128,7 +128,7 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata private void WithNoWriters() { - tvdbSeries.Episodes.ForEach(e => e.Writers = new List()); + tvdbSeries.Episodes.ForEach(e => e.Writer = new List()); } [Test] @@ -159,7 +159,7 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata { WithSingleEpisodeFile(); Mocker.Resolve().CreateForEpisodeFile(episodeFile, tvdbSeries); - Mocker.GetMock().Verify(v => v.Download(tvdbSeries.Episodes.First().Banner, episodeFile.Path.Replace("avi", "tbn")), Times.Once()); + Mocker.GetMock().Verify(v => v.Download(tvdbSeries.Episodes.First().BannerPath, episodeFile.Path.Replace("avi", "tbn")), Times.Once()); } [Test] diff --git a/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForSeries_Fixture.cs b/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForSeries_Fixture.cs index 6151bfc11..1a55c0eb7 100644 --- a/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForSeries_Fixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForSeries_Fixture.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; @@ -17,8 +16,8 @@ using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; using NzbDrone.Test.Common; -using XemLib.Data; -using XemLib.Data.Banner; +using TvdbLib.Data; +using TvdbLib.Data.Banner; namespace NzbDrone.Core.Test.ProviderTests.Metadata { @@ -43,23 +42,24 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata var seasonBanners = Builder .CreateListOfSize(4) .TheFirst(2) - .With(b => b.SeasonNumber = 1) + .With(b => b.Season = 1) .TheLast(2) - .With(b => b.SeasonNumber = 2) + .With(b => b.Season = 2) .TheFirst(1) - .With(b => b.BannerType = TvdbSeasonBanner.Type.Poster) + .With(b => b.BannerType = TvdbSeasonBanner.Type.season) .With(b => b.BannerPath = "seasons/79488-1-1.jpg") .TheNext(2) - .With(b => b.BannerType = TvdbSeasonBanner.Type.Banner) + .With(b => b.BannerType = TvdbSeasonBanner.Type.seasonwide) .With(b => b.BannerPath = "banners/seasons/79488-test.jpg") .TheLast(1) - .With(b => b.BannerType = TvdbSeasonBanner.Type.Poster) + .With(b => b.BannerType = TvdbSeasonBanner.Type.season) .With(b => b.BannerPath = "seasons/79488-2-1.jpg") .Build(); var seriesActors = Builder .CreateListOfSize(5) .All() + .With(a => a.ActorImage = Builder.CreateNew().Build()) .Build(); tvdbSeries = Builder @@ -67,10 +67,9 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata .With(s => s.Id = 79488) .With(s => s.SeriesName = "30 Rock") .With(s => s.TvdbActors = seriesActors.ToList()) - .With(s => s.Banners = new TvdbBanners()) .Build(); - tvdbSeries.Banners.SeasonBanners.AddRange(seasonBanners); + tvdbSeries.Banners.AddRange(seasonBanners); } private void WithUseBanners() @@ -83,18 +82,19 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata var seasonBanners = Builder .CreateListOfSize(2) .All() - .With(b => b.SeasonNumber = 0) + .With(b => b.Season = 0) .TheFirst(1) - .With(b => b.BannerType = TvdbSeasonBanner.Type.Poster) + .With(b => b.BannerType = TvdbSeasonBanner.Type.season) .With(b => b.BannerPath = "seasons/79488-0-1.jpg") .TheLast(1) - .With(b => b.BannerType = TvdbSeasonBanner.Type.Banner) + .With(b => b.BannerType = TvdbSeasonBanner.Type.seasonwide) .With(b => b.BannerPath = "banners/seasons/79488-0-1.jpg") .Build(); var seriesActors = Builder .CreateListOfSize(5) .All() + .With(a => a.ActorImage = Builder.CreateNew().Build()) .Build(); tvdbSeries = Builder @@ -102,11 +102,9 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata .With(s => s.Id = 79488) .With(s => s.SeriesName = "30 Rock") .With(s => s.TvdbActors = seriesActors.ToList()) - .With(s => s.Banners = new TvdbBanners()) - .With(s => s.Genres = new List { "Comedy" }) .Build(); - tvdbSeries.Banners.SeasonBanners.AddRange(seasonBanners); + tvdbSeries.Banners.AddRange(seasonBanners); } [Test] @@ -126,14 +124,14 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata public void should_download_fanart() { Mocker.Resolve().CreateForSeries(series, tvdbSeries); - Mocker.GetMock().Verify(v => v.Download(tvdbSeries.Fanart, Path.Combine(series.Path, "fanart.jpg")), Times.Once()); + Mocker.GetMock().Verify(v => v.Download(tvdbSeries.FanartPath, Path.Combine(series.Path, "fanart.jpg")), Times.Once()); } [Test] public void should_download_poster_when_useBanners_is_false() { Mocker.Resolve().CreateForSeries(series, tvdbSeries); - Mocker.GetMock().Verify(v => v.Download(tvdbSeries.Poster, Path.Combine(series.Path, "folder.jpg")), Times.Once()); + Mocker.GetMock().Verify(v => v.Download(tvdbSeries.PosterPath, Path.Combine(series.Path, "folder.jpg")), Times.Once()); } [Test] @@ -141,7 +139,7 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata { WithUseBanners(); Mocker.Resolve().CreateForSeries(series, tvdbSeries); - Mocker.GetMock().Verify(v => v.Download(tvdbSeries.Banner, Path.Combine(series.Path, "folder.jpg")), Times.Once()); + Mocker.GetMock().Verify(v => v.Download(tvdbSeries.BannerPath, Path.Combine(series.Path, "folder.jpg")), Times.Once()); } [Test] diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs index 26e367da3..dd4255406 100644 --- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs @@ -18,6 +18,7 @@ using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; using PetaPoco; +using TvdbLib.Data; namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests { diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs index 162baf1e8..e4cd1fd3b 100644 --- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs @@ -18,6 +18,7 @@ using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; using PetaPoco; +using TvdbLib.Data; namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests { diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs index 3f4310402..5ac5c3378 100644 --- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs @@ -18,6 +18,7 @@ using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; using PetaPoco; +using TvdbLib.Data; namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests { diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs index 4b7853392..1835dda2a 100644 --- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs @@ -18,6 +18,7 @@ using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; using PetaPoco; +using TvdbLib.Data; namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests { diff --git a/NzbDrone.Core.Test/ProviderTests/SeasonProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SeasonProviderTest.cs index 248fb82dc..fa400ab90 100644 --- a/NzbDrone.Core.Test/ProviderTests/SeasonProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/SeasonProviderTest.cs @@ -16,6 +16,7 @@ using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; using PetaPoco; +using TvdbLib.Data; namespace NzbDrone.Core.Test.ProviderTests { diff --git a/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs index 42232678e..2dd003ace 100644 --- a/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs @@ -10,8 +10,8 @@ using NzbDrone.Common; using NzbDrone.Core.Providers; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; -using XemLib.Data; -using XemLib.Exceptions; +using TvdbLib.Data; +using TvdbLib.Exceptions; namespace NzbDrone.Core.Test.ProviderTests { @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.ProviderTests [TearDown] public void TearDown() { - ExceptionVerification.MarkInconclusive(typeof(TheTvbdbUnavailableException)); + ExceptionVerification.MarkInconclusive(typeof(TvdbNotAvailableException)); } [TestCase("The Simpsons")] @@ -68,5 +68,58 @@ namespace NzbDrone.Core.Test.ProviderTests .Max(e => e.Count()).Should().Be(1); } + + [Test] + public void American_dad_fix() + { + //act + var result = tvDbProvider.GetSeries(73141, true); + + var seasonsNumbers = result.Episodes.Select(e => e.SeasonNumber) + .Distinct().ToList(); + + var seasons = new Dictionary>(seasonsNumbers.Count); + + foreach (var season in seasonsNumbers) + { + seasons.Add(season, result.Episodes.Where(e => e.SeasonNumber == season).ToList()); + } + + foreach (var episode in result.Episodes) + { + Console.WriteLine(episode); + } + + //assert + seasonsNumbers.Should().HaveCount(9); + seasons[1].Should().HaveCount(23); + seasons[2].Should().HaveCount(19); + seasons[3].Should().HaveCount(16); + seasons[4].Should().HaveCount(20); + seasons[5].Should().HaveCount(18); + seasons[6].Should().HaveCount(19); + seasons[7].Should().HaveCount(18); + + foreach (var season in seasons) + { + season.Value.Should().OnlyHaveUniqueItems("Season {0}", season.Key); + } + + //Make sure no episode number is skipped + foreach (var season in seasons) + { + for (int i = 1; i < season.Value.Count; i++) + { + //Skip specials, because someone decided 1,3,4,6,7,21 is how you count... + if (season.Key == 0) + continue; + + season.Value.Should().Contain(c => c.EpisodeNumber == i, "Can't find Episode S{0:00}E{1:00}", + season.Value[0].SeasonNumber, i); + } + } + + + } } } \ No newline at end of file diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index ec13af4a1..27f6da914 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -206,6 +206,10 @@ + + False + ..\Libraries\TvdbLib.dll + ..\packages\twitterizer.2.4.0.26532\lib\net40\Twitterizer2.dll @@ -213,9 +217,6 @@ False ..\packages\WebActivator.1.5\lib\net40\WebActivator.dll - - ..\Libraries\XemLib\XemLib.dll - diff --git a/NzbDrone.Core/Providers/EpisodeProvider.cs b/NzbDrone.Core/Providers/EpisodeProvider.cs index b8221b152..e3e4bfb3e 100644 --- a/NzbDrone.Core/Providers/EpisodeProvider.cs +++ b/NzbDrone.Core/Providers/EpisodeProvider.cs @@ -7,7 +7,7 @@ using NLog; using NzbDrone.Core.Model; using NzbDrone.Core.Repository; using PetaPoco; -using XemLib.Data; +using TvdbLib.Data; namespace NzbDrone.Core.Providers { diff --git a/NzbDrone.Core/Providers/Metadata/MetadataBase.cs b/NzbDrone.Core/Providers/Metadata/MetadataBase.cs index ee9de7e06..740785acc 100644 --- a/NzbDrone.Core/Providers/Metadata/MetadataBase.cs +++ b/NzbDrone.Core/Providers/Metadata/MetadataBase.cs @@ -4,7 +4,7 @@ using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Repository; -using XemLib.Data; +using TvdbLib.Data; namespace NzbDrone.Core.Providers.Metadata { diff --git a/NzbDrone.Core/Providers/Metadata/Xbmc.cs b/NzbDrone.Core/Providers/Metadata/Xbmc.cs index 44f9c9e5e..8182cc235 100644 --- a/NzbDrone.Core/Providers/Metadata/Xbmc.cs +++ b/NzbDrone.Core/Providers/Metadata/Xbmc.cs @@ -8,8 +8,8 @@ using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Repository; -using XemLib.Data; -using XemLib.Data.Banner; +using TvdbLib.Data; +using TvdbLib.Data.Banner; namespace NzbDrone.Core.Providers.Metadata { @@ -48,16 +48,16 @@ namespace NzbDrone.Core.Providers.Metadata tvShow.Add(new XElement("episodeguideurl", episodeGuideUrl)); tvShow.Add(new XElement("mpaa", tvDbSeries.ContentRating)); tvShow.Add(new XElement("id", tvDbSeries.Id)); - tvShow.Add(new XElement("genre", tvDbSeries.Genres.FirstOrDefault())); + tvShow.Add(new XElement("genre", tvDbSeries.GenreString.Trim('|').Split('|')[0])); tvShow.Add(new XElement("premiered", tvDbSeries.FirstAired.ToString("yyyy-MM-dd"))); - tvShow.Add(new XElement("studio", tvDbSeries.Network)); + tvShow.Add(new XElement("studio", tvDbSeries.Network)); foreach(var actor in tvDbSeries.TvdbActors) { tvShow.Add(new XElement("actor", new XElement("name", actor.Name), new XElement("role", actor.Role), - new XElement("thumb", "http://www.thetvdb.com/banners/" + actor.Image) + new XElement("thumb", "http://www.thetvdb.com/banners/" + actor.ActorImage.BannerPath) )); } @@ -71,7 +71,7 @@ namespace NzbDrone.Core.Providers.Metadata if (!_diskProvider.FileExists(Path.Combine(series.Path, "fanart.jpg"))) { _logger.Debug("Downloading fanart for: {0}", series.Title); - _bannerProvider.Download(tvDbSeries.Fanart, Path.Combine(series.Path, "fanart.jpg")); + _bannerProvider.Download(tvDbSeries.FanartPath, Path.Combine(series.Path, "fanart.jpg")); } if (!_diskProvider.FileExists(Path.Combine(series.Path, "folder.jpg"))) @@ -79,19 +79,19 @@ namespace NzbDrone.Core.Providers.Metadata if(_configProvider.MetadataUseBanners) { _logger.Debug("Downloading series banner for: {0}", series.Title); - _bannerProvider.Download(tvDbSeries.Banner, Path.Combine(series.Path, "folder.jpg")); + _bannerProvider.Download(tvDbSeries.BannerPath, Path.Combine(series.Path, "folder.jpg")); _logger.Debug("Downloading Season banners for {0}", series.Title); - DownloadSeasonThumbnails(series, tvDbSeries, TvdbSeasonBanner.Type.Banner); + DownloadSeasonThumbnails(series, tvDbSeries, TvdbSeasonBanner.Type.seasonwide); } else { _logger.Debug("Downloading series thumbnail for: {0}", series.Title); - _bannerProvider.Download(tvDbSeries.Poster, Path.Combine(series.Path, "folder.jpg")); + _bannerProvider.Download(tvDbSeries.PosterPath, Path.Combine(series.Path, "folder.jpg")); _logger.Debug("Downloading Season posters for {0}", series.Title); - DownloadSeasonThumbnails(series, tvDbSeries, TvdbSeasonBanner.Type.Poster); + DownloadSeasonThumbnails(series, tvDbSeries, TvdbSeasonBanner.Type.season); } } } @@ -112,7 +112,7 @@ namespace NzbDrone.Core.Providers.Metadata e.SeasonNumber == episodeFile.SeasonNumber && e.EpisodeNumber == episodes.First().EpisodeNumber); - if (episodeFileThumbnail == null || String.IsNullOrWhiteSpace(episodeFileThumbnail.Banner)) + if (episodeFileThumbnail == null || String.IsNullOrWhiteSpace(episodeFileThumbnail.BannerPath)) { _logger.Debug("No thumbnail is available for this episode"); return; @@ -121,7 +121,7 @@ namespace NzbDrone.Core.Providers.Metadata if (!_diskProvider.FileExists(episodeFile.Path.Replace(Path.GetExtension(episodeFile.Path), ".tbn"))) { _logger.Debug("Downloading episode thumbnail for: {0}", episodeFile.EpisodeFileId); - _bannerProvider.Download(episodeFileThumbnail.Banner, + _bannerProvider.Download(episodeFileThumbnail.BannerPath, episodeFile.Path.Replace(Path.GetExtension(episodeFile.Path), ".tbn")); } @@ -165,9 +165,9 @@ namespace NzbDrone.Core.Providers.Metadata details.Add(new XElement("plot", tvdbEpisode.Overview)); details.Add(new XElement("displayseason")); details.Add(new XElement("displayepisode")); - details.Add(new XElement("thumb", "http://www.thetvdb.com/banners/" + tvdbEpisode.Banner)); + details.Add(new XElement("thumb", "http://www.thetvdb.com/banners/" + tvdbEpisode.BannerPath)); details.Add(new XElement("watched", "false")); - details.Add(new XElement("credits", tvdbEpisode.Writers.FirstOrDefault())); + details.Add(new XElement("credits", tvdbEpisode.Writer.FirstOrDefault())); details.Add(new XElement("director", tvdbEpisode.Directors.FirstOrDefault())); details.Add(new XElement("rating", tvdbEpisode.Rating)); @@ -186,7 +186,7 @@ namespace NzbDrone.Core.Providers.Metadata details.Add(new XElement("actor", new XElement("name", actor.Name), new XElement("role", actor.Role), - new XElement("thumb", "http://www.thetvdb.com/banners/" + actor.Image) + new XElement("thumb", "http://www.thetvdb.com/banners/" + actor.ActorImage.BannerPath) )); } @@ -235,11 +235,11 @@ namespace NzbDrone.Core.Providers.Metadata private void DownloadSeasonThumbnails(Series series, TvdbSeries tvDbSeries, TvdbSeasonBanner.Type bannerType) { - var seasons = tvDbSeries.Banners.SeasonBanners.Where(s => s.BannerType == bannerType).Select(s => s.SeasonNumber); + var seasons = tvDbSeries.SeasonBanners.Where(s => s.BannerType == bannerType).Select(s => s.Season); foreach (var season in seasons) { - var banner = tvDbSeries.Banners.SeasonBanners.FirstOrDefault(b => b.BannerType == bannerType && b.SeasonNumber == season); + var banner = tvDbSeries.SeasonBanners.FirstOrDefault(b => b.BannerType == bannerType && b.Season == season); _logger.Debug("Downloading banner for Season: {0} Series: {1}", season, series.Title); if (season == 0) diff --git a/NzbDrone.Core/Providers/MetadataProvider.cs b/NzbDrone.Core/Providers/MetadataProvider.cs index d6d27ac08..caad52dba 100644 --- a/NzbDrone.Core/Providers/MetadataProvider.cs +++ b/NzbDrone.Core/Providers/MetadataProvider.cs @@ -8,7 +8,7 @@ using NzbDrone.Core.Providers.ExternalNotification; using NzbDrone.Core.Providers.Metadata; using NzbDrone.Core.Repository; using PetaPoco; -using XemLib.Data; +using TvdbLib.Data; namespace NzbDrone.Core.Providers { @@ -92,7 +92,7 @@ namespace NzbDrone.Core.Providers public virtual void CreateForSeries(Series series) { - var tvDbSeries = _tvDbProvider.GetSeries(series.SeriesId, false, true, true); + var tvDbSeries = _tvDbProvider.GetSeries(series.SeriesId, false, true); CreateForSeries(series, tvDbSeries); } @@ -107,7 +107,7 @@ namespace NzbDrone.Core.Providers public virtual void CreateForEpisodeFile(EpisodeFile episodeFile) { - var tvDbSeries = _tvDbProvider.GetSeries(episodeFile.SeriesId, true, true, true); + var tvDbSeries = _tvDbProvider.GetSeries(episodeFile.SeriesId, true, true); CreateForEpisodeFile(episodeFile, tvDbSeries); } @@ -130,7 +130,7 @@ namespace NzbDrone.Core.Providers Logger.Trace("Creating metadata for {0} files.", episodeFiles.Count); - var tvDbSeries = _tvDbProvider.GetSeries(episodeFiles.First().SeriesId, true, true, true); + var tvDbSeries = _tvDbProvider.GetSeries(episodeFiles.First().SeriesId, true, true); foreach(var episodeFile in episodeFiles) { diff --git a/NzbDrone.Core/Providers/SeriesProvider.cs b/NzbDrone.Core/Providers/SeriesProvider.cs index 9c6d61242..ecbded829 100644 --- a/NzbDrone.Core/Providers/SeriesProvider.cs +++ b/NzbDrone.Core/Providers/SeriesProvider.cs @@ -97,11 +97,11 @@ namespace NzbDrone.Core.Providers series.AirsDayOfWeek = tvDbSeries.AirsDayOfWeek; series.Overview = tvDbSeries.Overview; series.Status = tvDbSeries.Status; - series.Language = tvDbSeries.Language != null ? tvDbSeries.Language : string.Empty; + series.Language = tvDbSeries.Language != null ? tvDbSeries.Language.Abbriviation : string.Empty; series.CleanTitle = Parser.NormalizeTitle(tvDbSeries.SeriesName); series.LastInfoSync = DateTime.Now; series.Runtime = (int)tvDbSeries.Runtime; - series.BannerUrl = tvDbSeries.Banner; + series.BannerUrl = tvDbSeries.BannerPath; series.Network = tvDbSeries.Network; UpdateSeries(series); diff --git a/NzbDrone.Core/Providers/TvDbProvider.cs b/NzbDrone.Core/Providers/TvDbProvider.cs index aca384bbc..0bbd29b69 100644 --- a/NzbDrone.Core/Providers/TvDbProvider.cs +++ b/NzbDrone.Core/Providers/TvDbProvider.cs @@ -5,8 +5,9 @@ using System.Text.RegularExpressions; using NLog; using Ninject; using NzbDrone.Common; -using XemLib; -using XemLib.Data; +using TvdbLib; +using TvdbLib.Cache; +using TvdbLib.Data; namespace NzbDrone.Core.Providers { @@ -16,13 +17,13 @@ namespace NzbDrone.Core.Providers public const string TVDB_APIKEY = "5D2D188E86E07F4F"; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private readonly XemClient _xemClient; + private readonly TvdbHandler _handler; [Inject] public TvDbProvider(EnvironmentProvider environmentProvider) { _environmentProvider = environmentProvider; - _xemClient = new XemClient(TVDB_APIKEY); + _handler = new TvdbHandler(new XmlCacheProvider(_environmentProvider.GetCacheFolder()), TVDB_APIKEY); } public TvDbProvider() @@ -32,27 +33,57 @@ namespace NzbDrone.Core.Providers public virtual IList SearchSeries(string title) { - Logger.Debug("Searching TVDB for '{0}'", title); + lock (_handler) + { + Logger.Debug("Searching TVDB for '{0}'", title); - var result = _xemClient.SearchSeries(title); + var result = _handler.SearchSeries(title); - Logger.Debug("Search for '{0}' returned {1} possible results", title, result.Count); - return result; + Logger.Debug("Search for '{0}' returned {1} possible results", title, result.Count); + return result; + } } - public virtual TvdbSeries GetSeries(int id, bool loadEpisodes, bool loadActors = false, bool loadBanners = false) + public virtual TvdbSeries GetSeries(int id, bool loadEpisodes, bool loadActors = false) { - Logger.Debug("Fetching SeriesId'{0}' from tvdb", id); - var result = _xemClient.GetSeries(id, loadEpisodes, loadActors, true, TvdbLanguage.Default); + lock (_handler) + { + Logger.Debug("Fetching SeriesId'{0}' from tvdb", id); + var result = _handler.GetSeries(id, TvdbLanguage.DefaultLanguage, loadEpisodes, loadActors, true, true); - //Remove duplicated episodes - var episodes = result.Episodes.OrderByDescending(e => e.FirstAired).ThenByDescending(e => e.EpisodeName) - .GroupBy(e => e.SeriesId.ToString("000000") + e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000")) - .Select(e => e.First()); + //Fix American Dad's scene gongshow + if (result != null && result.Id == 73141) + { + result.Episodes = result.Episodes.Where(e => e.SeasonNumber == 0 || e.EpisodeNumber > 0).ToList(); - result.Episodes = episodes.ToList(); + var seasonOneEpisodeCount = result.Episodes.Where(e => e.SeasonNumber == 1).Count(); + var seasonOneId = result.Episodes.Where(e => e.SeasonNumber == 1).First().SeasonId; - return result; + foreach (var episode in result.Episodes) + { + if (episode.SeasonNumber > 1) + { + if (episode.SeasonNumber == 2) + { + episode.EpisodeNumber = episode.EpisodeNumber + seasonOneEpisodeCount; + episode.SeasonId = seasonOneId; + } + + episode.SeasonNumber = episode.SeasonNumber - 1; + } + + } + } + + //Remove duplicated episodes + var episodes = result.Episodes.OrderByDescending(e => e.FirstAired).ThenByDescending(e => e.EpisodeName) + .GroupBy(e => e.SeriesId.ToString("000000") + e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000")) + .Select(e => e.First()); + + result.Episodes = episodes.ToList(); + + return result; + } } } } \ No newline at end of file diff --git a/NzbDrone.Web/Controllers/AddSeriesController.cs b/NzbDrone.Web/Controllers/AddSeriesController.cs index 541dcea23..96adab086 100644 --- a/NzbDrone.Web/Controllers/AddSeriesController.cs +++ b/NzbDrone.Web/Controllers/AddSeriesController.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Repository; using NzbDrone.Web.Filters; using NzbDrone.Web.Models; -using XemLib.Exceptions; +using TvdbLib.Exceptions; namespace NzbDrone.Web.Controllers { @@ -156,14 +156,14 @@ namespace NzbDrone.Web.Controllers DisplayedTitle = r.FirstAired.Year > 1900 && !r.SeriesName.EndsWith("(" + r.FirstAired.Year + ")") ? string.Format("{0} ({1})", r.SeriesName, r.FirstAired.Year) : r.SeriesName, - Banner = r.Banner, + Banner = r.Banner.BannerPath, Url = String.Format("http://www.thetvdb.com/?tab=series&id={0}", r.Id) }).ToList(); return Json(tvDbResults, JsonRequestBehavior.AllowGet); } - catch (TheTvbdbUnavailableException ex) + catch(TvdbNotAvailableException ex) { logger.WarnException("Unable to lookup series on TheTVDB", ex); return JsonNotificationResult.Info("Lookup Failed", "TheTVDB is not available at this time."); diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 0bb0c2722..56305e711 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -138,14 +138,14 @@ True + + False + ..\Libraries\TvdbLib.dll + False ..\packages\WebActivator.1.5.1\lib\net40\WebActivator.dll - - False - ..\Libraries\XemLib\XemLib.dll -