XemClient added

New: Now using the thexem.de for episode information
pull/2/head
Mark McDowall 12 years ago
parent 27646310a1
commit a6e8ec6123

Binary file not shown.

Binary file not shown.

@ -128,14 +128,13 @@
<Reference Include="System.Transactions" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="TvdbLib, Version=0.8.8.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\TvdbLib.dll</HintPath>
</Reference>
<Reference Include="WebActivator, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\WebActivator.1.5\lib\net40\WebActivator.dll</HintPath>
</Reference>
<Reference Include="XemLib">
<HintPath>..\Libraries\XemLib\XemLib.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="EpisodeParseResultTest.cs" />

@ -17,7 +17,7 @@ using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
using PetaPoco;
using TvdbLib.Data;
using XemLib.Data;
namespace NzbDrone.Core.Test.ProviderTests
{
@ -161,7 +161,7 @@ namespace NzbDrone.Core.Test.ProviderTests
c => c.Episodes =
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
All()
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
.With(l => l.Language = "en")
.Build())
).With(c => c.Id = seriesId).Build();
@ -172,7 +172,7 @@ namespace NzbDrone.Core.Test.ProviderTests
Db.Insert(fakeSeries);
Mocker.GetMock<TvDbProvider>()
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(fakeEpisodes);
//Act
@ -195,7 +195,7 @@ namespace NzbDrone.Core.Test.ProviderTests
c => c.Episodes =
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(10).
All()
.With(l => l.Language = new TvdbLanguage(0, "eng", "a")).And(e => e.FirstAired = DateTime.Now)
.With(l => l.Language = "en").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<TvDbProvider>()
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(fakeEpisodes);
@ -236,7 +236,7 @@ namespace NzbDrone.Core.Test.ProviderTests
c => c.Episodes =
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(1)
.All()
.With(l => l.Language = new TvdbLanguage(0, "eng", "a")).And(e => e.FirstAired = DateTime.Now)
.With(l => l.Language = "en").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<TvDbProvider>()
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(fakeTvDbEpisodes);
//Act
@ -271,7 +271,7 @@ namespace NzbDrone.Core.Test.ProviderTests
c => c.Episodes =
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
All()
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
.With(l => l.Language = "en")
.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<TvDbProvider>()
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(fakeEpisodes);
@ -324,7 +324,7 @@ namespace NzbDrone.Core.Test.ProviderTests
Db.Insert(fakeSeries);
Mocker.GetMock<TvDbProvider>()
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(fakeEpisodes);
@ -362,7 +362,7 @@ namespace NzbDrone.Core.Test.ProviderTests
Db.Insert(fakeSeries);
Mocker.GetMock<TvDbProvider>()
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(fakeEpisodes);
@ -395,7 +395,7 @@ namespace NzbDrone.Core.Test.ProviderTests
Db.Insert(fakeSeries);
Mocker.GetMock<TvDbProvider>()
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(fakeEpisodes);
@ -428,7 +428,7 @@ namespace NzbDrone.Core.Test.ProviderTests
Db.Insert(fakeSeries);
Mocker.GetMock<TvDbProvider>()
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(fakeEpisodes);
@ -451,7 +451,7 @@ namespace NzbDrone.Core.Test.ProviderTests
c => c.Episodes =
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
All()
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
.With(l => l.Language = "en")
.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<TvDbProvider>()
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(fakeEpisodes);
Mocker.GetMock<SeasonProvider>()
@ -493,7 +493,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var currentEpisodes = new List<Episode>();
Mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(tvdbSeries);
Mocker.GetMock<IDatabase>()
@ -528,7 +528,7 @@ namespace NzbDrone.Core.Test.ProviderTests
}
Mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(tvdbSeries);
Mocker.GetMock<IDatabase>()
@ -565,7 +565,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Returns(fakeEpisodeList);
Mocker.GetMock<TvDbProvider>()
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(fakeTvDbResult);
//Act
@ -602,7 +602,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
Mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(tvdbSeries);
Mocker.GetMock<IDatabase>()
@ -643,7 +643,7 @@ namespace NzbDrone.Core.Test.ProviderTests
}
Mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(tvdbSeries);
var updatedEpisodes = new List<Episode>();
@ -692,7 +692,7 @@ namespace NzbDrone.Core.Test.ProviderTests
}
Mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(tvdbSeries);
var updatedEpisodes = new List<Episode>();
@ -738,7 +738,7 @@ namespace NzbDrone.Core.Test.ProviderTests
}
Mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(tvdbSeries);
var updatedEpisodes = new List<Episode>();
@ -777,7 +777,7 @@ namespace NzbDrone.Core.Test.ProviderTests
c => c.Episodes =
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
All()
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
.With(l => l.Language = "en")
.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<TvDbProvider>()
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(tvdbSeries);
Mocker.GetMock<SeasonProvider>()
@ -1486,7 +1486,7 @@ namespace NzbDrone.Core.Test.ProviderTests
c => c.Episodes =
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
All()
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
.With(l => l.Language = "en")
.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<TvDbProvider>()
.Setup(c => c.GetSeries(seriesId, true, false))
.Setup(c => c.GetSeries(seriesId, true, false, false))
.Returns(tvdbSeries);
//Act

@ -10,7 +10,7 @@ using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
using TvdbLib.Data;
using XemLib.Data;
namespace NzbDrone.Core.Test.ProviderTests
{
@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
All()
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
.With(l => l.Language = "en")
.Build();
@ -65,7 +65,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
All()
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
.With(l => l.Language = "en")
.Build();
var fakeSeries = Builder<Series>.CreateNew()
@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
All()
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
.With(l => l.Language = "en")
.Build();
var fakeSeries = Builder<Series>.CreateNew()
@ -139,7 +139,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
All()
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
.With(l => l.Language = "en")
.Build();
var fakeSeries = Builder<Series>.CreateNew()
@ -179,7 +179,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
All()
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
.With(l => l.Language = "en")
.Build();
var fakeSeries = Builder<Series>.CreateNew()

@ -17,8 +17,8 @@ using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
using NzbDrone.Test.Common;
using TvdbLib.Data;
using TvdbLib.Data.Banner;
using XemLib.Data;
using XemLib.Data.Banner;
namespace NzbDrone.Core.Test.ProviderTests.Metadata
{
@ -52,31 +52,30 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata
.With(e => e.SeriesId = 79488)
.With(e => e.SeasonNumber = 1)
.With(e => e.Directors = new List<string>{ "Fake Director" })
.With(e => e.Writer = new List<string>{ "Fake Writer" })
.With(e => e.Writers = new List<string>{ "Fake Writer" })
.With(e => e.GuestStars = new List<string> { "Guest Star 1", "Guest Star 2", "Guest Star 3", "" })
.Build();
var seasonBanners = Builder<TvdbSeasonBanner>
.CreateListOfSize(4)
.TheFirst(2)
.With(b => b.Season = 1)
.With(b => b.SeasonNumber = 1)
.TheLast(2)
.With(b => b.Season = 2)
.With(b => b.SeasonNumber = 2)
.TheFirst(1)
.With(b => b.BannerType = TvdbSeasonBanner.Type.season)
.With(b => b.BannerType = TvdbSeasonBanner.Type.Poster)
.With(b => b.BannerPath = "seasons/79488-1-1.jpg")
.TheNext(2)
.With(b => b.BannerType = TvdbSeasonBanner.Type.seasonwide)
.With(b => b.BannerType = TvdbSeasonBanner.Type.Banner)
.With(b => b.BannerPath = "banners/seasons/79488-test.jpg")
.TheLast(1)
.With(b => b.BannerType = TvdbSeasonBanner.Type.season)
.With(b => b.BannerType = TvdbSeasonBanner.Type.Poster)
.With(b => b.BannerPath = "seasons/79488-2-1.jpg")
.Build();
var seriesActors = Builder<TvdbActor>
.CreateListOfSize(5)
.All()
.With(a => a.ActorImage = Builder<TvdbActorBanner>.CreateNew().Build())
.Build();
tvdbSeries = Builder<TvdbSeries>
@ -85,9 +84,10 @@ 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.AddRange(seasonBanners);
tvdbSeries.Banners.SeasonBanners.AddRange(seasonBanners);
}
private void WithUseBanners()
@ -128,7 +128,7 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata
private void WithNoWriters()
{
tvdbSeries.Episodes.ForEach(e => e.Writer = new List<string>());
tvdbSeries.Episodes.ForEach(e => e.Writers = new List<string>());
}
[Test]
@ -159,7 +159,7 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata
{
WithSingleEpisodeFile();
Mocker.Resolve<Xbmc>().CreateForEpisodeFile(episodeFile, tvdbSeries);
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.Episodes.First().BannerPath, episodeFile.Path.Replace("avi", "tbn")), Times.Once());
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.Episodes.First().Banner, episodeFile.Path.Replace("avi", "tbn")), Times.Once());
}
[Test]

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
@ -16,8 +17,8 @@ using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
using NzbDrone.Test.Common;
using TvdbLib.Data;
using TvdbLib.Data.Banner;
using XemLib.Data;
using XemLib.Data.Banner;
namespace NzbDrone.Core.Test.ProviderTests.Metadata
{
@ -42,24 +43,23 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata
var seasonBanners = Builder<TvdbSeasonBanner>
.CreateListOfSize(4)
.TheFirst(2)
.With(b => b.Season = 1)
.With(b => b.SeasonNumber = 1)
.TheLast(2)
.With(b => b.Season = 2)
.With(b => b.SeasonNumber = 2)
.TheFirst(1)
.With(b => b.BannerType = TvdbSeasonBanner.Type.season)
.With(b => b.BannerType = TvdbSeasonBanner.Type.Poster)
.With(b => b.BannerPath = "seasons/79488-1-1.jpg")
.TheNext(2)
.With(b => b.BannerType = TvdbSeasonBanner.Type.seasonwide)
.With(b => b.BannerType = TvdbSeasonBanner.Type.Banner)
.With(b => b.BannerPath = "banners/seasons/79488-test.jpg")
.TheLast(1)
.With(b => b.BannerType = TvdbSeasonBanner.Type.season)
.With(b => b.BannerType = TvdbSeasonBanner.Type.Poster)
.With(b => b.BannerPath = "seasons/79488-2-1.jpg")
.Build();
var seriesActors = Builder<TvdbActor>
.CreateListOfSize(5)
.All()
.With(a => a.ActorImage = Builder<TvdbActorBanner>.CreateNew().Build())
.Build();
tvdbSeries = Builder<TvdbSeries>
@ -67,9 +67,10 @@ 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.AddRange(seasonBanners);
tvdbSeries.Banners.SeasonBanners.AddRange(seasonBanners);
}
private void WithUseBanners()
@ -82,19 +83,18 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata
var seasonBanners = Builder<TvdbSeasonBanner>
.CreateListOfSize(2)
.All()
.With(b => b.Season = 0)
.With(b => b.SeasonNumber = 0)
.TheFirst(1)
.With(b => b.BannerType = TvdbSeasonBanner.Type.season)
.With(b => b.BannerType = TvdbSeasonBanner.Type.Poster)
.With(b => b.BannerPath = "seasons/79488-0-1.jpg")
.TheLast(1)
.With(b => b.BannerType = TvdbSeasonBanner.Type.seasonwide)
.With(b => b.BannerType = TvdbSeasonBanner.Type.Banner)
.With(b => b.BannerPath = "banners/seasons/79488-0-1.jpg")
.Build();
var seriesActors = Builder<TvdbActor>
.CreateListOfSize(5)
.All()
.With(a => a.ActorImage = Builder<TvdbActorBanner>.CreateNew().Build())
.Build();
tvdbSeries = Builder<TvdbSeries>
@ -102,9 +102,11 @@ 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<String> { "Comedy" })
.Build();
tvdbSeries.Banners.AddRange(seasonBanners);
tvdbSeries.Banners.SeasonBanners.AddRange(seasonBanners);
}
[Test]
@ -124,14 +126,14 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata
public void should_download_fanart()
{
Mocker.Resolve<Xbmc>().CreateForSeries(series, tvdbSeries);
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.FanartPath, Path.Combine(series.Path, "fanart.jpg")), Times.Once());
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.Fanart, Path.Combine(series.Path, "fanart.jpg")), Times.Once());
}
[Test]
public void should_download_poster_when_useBanners_is_false()
{
Mocker.Resolve<Xbmc>().CreateForSeries(series, tvdbSeries);
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.PosterPath, Path.Combine(series.Path, "folder.jpg")), Times.Once());
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.Poster, Path.Combine(series.Path, "folder.jpg")), Times.Once());
}
[Test]
@ -139,7 +141,7 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata
{
WithUseBanners();
Mocker.Resolve<Xbmc>().CreateForSeries(series, tvdbSeries);
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.BannerPath, Path.Combine(series.Path, "folder.jpg")), Times.Once());
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.Banner, Path.Combine(series.Path, "folder.jpg")), Times.Once());
}
[Test]

@ -18,7 +18,6 @@ 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
{

@ -18,7 +18,6 @@ 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
{

@ -18,7 +18,6 @@ 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
{

@ -18,7 +18,6 @@ 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
{

@ -16,7 +16,6 @@ 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
{

@ -10,8 +10,8 @@ using NzbDrone.Common;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
using TvdbLib.Data;
using TvdbLib.Exceptions;
using XemLib.Data;
using XemLib.Exceptions;
namespace NzbDrone.Core.Test.ProviderTests
{
@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[TearDown]
public void TearDown()
{
ExceptionVerification.MarkInconclusive(typeof(TvdbNotAvailableException));
ExceptionVerification.MarkInconclusive(typeof(TheTvbdbUnavailableException));
}
[TestCase("The Simpsons")]
@ -68,58 +68,5 @@ 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<int, List<TvdbEpisode>>(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);
}
}
}
}
}

@ -206,10 +206,6 @@
<Reference Include="System.Web.Extensions" />
<Reference Include="System.XML" />
<Reference Include="System.Xml.Linq" />
<Reference Include="TvdbLib, Version=0.8.8.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\TvdbLib.dll</HintPath>
</Reference>
<Reference Include="Twitterizer2, Version=2.4.0.26532, Culture=neutral, PublicKeyToken=69d1469eac671567, processorArchitecture=MSIL">
<HintPath>..\packages\twitterizer.2.4.0.26532\lib\net40\Twitterizer2.dll</HintPath>
</Reference>
@ -217,6 +213,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\WebActivator.1.5\lib\net40\WebActivator.dll</HintPath>
</Reference>
<Reference Include="XemLib">
<HintPath>..\Libraries\XemLib\XemLib.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\NzbDrone.Common\Properties\SharedAssemblyInfo.cs">

@ -7,7 +7,7 @@ using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
using PetaPoco;
using TvdbLib.Data;
using XemLib.Data;
namespace NzbDrone.Core.Providers
{

@ -4,7 +4,7 @@ using NzbDrone.Common;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using TvdbLib.Data;
using XemLib.Data;
namespace NzbDrone.Core.Providers.Metadata
{

@ -8,8 +8,8 @@ using NzbDrone.Common;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using TvdbLib.Data;
using TvdbLib.Data.Banner;
using XemLib.Data;
using XemLib.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.GenreString.Trim('|').Split('|')[0]));
tvShow.Add(new XElement("genre", tvDbSeries.Genres.FirstOrDefault()));
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.ActorImage.BannerPath)
new XElement("thumb", "http://www.thetvdb.com/banners/" + actor.Image)
));
}
@ -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.FanartPath, Path.Combine(series.Path, "fanart.jpg"));
_bannerProvider.Download(tvDbSeries.Fanart, 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.BannerPath, Path.Combine(series.Path, "folder.jpg"));
_bannerProvider.Download(tvDbSeries.Banner, Path.Combine(series.Path, "folder.jpg"));
_logger.Debug("Downloading Season banners for {0}", series.Title);
DownloadSeasonThumbnails(series, tvDbSeries, TvdbSeasonBanner.Type.seasonwide);
DownloadSeasonThumbnails(series, tvDbSeries, TvdbSeasonBanner.Type.Banner);
}
else
{
_logger.Debug("Downloading series thumbnail for: {0}", series.Title);
_bannerProvider.Download(tvDbSeries.PosterPath, Path.Combine(series.Path, "folder.jpg"));
_bannerProvider.Download(tvDbSeries.Poster, Path.Combine(series.Path, "folder.jpg"));
_logger.Debug("Downloading Season posters for {0}", series.Title);
DownloadSeasonThumbnails(series, tvDbSeries, TvdbSeasonBanner.Type.season);
DownloadSeasonThumbnails(series, tvDbSeries, TvdbSeasonBanner.Type.Poster);
}
}
}
@ -112,7 +112,7 @@ namespace NzbDrone.Core.Providers.Metadata
e.SeasonNumber == episodeFile.SeasonNumber &&
e.EpisodeNumber == episodes.First().EpisodeNumber);
if (episodeFileThumbnail == null || String.IsNullOrWhiteSpace(episodeFileThumbnail.BannerPath))
if (episodeFileThumbnail == null || String.IsNullOrWhiteSpace(episodeFileThumbnail.Banner))
{
_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.BannerPath,
_bannerProvider.Download(episodeFileThumbnail.Banner,
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.BannerPath));
details.Add(new XElement("thumb", "http://www.thetvdb.com/banners/" + tvdbEpisode.Banner));
details.Add(new XElement("watched", "false"));
details.Add(new XElement("credits", tvdbEpisode.Writer.FirstOrDefault()));
details.Add(new XElement("credits", tvdbEpisode.Writers.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.ActorImage.BannerPath)
new XElement("thumb", "http://www.thetvdb.com/banners/" + actor.Image)
));
}
@ -235,11 +235,11 @@ namespace NzbDrone.Core.Providers.Metadata
private void DownloadSeasonThumbnails(Series series, TvdbSeries tvDbSeries, TvdbSeasonBanner.Type bannerType)
{
var seasons = tvDbSeries.SeasonBanners.Where(s => s.BannerType == bannerType).Select(s => s.Season);
var seasons = tvDbSeries.Banners.SeasonBanners.Where(s => s.BannerType == bannerType).Select(s => s.SeasonNumber);
foreach (var season in seasons)
{
var banner = tvDbSeries.SeasonBanners.FirstOrDefault(b => b.BannerType == bannerType && b.Season == season);
var banner = tvDbSeries.Banners.SeasonBanners.FirstOrDefault(b => b.BannerType == bannerType && b.SeasonNumber == season);
_logger.Debug("Downloading banner for Season: {0} Series: {1}", season, series.Title);
if (season == 0)

@ -8,7 +8,7 @@ using NzbDrone.Core.Providers.ExternalNotification;
using NzbDrone.Core.Providers.Metadata;
using NzbDrone.Core.Repository;
using PetaPoco;
using TvdbLib.Data;
using XemLib.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);
var tvDbSeries = _tvDbProvider.GetSeries(series.SeriesId, false, true, 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);
var tvDbSeries = _tvDbProvider.GetSeries(episodeFile.SeriesId, true, 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);
var tvDbSeries = _tvDbProvider.GetSeries(episodeFiles.First().SeriesId, true, true, true);
foreach(var episodeFile in episodeFiles)
{

@ -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.Abbriviation : string.Empty;
series.Language = tvDbSeries.Language != null ? tvDbSeries.Language : string.Empty;
series.CleanTitle = Parser.NormalizeTitle(tvDbSeries.SeriesName);
series.LastInfoSync = DateTime.Now;
series.Runtime = (int)tvDbSeries.Runtime;
series.BannerUrl = tvDbSeries.BannerPath;
series.BannerUrl = tvDbSeries.Banner;
series.Network = tvDbSeries.Network;
UpdateSeries(series);

@ -5,9 +5,8 @@ using System.Text.RegularExpressions;
using NLog;
using Ninject;
using NzbDrone.Common;
using TvdbLib;
using TvdbLib.Cache;
using TvdbLib.Data;
using XemLib;
using XemLib.Data;
namespace NzbDrone.Core.Providers
{
@ -17,13 +16,13 @@ namespace NzbDrone.Core.Providers
public const string TVDB_APIKEY = "5D2D188E86E07F4F";
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly TvdbHandler _handler;
private readonly XemClient _xemClient;
[Inject]
public TvDbProvider(EnvironmentProvider environmentProvider)
{
_environmentProvider = environmentProvider;
_handler = new TvdbHandler(new XmlCacheProvider(_environmentProvider.GetCacheFolder()), TVDB_APIKEY);
_xemClient = new XemClient(TVDB_APIKEY);
}
public TvDbProvider()
@ -33,57 +32,27 @@ namespace NzbDrone.Core.Providers
public virtual IList<TvdbSearchResult> SearchSeries(string title)
{
lock (_handler)
{
Logger.Debug("Searching TVDB for '{0}'", title);
Logger.Debug("Searching TVDB for '{0}'", title);
var result = _handler.SearchSeries(title);
var result = _xemClient.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)
public virtual TvdbSeries GetSeries(int id, bool loadEpisodes, bool loadActors = false, bool loadBanners = false)
{
lock (_handler)
{
Logger.Debug("Fetching SeriesId'{0}' from tvdb", id);
var result = _handler.GetSeries(id, TvdbLanguage.DefaultLanguage, loadEpisodes, loadActors, true, true);
Logger.Debug("Fetching SeriesId'{0}' from tvdb", id);
var result = _xemClient.GetSeries(id, loadEpisodes, loadActors, true, TvdbLanguage.Default);
//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();
//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());
var seasonOneEpisodeCount = result.Episodes.Where(e => e.SeasonNumber == 1).Count();
var seasonOneId = result.Episodes.Where(e => e.SeasonNumber == 1).First().SeasonId;
result.Episodes = episodes.ToList();
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;
}
return result;
}
}
}

@ -12,7 +12,7 @@ using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Web.Filters;
using NzbDrone.Web.Models;
using TvdbLib.Exceptions;
using XemLib.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.BannerPath,
Banner = r.Banner,
Url = String.Format("http://www.thetvdb.com/?tab=series&id={0}", r.Id)
}).ToList();
return Json(tvDbResults, JsonRequestBehavior.AllowGet);
}
catch(TvdbNotAvailableException ex)
catch (TheTvbdbUnavailableException ex)
{
logger.WarnException("Unable to lookup series on TheTVDB", ex);
return JsonNotificationResult.Info("Lookup Failed", "TheTVDB is not available at this time.");

@ -138,14 +138,14 @@
<Private>True</Private>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="TvdbLib, Version=0.8.8.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\TvdbLib.dll</HintPath>
</Reference>
<Reference Include="WebActivator, Version=1.5.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\WebActivator.1.5.1\lib\net40\WebActivator.dll</HintPath>
</Reference>
<Reference Include="XemLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\XemLib\XemLib.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="App_Start\DataTablesMvc.cs" />

Loading…
Cancel
Save