removed trakt references, added user agent to tvdb requests

pull/2/head
Keivan Beigi 10 years ago
parent 7e76a36d68
commit d4331e9470

@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
} }
[Test] [Test]
public void should_convert_trakts_urls_to_local() public void should_convert_cover_urls_to_local()
{ {
var covers = new List<MediaCover.MediaCover> var covers = new List<MediaCover.MediaCover>
{ {
@ -41,7 +41,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
} }
[Test] [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<MediaCover.MediaCover> var covers = new List<MediaCover.MediaCover>
{ {

@ -9,7 +9,7 @@ using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.MetadataSourceTests namespace NzbDrone.Core.Test.MetadataSourceTests
{ {
[TestFixture] [TestFixture]
public class TraktSearchSeriesComparerFixture : CoreTest public class SearchSeriesComparerFixture : CoreTest
{ {
private List<Series> _series; private List<Series> _series;
@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.MetadataSourceTests
WithSeries("Talking Dead"); WithSeries("Talking Dead");
WithSeries("The Walking 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"); _series.First().Title.Should().Be("The Walking Dead");
} }
@ -41,7 +41,7 @@ namespace NzbDrone.Core.Test.MetadataSourceTests
WithSeries("Talking Dead"); WithSeries("Talking Dead");
WithSeries("The Walking 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"); _series.First().Title.Should().Be("The Walking Dead");
} }
@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.MetadataSourceTests
WithSeries("The Blacklist"); WithSeries("The Blacklist");
WithSeries("Blacklist"); WithSeries("Blacklist");
_series.Sort(new TraktSearchSeriesComparer("blacklist")); _series.Sort(new SearchSeriesComparer("blacklist"));
_series.First().Title.Should().Be("Blacklist"); _series.First().Title.Should().Be("Blacklist");
} }
@ -63,7 +63,7 @@ namespace NzbDrone.Core.Test.MetadataSourceTests
WithSeries("Blacklist"); WithSeries("Blacklist");
WithSeries("The Blacklist"); WithSeries("The Blacklist");
_series.Sort(new TraktSearchSeriesComparer("the blacklist")); _series.Sort(new SearchSeriesComparer("the blacklist"));
_series.First().Title.Should().Be("The Blacklist"); _series.First().Title.Should().Be("The Blacklist");
} }

@ -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<TraktProxy>
{
[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<HttpException>(() => 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<Episode> 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();
}
}
}
*/

@ -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<TraktProxy>
// {
// [TestCase("tvdb:78804", "/78804/")]
// [TestCase("TVDB:78804", "/78804/")]
// [TestCase("TVDB: 78804 ", "/78804/")]
// public void search_by_lookup(string title, string expectedPartialQuery)
// {
// Assert.Throws<TraktException>(() => Subject.SearchForNewSeries(title));
//
// Mocker.GetMock<IHttpClient>()
// .Verify(v => v.Get<Show>(It.Is<HttpRequest>(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<TraktException>(() => Subject.SearchForNewSeries(title));
//
// Mocker.GetMock<IHttpClient>()
// .Verify(v => v.Get<List<Show>>(It.Is<HttpRequest>(d => d.Url.ToString().Contains(expectedPartialQuery))), Times.Once());
//
// ExceptionVerification.ExpectedWarns(1);
// }
// }
//}

@ -4,7 +4,6 @@ using System.Linq;
using System.Net; using System.Net;
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common.Http;
using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource; using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
@ -42,17 +41,22 @@ namespace NzbDrone.Core.Test.MetadataSourceTests
result.Should().NotBeEmpty(); result.Should().NotBeEmpty();
result[0].Title.Should().Be(expected); result[0].Title.Should().Be(expected);
ExceptionVerification.IgnoreWarns();
} }
[TestCase("tvdbid:")] [TestCase("tvdbid:")]
[TestCase("tvdbid: 99999999999999999999")] [TestCase("tvdbid: 99999999999999999999")]
[TestCase("tvdbid: 0")] [TestCase("tvdbid: 0")]
[TestCase("tvdbid: -12")] [TestCase("tvdbid: -12")]
[TestCase("tvdbid:289578")]
[TestCase("adjalkwdjkalwdjklawjdlKAJD;EF")] [TestCase("adjalkwdjkalwdjklawjdlKAJD;EF")]
public void no_search_result(string term) public void no_search_result(string term)
{ {
var result = Subject.SearchForNewSeries(term); var result = Subject.SearchForNewSeries(term);
result.Should().BeEmpty(); result.Should().BeEmpty();
ExceptionVerification.IgnoreWarns();
} }
[TestCase(75978, "Family Guy")] [TestCase(75978, "Family Guy")]
@ -71,9 +75,9 @@ namespace NzbDrone.Core.Test.MetadataSourceTests
[Test] [Test]
public void getting_details_of_invalid_series() public void getting_details_of_invalid_series()
{ {
Assert.Throws<WebException>(() => Subject.GetSeriesInfo(Int32.MaxValue)); Assert.Throws<Common.Http.HttpException>(() => Subject.GetSeriesInfo(Int32.MaxValue));
//ExceptionVerification.ExpectedWarns(1); ExceptionVerification.ExpectedWarns(1);
} }
[Test] [Test]

@ -228,7 +228,7 @@
<Compile Include="MediaFiles\ImportApprovedEpisodesFixture.cs" /> <Compile Include="MediaFiles\ImportApprovedEpisodesFixture.cs" />
<Compile Include="MediaFiles\MediaFileRepositoryFixture.cs" /> <Compile Include="MediaFiles\MediaFileRepositoryFixture.cs" />
<Compile Include="MetadataSourceTests\TvdbDataProxyFixture.cs" /> <Compile Include="MetadataSourceTests\TvdbDataProxyFixture.cs" />
<Compile Include="MetadataSourceTests\TraktSearchSeriesComparerFixture.cs" /> <Compile Include="MetadataSourceTests\SearchSeriesComparerFixture.cs" />
<Compile Include="OrganizerTests\FileNameBuilderTests\CleanTitleFixture.cs" /> <Compile Include="OrganizerTests\FileNameBuilderTests\CleanTitleFixture.cs" />
<Compile Include="OrganizerTests\FileNameBuilderTests\EpisodeTitleCollapseFixture.cs" /> <Compile Include="OrganizerTests\FileNameBuilderTests\EpisodeTitleCollapseFixture.cs" />
<Compile Include="ParserTests\MiniSeriesEpisodeParserFixture.cs" /> <Compile Include="ParserTests\MiniSeriesEpisodeParserFixture.cs" />
@ -247,8 +247,6 @@
<Compile Include="Messaging\Events\EventAggregatorFixture.cs" /> <Compile Include="Messaging\Events\EventAggregatorFixture.cs" />
<Compile Include="Metadata\Consumers\Roksbox\FindMetadataFileFixture.cs" /> <Compile Include="Metadata\Consumers\Roksbox\FindMetadataFileFixture.cs" />
<Compile Include="Metadata\Consumers\Wdtv\FindMetadataFileFixture.cs" /> <Compile Include="Metadata\Consumers\Wdtv\FindMetadataFileFixture.cs" />
<Compile Include="MetadataSourceTests\TraktProxyFixture.cs" />
<Compile Include="MetadataSourceTests\TraktProxyQueryFixture.cs" />
<Compile Include="MetadataSourceTests\TvdbProxyFixture.cs" /> <Compile Include="MetadataSourceTests\TvdbProxyFixture.cs" />
<Compile Include="NotificationTests\PlexProviderTest.cs" /> <Compile Include="NotificationTests\PlexProviderTest.cs" />
<Compile Include="NotificationTests\ProwlProviderTest.cs" /> <Compile Include="NotificationTests\ProwlProviderTest.cs" />

@ -108,7 +108,7 @@ namespace NzbDrone.Core.Test.TvTests
} }
[Test] [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<IEpisodeService>().Setup(c => c.GetEpisodeBySeries(It.IsAny<Int32>())) Mocker.GetMock<IEpisodeService>().Setup(c => c.GetEpisodeBySeries(It.IsAny<Int32>()))
.Returns(GetEpisodes()); .Returns(GetEpisodes());

@ -6,7 +6,7 @@ using NzbDrone.Core.Tv;
namespace NzbDrone.Core.MetadataSource namespace NzbDrone.Core.MetadataSource
{ {
public class TraktSearchSeriesComparer : IComparer<Series> public class SearchSeriesComparer : IComparer<Series>
{ {
private static readonly Regex RegexCleanPunctuation = new Regex("[-._:]", RegexOptions.Compiled); 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); 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; } public String SearchQuery { get; private set; }
private String _searchQueryWithoutYear; private readonly String _searchQueryWithoutYear;
private Int32? _year; private Int32? _year;
public TraktSearchSeriesComparer(String searchQuery) public SearchSeriesComparer(String searchQuery)
{ {
SearchQuery = searchQuery; SearchQuery = searchQuery;

@ -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; }
}
}

@ -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; }
}
}

@ -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<string> genres { get; set; }
public List<Season> 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<string> genres { get; set; }
}
}

@ -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; }
}
}

@ -1,9 +0,0 @@
using System.Collections.Generic;
namespace NzbDrone.Core.MetadataSource.Trakt
{
public class People
{
public List<Actor> actors { get; set; }
}
}

@ -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; }
}
}

@ -1,13 +0,0 @@
using System.Collections.Generic;
namespace NzbDrone.Core.MetadataSource.Trakt
{
public class Season
{
public int season { get; set; }
public List<Episode> episodes { get; set; }
public string url { get; set; }
public string poster { get; set; }
public Images images { get; set; }
}
}

@ -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)
{
}
}
}

@ -7,7 +7,7 @@ using System.Web;
using NLog; using NLog;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource.Trakt; using NzbDrone.Core.MetadataSource.Tvdb;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
using TVDBSharp; using TVDBSharp;
using TVDBSharp.Models.Enums; using TVDBSharp.Models.Enums;
@ -28,7 +28,7 @@ namespace NzbDrone.Core.MetadataSource
_tvdb = new TVDB("5D2D188E86E07F4F"); _tvdb = new TVDB("5D2D188E86E07F4F");
} }
private IEnumerable<TVDBSharp.Models.Show> SearchTrakt(string title) private IEnumerable<TVDBSharp.Models.Show> SearchTvdb(string title)
{ {
var lowerTitle = title.ToLowerInvariant(); var lowerTitle = title.ToLowerInvariant();
@ -47,11 +47,9 @@ namespace NzbDrone.Core.MetadataSource
{ {
return new[] { _tvdb.GetShow(tvdbId) }; return new[] { _tvdb.GetShow(tvdbId) };
} }
catch (WebException ex) catch (Common.Http.HttpException ex)
{ {
var resp = ex.Response as HttpWebResponse; if (ex.Response.StatusCode == HttpStatusCode.NotFound)
if (resp != null && resp.StatusCode == HttpStatusCode.NotFound)
{ {
return Enumerable.Empty<TVDBSharp.Models.Show>(); return Enumerable.Empty<TVDBSharp.Models.Show>();
} }
@ -67,22 +65,22 @@ namespace NzbDrone.Core.MetadataSource
{ {
try try
{ {
var tvdbSeries = SearchTrakt(title.Trim()); var tvdbSeries = SearchTvdb(title.Trim());
var series = tvdbSeries.Select(MapSeries).ToList(); var series = tvdbSeries.Select(MapSeries).ToList();
series.Sort(new TraktSearchSeriesComparer(title)); series.Sort(new SearchSeriesComparer(title));
return series; return series;
} }
catch (Common.Http.HttpException) 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) catch (Exception ex)
{ {
_logger.WarnException(ex.Message, 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);
} }
} }

@ -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)
{
}
}
}

@ -597,7 +597,7 @@
<Compile Include="Messaging\Events\IHandle.cs" /> <Compile Include="Messaging\Events\IHandle.cs" />
<Compile Include="Messaging\IProcessMessage.cs" /> <Compile Include="Messaging\IProcessMessage.cs" />
<Compile Include="MetadataSource\TvDbProxy.cs" /> <Compile Include="MetadataSource\TvDbProxy.cs" />
<Compile Include="MetadataSource\TraktSearchSeriesComparer.cs" /> <Compile Include="MetadataSource\SearchSeriesComparer.cs" />
<Compile Include="Metadata\Consumers\MediaBrowser\MediaBrowserMetadata.cs" /> <Compile Include="Metadata\Consumers\MediaBrowser\MediaBrowserMetadata.cs" />
<Compile Include="Metadata\Consumers\MediaBrowser\MediaBrowserMetadataSettings.cs" /> <Compile Include="Metadata\Consumers\MediaBrowser\MediaBrowserMetadataSettings.cs" />
<Compile Include="Metadata\Consumers\Roksbox\RoksboxMetadata.cs" /> <Compile Include="Metadata\Consumers\Roksbox\RoksboxMetadata.cs" />
@ -623,14 +623,7 @@
<Compile Include="Metadata\MetadataType.cs" /> <Compile Include="Metadata\MetadataType.cs" />
<Compile Include="MetadataSource\IProvideSeriesInfo.cs" /> <Compile Include="MetadataSource\IProvideSeriesInfo.cs" />
<Compile Include="MetadataSource\ISearchForNewSeries.cs" /> <Compile Include="MetadataSource\ISearchForNewSeries.cs" />
<Compile Include="MetadataSource\Trakt\Actor.cs" /> <Compile Include="MetadataSource\Tvdb\TvdbException.cs" />
<Compile Include="MetadataSource\Trakt\Episode.cs" />
<Compile Include="MetadataSource\Trakt\FullShow.cs" />
<Compile Include="MetadataSource\Trakt\Images.cs" />
<Compile Include="MetadataSource\Trakt\People.cs" />
<Compile Include="MetadataSource\Trakt\Ratings.cs" />
<Compile Include="MetadataSource\Trakt\Season.cs" />
<Compile Include="MetadataSource\Trakt\TraktException.cs" />
<Compile Include="MetadataSource\Tvdb\TvdbProxy.cs" /> <Compile Include="MetadataSource\Tvdb\TvdbProxy.cs" />
<Compile Include="Profiles\Delay\DelayProfile.cs" /> <Compile Include="Profiles\Delay\DelayProfile.cs" />
<Compile Include="Profiles\Delay\DelayProfileService.cs" /> <Compile Include="Profiles\Delay\DelayProfileService.cs" />

@ -11,7 +11,7 @@ namespace NzbDrone.Integration.Test
public class SeriesIntegrationTest : IntegrationTest public class SeriesIntegrationTest : IntegrationTest
{ {
[Test] [Test]
public void series_lookup_on_trakt() public void series_lookup_on_tvdb()
{ {
var series = Series.Lookup("archer"); var series = Series.Lookup("archer");

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Xml.Linq; using System.Xml.Linq;
using NzbDrone.Common.Http;
using TVDBSharp.Models.DAO; using TVDBSharp.Models.DAO;
using TVDBSharp.Models.Enums; using TVDBSharp.Models.Enums;
using TVDBSharp.Utilities; using TVDBSharp.Utilities;
@ -69,7 +70,7 @@ namespace TVDBSharp.Models
var response = _dataProvider.GetShow(id); var response = _dataProvider.GetShow(id);
shows.Add(new ShowBuilder(response).GetResult()); shows.Add(new ShowBuilder(response).GetResult());
} }
catch (WebException ex) catch (HttpException ex)
{ {
} }

@ -1,6 +1,8 @@
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Xml.Linq; using System.Xml.Linq;
using NzbDrone.Common.Http;
using NzbDrone.Common.Instrumentation;
using TVDBSharp.Models.Enums; using TVDBSharp.Models.Enums;
namespace TVDBSharp.Models.DAO namespace TVDBSharp.Models.DAO
@ -13,6 +15,9 @@ namespace TVDBSharp.Models.DAO
public string ApiKey { get; set; } public string ApiKey { get; set; }
private const string BaseUrl = "http://thetvdb.com"; private const string BaseUrl = "http://thetvdb.com";
private static HttpClient httpClient = new HttpClient(NzbDroneLogger.GetLogger(typeof(DataProvider)));
public XDocument GetShow(int showID) public XDocument GetShow(int showID)
{ {
return GetXDocumentFromUrl(string.Format("{0}/api/{1}/series/{2}/all/", BaseUrl, ApiKey, 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) private static XDocument GetXDocumentFromUrl(string url)
{ {
using (var web = new WebClient())
using (var memoryStream = new MemoryStream(web.DownloadData(url))) var request = new HttpRequest(url, new HttpAccept("application/xml"));
return XDocument.Load(memoryStream);
var response = httpClient.Get(request);
return XDocument.Parse(response.Content);
} }
} }
} }

@ -36,6 +36,9 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="NLog">
<HintPath>..\packages\NLog.2.1.0\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
@ -63,6 +66,12 @@
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Common\NzbDrone.Common.csproj">
<Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project>
<Name>NzbDrone.Common</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

Loading…
Cancel
Save