diff --git a/src/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs b/src/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs index 88e75621e..b59520dec 100644 --- a/src/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests } [Test] - public void should_convert_trakts_urls_to_local() + public void should_convert_cover_urls_to_local() { var covers = new List { @@ -41,7 +41,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests } [Test] - public void should_convert_trakts_urls_to_local_without_time_if_file_doesnt_exist() + public void should_convert_media_urls_to_local_without_time_if_file_doesnt_exist() { var covers = new List { diff --git a/src/NzbDrone.Core.Test/MetadataSourceTests/TraktSearchSeriesComparerFixture.cs b/src/NzbDrone.Core.Test/MetadataSourceTests/SearchSeriesComparerFixture.cs similarity index 82% rename from src/NzbDrone.Core.Test/MetadataSourceTests/TraktSearchSeriesComparerFixture.cs rename to src/NzbDrone.Core.Test/MetadataSourceTests/SearchSeriesComparerFixture.cs index 383edc93e..734f814f3 100644 --- a/src/NzbDrone.Core.Test/MetadataSourceTests/TraktSearchSeriesComparerFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSourceTests/SearchSeriesComparerFixture.cs @@ -9,7 +9,7 @@ using NzbDrone.Core.Tv; namespace NzbDrone.Core.Test.MetadataSourceTests { [TestFixture] - public class TraktSearchSeriesComparerFixture : CoreTest + public class SearchSeriesComparerFixture : CoreTest { private List _series; @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.MetadataSourceTests WithSeries("Talking Dead"); WithSeries("The Walking Dead"); - _series.Sort(new TraktSearchSeriesComparer("the walking dead")); + _series.Sort(new SearchSeriesComparer("the walking dead")); _series.First().Title.Should().Be("The Walking Dead"); } @@ -41,7 +41,7 @@ namespace NzbDrone.Core.Test.MetadataSourceTests WithSeries("Talking Dead"); WithSeries("The Walking Dead"); - _series.Sort(new TraktSearchSeriesComparer("walking dead")); + _series.Sort(new SearchSeriesComparer("walking dead")); _series.First().Title.Should().Be("The Walking Dead"); } @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.MetadataSourceTests WithSeries("The Blacklist"); WithSeries("Blacklist"); - _series.Sort(new TraktSearchSeriesComparer("blacklist")); + _series.Sort(new SearchSeriesComparer("blacklist")); _series.First().Title.Should().Be("Blacklist"); } @@ -63,7 +63,7 @@ namespace NzbDrone.Core.Test.MetadataSourceTests WithSeries("Blacklist"); WithSeries("The Blacklist"); - _series.Sort(new TraktSearchSeriesComparer("the blacklist")); + _series.Sort(new SearchSeriesComparer("the blacklist")); _series.First().Title.Should().Be("The Blacklist"); } diff --git a/src/NzbDrone.Core.Test/MetadataSourceTests/TraktProxyFixture.cs b/src/NzbDrone.Core.Test/MetadataSourceTests/TraktProxyFixture.cs deleted file mode 100644 index 307e23928..000000000 --- a/src/NzbDrone.Core.Test/MetadataSourceTests/TraktProxyFixture.cs +++ /dev/null @@ -1,138 +0,0 @@ -/* -using System; -using System.Collections.Generic; -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Http; -using NzbDrone.Core.MediaCover; -using NzbDrone.Core.MetadataSource; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Test.Common; -using NzbDrone.Test.Common.Categories; - -namespace NzbDrone.Core.Test.MetadataSourceTests -{ - [TestFixture] - [IntegrationTest] - public class TraktProxyFixture : CoreTest - { - [SetUp] - public void Setup() - { - UseRealHttp(); - } - - [TestCase("The Simpsons", "The Simpsons")] - [TestCase("South Park", "South Park")] - [TestCase("Franklin & Bash", "Franklin & Bash")] - [TestCase("Mr. D", "Mr. D")] - [TestCase("Rob & Big", "Rob and Big")] - [TestCase("M*A*S*H", "M*A*S*H")] - [TestCase("imdb:tt0436992", "Doctor Who (2005)")] - [TestCase("tvdb:78804", "Doctor Who (2005)")] - public void successful_search(string title, string expected) - { - var result = Subject.SearchForNewSeries(title); - - result.Should().NotBeEmpty(); - - result[0].Title.Should().Be(expected); - } - - [Test] - public void no_search_result() - { - var result = Subject.SearchForNewSeries(Guid.NewGuid().ToString()); - result.Should().BeEmpty(); - } - - [TestCase(75978, "Family Guy")] - [TestCase(83462, "Castle (2009)")] - [TestCase(266189, "The Blacklist")] - public void should_be_able_to_get_series_detail(Int32 tvdbId, String title) - { - var details = Subject.GetSeriesInfo(tvdbId); - - ValidateSeries(details.Item1); - ValidateEpisodes(details.Item2); - - details.Item1.Title.Should().Be(title); - } - - [Test] - public void getting_details_of_invalid_series() - { - Assert.Throws(() => Subject.GetSeriesInfo(Int32.MaxValue)); - - ExceptionVerification.ExpectedWarns(1); - } - - [Test] - public void should_not_have_period_at_start_of_title_slug() - { - var details = Subject.GetSeriesInfo(79099); - - details.Item1.TitleSlug.Should().Be("dothack"); - } - - private void ValidateSeries(Series series) - { - series.Should().NotBeNull(); - series.Title.Should().NotBeNullOrWhiteSpace(); - series.CleanTitle.Should().Be(Parser.Parser.CleanSeriesTitle(series.Title)); - series.SortTitle.Should().Be(SeriesTitleNormalizer.Normalize(series.Title, series.TvdbId)); - series.Overview.Should().NotBeNullOrWhiteSpace(); - series.AirTime.Should().NotBeNullOrWhiteSpace(); - series.FirstAired.Should().HaveValue(); - series.FirstAired.Value.Kind.Should().Be(DateTimeKind.Utc); - series.Images.Should().NotBeEmpty(); - series.ImdbId.Should().NotBeNullOrWhiteSpace(); - series.Network.Should().NotBeNullOrWhiteSpace(); - series.Runtime.Should().BeGreaterThan(0); - series.TitleSlug.Should().NotBeNullOrWhiteSpace(); - series.TvRageId.Should().BeGreaterThan(0); - series.TvdbId.Should().BeGreaterThan(0); - } - - private void ValidateEpisodes(List episodes) - { - episodes.Should().NotBeEmpty(); - - var episodeGroup= episodes.GroupBy(e => e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000")); - episodeGroup.Should().OnlyContain(c=>c.Count() == 1); - - episodes.Should().Contain(c => c.SeasonNumber > 0); - episodes.Should().Contain(c => !string.IsNullOrWhiteSpace(c.Overview)); - - foreach (var episode in episodes) - { - ValidateEpisode(episode); - - //if atleast one episdoe has title it means parse it working. - episodes.Should().Contain(c => !string.IsNullOrWhiteSpace(c.Title)); - } - } - - private void ValidateEpisode(Episode episode) - { - episode.Should().NotBeNull(); - - //TODO: Is there a better way to validate that episode number or season number is greater than zero? - (episode.EpisodeNumber + episode.SeasonNumber).Should().NotBe(0); - - episode.Should().NotBeNull(); - - if (episode.AirDateUtc.HasValue) - { - episode.AirDateUtc.Value.Kind.Should().Be(DateTimeKind.Utc); - } - - episode.Images.Any(i => i.CoverType == MediaCoverTypes.Screenshot && i.Url.Contains("-940.")) - .Should() - .BeFalse(); - } - } -} -*/ diff --git a/src/NzbDrone.Core.Test/MetadataSourceTests/TraktProxyQueryFixture.cs b/src/NzbDrone.Core.Test/MetadataSourceTests/TraktProxyQueryFixture.cs deleted file mode 100644 index 0248ec4ca..000000000 --- a/src/NzbDrone.Core.Test/MetadataSourceTests/TraktProxyQueryFixture.cs +++ /dev/null @@ -1,69 +0,0 @@ -//using System; -//using System.Collections.Generic; -//using Moq; -//using NUnit.Framework; -//using NzbDrone.Common.Http; -//using NzbDrone.Core.MetadataSource; -//using NzbDrone.Core.MetadataSource.Trakt; -//using NzbDrone.Core.Test.Framework; -//using NzbDrone.Test.Common; -// -//namespace NzbDrone.Core.Test.MetadataSourceTests -//{ -// [TestFixture] -// public class TraktProxyQueryFixture : CoreTest -// { -// [TestCase("tvdb:78804", "/78804/")] -// [TestCase("TVDB:78804", "/78804/")] -// [TestCase("TVDB: 78804 ", "/78804/")] -// public void search_by_lookup(string title, string expectedPartialQuery) -// { -// Assert.Throws(() => Subject.SearchForNewSeries(title)); -// -// Mocker.GetMock() -// .Verify(v => v.Get(It.Is(d => d.Url.ToString().Contains(expectedPartialQuery))), Times.Once()); -// -// ExceptionVerification.ExpectedWarns(1); -// } -// -// [TestCase("imdb:tt0436992", "tt0436992")] -// [TestCase("imdb:0436992", "tt0436992")] -// [TestCase("IMDB:0436992", "tt0436992")] -// [TestCase("IMDB: 0436992 ", "tt0436992")] -//// [TestCase("The BigBangTheory", "the+bigbangtheory")] -//// [TestCase("TheBigBangTheory", "the+big+bang+theory")] -//// [TestCase(" TheBigBangTheory", "the+big+bang+theory")] -// [TestCase("Agents of S.H.I.E.L.D.", "agents+of+s.h.i.e.l.d.")] -// [TestCase("Marvel's Agents of S.H.I.E.L.D.", "marvels+agents+of+s.h.i.e.l.d.")] -//// [TestCase("Marvel'sAgentsOfS.H.I.E.L.D.", "marvels+agents+of+s.h.i.e.l.d.")] -// [TestCase("Utopia (US) (2014)", "utopia+us+2014")] -// [TestCase("Utopia US 2014", "utopia+us+2014")] -//// [TestCase("UtopiaUS2014", "utopia+us+2014")] -// [TestCase("@Midnight", "midnight")] -//// [TestCase("The4400", "the+4400")] -//// [TestCase("StargateSG-1", "stargate+sg-1")] -//// [TestCase("Warehouse13", "warehouse+13")] -//// [TestCase("Ben10AlienForce", "ben+10+alien+force")] -//// [TestCase("FridayThe13thTheSeries","friday+the+13th+the+series")] -// [TestCase("W1A", "w1a")] -// [TestCase("O2Be", "o2be")] -//// [TestCase("TeenMom2", "teen+mom+2")] -// [TestCase("123-456-789", "123-456-789")] -//// [TestCase("BuckRodgersInThe25thCentury", "buck+rodgers+in+the+25th+century")] -//// [TestCase("EPDaily", "ep+daily")] -// [TestCase("6ad072c8-d000-4ed5-97d5-324858c45774", "6ad072c8-d000-4ed5-97d5-324858c45774")] -// [TestCase("6AD072C8-D000-4ED5-97D5-324858C45774", "6ad072c8-d000-4ed5-97d5-324858c45774")] -// [TestCase("MythBusters", "mythbusters")] -// public void search_by_query(string title, string expectedPartialQuery) -// { -// expectedPartialQuery = String.Format("query={0}&", expectedPartialQuery); -// -// Assert.Throws(() => Subject.SearchForNewSeries(title)); -// -// Mocker.GetMock() -// .Verify(v => v.Get>(It.Is(d => d.Url.ToString().Contains(expectedPartialQuery))), Times.Once()); -// -// ExceptionVerification.ExpectedWarns(1); -// } -// } -//} diff --git a/src/NzbDrone.Core.Test/MetadataSourceTests/TvdbDataProxyFixture.cs b/src/NzbDrone.Core.Test/MetadataSourceTests/TvdbDataProxyFixture.cs index fee5c4785..3679dba36 100644 --- a/src/NzbDrone.Core.Test/MetadataSourceTests/TvdbDataProxyFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSourceTests/TvdbDataProxyFixture.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Net; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Common.Http; using NzbDrone.Core.MediaCover; using NzbDrone.Core.MetadataSource; using NzbDrone.Core.Test.Framework; @@ -42,17 +41,22 @@ namespace NzbDrone.Core.Test.MetadataSourceTests result.Should().NotBeEmpty(); result[0].Title.Should().Be(expected); + + ExceptionVerification.IgnoreWarns(); } [TestCase("tvdbid:")] [TestCase("tvdbid: 99999999999999999999")] [TestCase("tvdbid: 0")] [TestCase("tvdbid: -12")] + [TestCase("tvdbid:289578")] [TestCase("adjalkwdjkalwdjklawjdlKAJD;EF")] public void no_search_result(string term) { var result = Subject.SearchForNewSeries(term); result.Should().BeEmpty(); + + ExceptionVerification.IgnoreWarns(); } [TestCase(75978, "Family Guy")] @@ -71,9 +75,9 @@ namespace NzbDrone.Core.Test.MetadataSourceTests [Test] public void getting_details_of_invalid_series() { - Assert.Throws(() => Subject.GetSeriesInfo(Int32.MaxValue)); + Assert.Throws(() => Subject.GetSeriesInfo(Int32.MaxValue)); - //ExceptionVerification.ExpectedWarns(1); + ExceptionVerification.ExpectedWarns(1); } [Test] diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index c74ade20b..36cfef615 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -228,7 +228,7 @@ - + @@ -247,8 +247,6 @@ - - diff --git a/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs b/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs index 2a64711dc..6659777c0 100644 --- a/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs +++ b/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs @@ -108,7 +108,7 @@ namespace NzbDrone.Core.Test.TvTests } [Test] - public void should_delete_all_when_all_existing_episodes_are_gone_from_trakt() + public void should_delete_all_when_all_existing_episodes_are_gone_from_datasource() { Mocker.GetMock().Setup(c => c.GetEpisodeBySeries(It.IsAny())) .Returns(GetEpisodes()); diff --git a/src/NzbDrone.Core/MetadataSource/TraktSearchSeriesComparer.cs b/src/NzbDrone.Core/MetadataSource/SearchSeriesComparer.cs similarity index 96% rename from src/NzbDrone.Core/MetadataSource/TraktSearchSeriesComparer.cs rename to src/NzbDrone.Core/MetadataSource/SearchSeriesComparer.cs index b3c31cba4..ba8121c47 100644 --- a/src/NzbDrone.Core/MetadataSource/TraktSearchSeriesComparer.cs +++ b/src/NzbDrone.Core/MetadataSource/SearchSeriesComparer.cs @@ -6,7 +6,7 @@ using NzbDrone.Core.Tv; namespace NzbDrone.Core.MetadataSource { - public class TraktSearchSeriesComparer : IComparer + public class SearchSeriesComparer : IComparer { private static readonly Regex RegexCleanPunctuation = new Regex("[-._:]", RegexOptions.Compiled); private static readonly Regex RegexCleanCountryYearPostfix = new Regex(@"(?<=.+)( \([A-Z]{2}\)| \(\d{4}\)| \([A-Z]{2}\) \(\d{4}\))$", RegexOptions.Compiled); @@ -14,10 +14,10 @@ namespace NzbDrone.Core.MetadataSource public String SearchQuery { get; private set; } - private String _searchQueryWithoutYear; + private readonly String _searchQueryWithoutYear; private Int32? _year; - public TraktSearchSeriesComparer(String searchQuery) + public SearchSeriesComparer(String searchQuery) { SearchQuery = searchQuery; diff --git a/src/NzbDrone.Core/MetadataSource/Trakt/Actor.cs b/src/NzbDrone.Core/MetadataSource/Trakt/Actor.cs deleted file mode 100644 index 6a775136f..000000000 --- a/src/NzbDrone.Core/MetadataSource/Trakt/Actor.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace NzbDrone.Core.MetadataSource.Trakt -{ - public class Actor - { - public string name { get; set; } - public string character { get; set; } - public Images images { get; set; } - } -} diff --git a/src/NzbDrone.Core/MetadataSource/Trakt/Episode.cs b/src/NzbDrone.Core/MetadataSource/Trakt/Episode.cs deleted file mode 100644 index 302fb49ef..000000000 --- a/src/NzbDrone.Core/MetadataSource/Trakt/Episode.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace NzbDrone.Core.MetadataSource.Trakt -{ - public class Episode - { - public int season { get; set; } - public int episode { get; set; } - public int number { get; set; } - public int tvdb_id { get; set; } - public string title { get; set; } - public string overview { get; set; } - public int first_aired { get; set; } - public string first_aired_iso { get; set; } - public int first_aired_utc { get; set; } - public string url { get; set; } - public string screen { get; set; } - public Ratings ratings { get; set; } - public Images images { get; set; } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MetadataSource/Trakt/FullShow.cs b/src/NzbDrone.Core/MetadataSource/Trakt/FullShow.cs deleted file mode 100644 index d94675b26..000000000 --- a/src/NzbDrone.Core/MetadataSource/Trakt/FullShow.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Collections.Generic; - -namespace NzbDrone.Core.MetadataSource.Trakt -{ - public class Show - { - public string title { get; set; } - public int year { get; set; } - public string url { get; set; } - public int first_aired { get; set; } - public string first_aired_iso { get; set; } - public int first_aired_utc { get; set; } - public string country { get; set; } - public string overview { get; set; } - public int runtime { get; set; } - public string status { get; set; } - public string network { get; set; } - public string air_day { get; set; } - public string air_day_utc { get; set; } - public string air_time { get; set; } - public string air_time_utc { get; set; } - public string certification { get; set; } - public string imdb_id { get; set; } - public int tvdb_id { get; set; } - public int tvrage_id { get; set; } - public int last_updated { get; set; } - public string poster { get; set; } - public bool? ended { get; set; } - public Images images { get; set; } - public List genres { get; set; } - public List seasons { get; set; } - public Ratings ratings { get; set; } - public People people { get; set; } - } - - public class SearchShow - { - public string title { get; set; } - public int year { get; set; } - public string url { get; set; } - public int first_aired { get; set; } - public string first_aired_iso { get; set; } - public int first_aired_utc { get; set; } - public string country { get; set; } - public string overview { get; set; } - public int runtime { get; set; } - public string status { get; set; } - public string network { get; set; } - public string air_day { get; set; } - public string air_day_utc { get; set; } - public string air_time { get; set; } - public string air_time_utc { get; set; } - public string certification { get; set; } - public string imdb_id { get; set; } - public int tvdb_id { get; set; } - public int tvrage_id { get; set; } - public int last_updated { get; set; } - public string poster { get; set; } - public Images images { get; set; } - public List genres { get; set; } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MetadataSource/Trakt/Images.cs b/src/NzbDrone.Core/MetadataSource/Trakt/Images.cs deleted file mode 100644 index aa8b15374..000000000 --- a/src/NzbDrone.Core/MetadataSource/Trakt/Images.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace NzbDrone.Core.MetadataSource.Trakt -{ - public class Images - { - public string poster { get; set; } - public string fanart { get; set; } - public string banner { get; set; } - public string screen { get; set; } - public string headshot { get; set; } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MetadataSource/Trakt/People.cs b/src/NzbDrone.Core/MetadataSource/Trakt/People.cs deleted file mode 100644 index 31d736178..000000000 --- a/src/NzbDrone.Core/MetadataSource/Trakt/People.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Collections.Generic; - -namespace NzbDrone.Core.MetadataSource.Trakt -{ - public class People - { - public List actors { get; set; } - } -} diff --git a/src/NzbDrone.Core/MetadataSource/Trakt/Ratings.cs b/src/NzbDrone.Core/MetadataSource/Trakt/Ratings.cs deleted file mode 100644 index 6302071eb..000000000 --- a/src/NzbDrone.Core/MetadataSource/Trakt/Ratings.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace NzbDrone.Core.MetadataSource.Trakt -{ - public class Ratings - { - public Int32 percentage { get; set; } - public Int32 votes { get; set; } - public Int32 loved { get; set; } - public Int32 hated { get; set; } - } -} diff --git a/src/NzbDrone.Core/MetadataSource/Trakt/Season.cs b/src/NzbDrone.Core/MetadataSource/Trakt/Season.cs deleted file mode 100644 index ac9bad579..000000000 --- a/src/NzbDrone.Core/MetadataSource/Trakt/Season.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; - -namespace NzbDrone.Core.MetadataSource.Trakt -{ - public class Season - { - public int season { get; set; } - public List episodes { get; set; } - public string url { get; set; } - public string poster { get; set; } - public Images images { get; set; } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/MetadataSource/Trakt/TraktException.cs b/src/NzbDrone.Core/MetadataSource/Trakt/TraktException.cs deleted file mode 100644 index 3d51fe8ab..000000000 --- a/src/NzbDrone.Core/MetadataSource/Trakt/TraktException.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Net; -using NzbDrone.Core.Exceptions; - -namespace NzbDrone.Core.MetadataSource.Trakt -{ - public class TraktException : NzbDroneClientException - { - public TraktException(string message) : base(HttpStatusCode.ServiceUnavailable, message) - { - } - - public TraktException(string message, params object[] args) : base(HttpStatusCode.ServiceUnavailable, message, args) - { - } - } -} diff --git a/src/NzbDrone.Core/MetadataSource/TvDbProxy.cs b/src/NzbDrone.Core/MetadataSource/TvDbProxy.cs index 5561cbcf7..784be099c 100644 --- a/src/NzbDrone.Core/MetadataSource/TvDbProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/TvDbProxy.cs @@ -7,7 +7,7 @@ using System.Web; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.MediaCover; -using NzbDrone.Core.MetadataSource.Trakt; +using NzbDrone.Core.MetadataSource.Tvdb; using NzbDrone.Core.Tv; using TVDBSharp; using TVDBSharp.Models.Enums; @@ -28,7 +28,7 @@ namespace NzbDrone.Core.MetadataSource _tvdb = new TVDB("5D2D188E86E07F4F"); } - private IEnumerable SearchTrakt(string title) + private IEnumerable SearchTvdb(string title) { var lowerTitle = title.ToLowerInvariant(); @@ -47,11 +47,9 @@ namespace NzbDrone.Core.MetadataSource { return new[] { _tvdb.GetShow(tvdbId) }; } - catch (WebException ex) + catch (Common.Http.HttpException ex) { - var resp = ex.Response as HttpWebResponse; - - if (resp != null && resp.StatusCode == HttpStatusCode.NotFound) + if (ex.Response.StatusCode == HttpStatusCode.NotFound) { return Enumerable.Empty(); } @@ -67,22 +65,22 @@ namespace NzbDrone.Core.MetadataSource { try { - var tvdbSeries = SearchTrakt(title.Trim()); + var tvdbSeries = SearchTvdb(title.Trim()); var series = tvdbSeries.Select(MapSeries).ToList(); - series.Sort(new TraktSearchSeriesComparer(title)); + series.Sort(new SearchSeriesComparer(title)); return series; } catch (Common.Http.HttpException) { - throw new TraktException("Search for '{0}' failed. Unable to communicate with Trakt.", title); + throw new TvdbException("Search for '{0}' failed. Unable to communicate with TVDB.", title); } catch (Exception ex) { _logger.WarnException(ex.Message, ex); - throw new TraktException("Search for '{0}' failed. Invalid response received from Trakt.", title); + throw new TvdbException("Search for '{0}' failed. Invalid response received from TVDB.", title); } } diff --git a/src/NzbDrone.Core/MetadataSource/Tvdb/TvdbException.cs b/src/NzbDrone.Core/MetadataSource/Tvdb/TvdbException.cs new file mode 100644 index 000000000..a87b6aaf4 --- /dev/null +++ b/src/NzbDrone.Core/MetadataSource/Tvdb/TvdbException.cs @@ -0,0 +1,16 @@ +using System.Net; +using NzbDrone.Core.Exceptions; + +namespace NzbDrone.Core.MetadataSource.Tvdb +{ + public class TvdbException : NzbDroneClientException + { + public TvdbException(string message) : base(HttpStatusCode.ServiceUnavailable, message) + { + } + + public TvdbException(string message, params object[] args) : base(HttpStatusCode.ServiceUnavailable, message, args) + { + } + } +} diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 7762523ee..21c9c4d43 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -597,7 +597,7 @@ - + @@ -623,14 +623,7 @@ - - - - - - - - + diff --git a/src/NzbDrone.Integration.Test/SeriesIntegrationTest.cs b/src/NzbDrone.Integration.Test/SeriesIntegrationTest.cs index 9700b898f..9e9a33a80 100644 --- a/src/NzbDrone.Integration.Test/SeriesIntegrationTest.cs +++ b/src/NzbDrone.Integration.Test/SeriesIntegrationTest.cs @@ -11,7 +11,7 @@ namespace NzbDrone.Integration.Test public class SeriesIntegrationTest : IntegrationTest { [Test] - public void series_lookup_on_trakt() + public void series_lookup_on_tvdb() { var series = Series.Lookup("archer"); diff --git a/src/TVDBSharp/Models/Builder.cs b/src/TVDBSharp/Models/Builder.cs index 72f307a9e..c8d2d02fd 100644 --- a/src/TVDBSharp/Models/Builder.cs +++ b/src/TVDBSharp/Models/Builder.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Net; using System.Xml.Linq; +using NzbDrone.Common.Http; using TVDBSharp.Models.DAO; using TVDBSharp.Models.Enums; using TVDBSharp.Utilities; @@ -69,7 +70,7 @@ namespace TVDBSharp.Models var response = _dataProvider.GetShow(id); shows.Add(new ShowBuilder(response).GetResult()); } - catch (WebException ex) + catch (HttpException ex) { } diff --git a/src/TVDBSharp/Models/DAO/DataProvider.cs b/src/TVDBSharp/Models/DAO/DataProvider.cs index e79a05f10..bcd6aa45c 100644 --- a/src/TVDBSharp/Models/DAO/DataProvider.cs +++ b/src/TVDBSharp/Models/DAO/DataProvider.cs @@ -1,6 +1,8 @@ using System.IO; using System.Net; using System.Xml.Linq; +using NzbDrone.Common.Http; +using NzbDrone.Common.Instrumentation; using TVDBSharp.Models.Enums; namespace TVDBSharp.Models.DAO @@ -13,6 +15,9 @@ namespace TVDBSharp.Models.DAO public string ApiKey { get; set; } private const string BaseUrl = "http://thetvdb.com"; + + private static HttpClient httpClient = new HttpClient(NzbDroneLogger.GetLogger(typeof(DataProvider))); + public XDocument GetShow(int showID) { return GetXDocumentFromUrl(string.Format("{0}/api/{1}/series/{2}/all/", BaseUrl, ApiKey, showID)); @@ -35,9 +40,15 @@ namespace TVDBSharp.Models.DAO private static XDocument GetXDocumentFromUrl(string url) { - using (var web = new WebClient()) - using (var memoryStream = new MemoryStream(web.DownloadData(url))) - return XDocument.Load(memoryStream); + + var request = new HttpRequest(url, new HttpAccept("application/xml")); + + + + var response = httpClient.Get(request); + + return XDocument.Parse(response.Content); + } } } \ No newline at end of file diff --git a/src/TVDBSharp/TVDBSharp.csproj b/src/TVDBSharp/TVDBSharp.csproj index 7f2ce9bae..ce6172f43 100644 --- a/src/TVDBSharp/TVDBSharp.csproj +++ b/src/TVDBSharp/TVDBSharp.csproj @@ -36,6 +36,9 @@ MinimumRecommendedRules.ruleset + + ..\packages\NLog.2.1.0\lib\net40\NLog.dll + @@ -63,6 +66,12 @@ + + + {F2BE0FDF-6E47-4827-A420-DD4EF82407F8} + NzbDrone.Common + +