diff --git a/src/NzbDrone.Core.Test/MetadataSourceTests/TraktProxyQueryFixture.cs b/src/NzbDrone.Core.Test/MetadataSourceTests/TraktProxyQueryFixture.cs index 8d60ad2b2..0248ec4ca 100644 --- a/src/NzbDrone.Core.Test/MetadataSourceTests/TraktProxyQueryFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSourceTests/TraktProxyQueryFixture.cs @@ -1,69 +1,69 @@ -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); - } - } -} +//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 8ade9b6ca..bf4df218d 100644 --- a/src/NzbDrone.Core.Test/MetadataSourceTests/TvdbDataProxyFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSourceTests/TvdbDataProxyFixture.cs @@ -32,7 +32,9 @@ namespace NzbDrone.Core.Test.MetadataSourceTests [TestCase("Rob & Big", "Rob & Big")] [TestCase("M*A*S*H", "M*A*S*H")] //[TestCase("imdb:tt0436992", "Doctor Who (2005)")] - //[TestCase("tvdb:78804", "Doctor Who (2005)")] + [TestCase("tvdb:78804", "Doctor Who (2005)")] + [TestCase("tvdbid:78804", "Doctor Who (2005)")] + [TestCase("tvdbid: 78804 ", "Doctor Who (2005)")] public void successful_search(string title, string expected) { var result = Subject.SearchForNewSeries(title); diff --git a/src/NzbDrone.Core/MetadataSource/TvDbProxy.cs b/src/NzbDrone.Core/MetadataSource/TvDbProxy.cs index 0632df2e8..26a94d006 100644 --- a/src/NzbDrone.Core/MetadataSource/TvDbProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/TvDbProxy.cs @@ -1,15 +1,14 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Text.RegularExpressions; using System.Web; using NLog; using NzbDrone.Common.Extensions; -using NzbDrone.Common.Http; using NzbDrone.Core.MediaCover; using NzbDrone.Core.MetadataSource.Trakt; using NzbDrone.Core.Tv; +using TVDBSharp; using TVDBSharp.Models.Enums; namespace NzbDrone.Core.MetadataSource @@ -17,63 +16,36 @@ namespace NzbDrone.Core.MetadataSource public class TvDbProxy : ISearchForNewSeries, IProvideSeriesInfo { private readonly Logger _logger; - private readonly IHttpClient _httpClient; private static readonly Regex CollapseSpaceRegex = new Regex(@"\s+", RegexOptions.Compiled); private static readonly Regex InvalidSearchCharRegex = new Regex(@"(?:\*|\(|\)|'|!|@|\+)", RegexOptions.Compiled); - private static readonly Regex ExpandCamelCaseRegEx = new Regex(@"(? SearchTrakt(string title) { -/* Common.Http.HttpRequest request; - var lowerTitle = title.ToLowerInvariant(); - if (lowerTitle.StartsWith("tvdb:") || lowerTitle.StartsWith("tvdbid:") /*|| lowerTitle.StartsWith("slug:")#1#) + if (lowerTitle.StartsWith("tvdb:") || lowerTitle.StartsWith("tvdbid:")) { var slug = lowerTitle.Split(':')[1].Trim(); - if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace)) + int tvdbId; + + if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || !Int32.TryParse(slug, out tvdbId)) { return Enumerable.Empty(); } - request = _requestBuilder.Build("/{slug}/extended"); - - request.AddSegment("path", "show"); - request.AddSegment("resource", "summary"); - request.AddSegment("slug", GetSearchTerm(slug)); - - return new List { _httpClient.Get(request).Resource }; + return new[] { _tvdb.GetShow(tvdbId) }; } - if (lowerTitle.StartsWith("imdb:") || lowerTitle.StartsWith("imdbid:")) - { - var slug = lowerTitle.Split(':')[1].TrimStart('t').Trim(); - - if (slug.IsNullOrWhiteSpace() || !slug.All(char.IsDigit) || slug.Length < 7) - { - return Enumerable.Empty(); - } - - title = "tt" + slug; - }*/ - - - return tvdb.Search(GetSearchTerm(title)); - + return _tvdb.Search(GetSearchTerm(lowerTitle)); } public List SearchForNewSeries(string title) @@ -101,14 +73,7 @@ namespace NzbDrone.Core.MetadataSource public Tuple> GetSeriesInfo(int tvdbSeriesId) { - - var request = _requestBuilder.Build("/{tvdbId}/extended"); - - request.AddSegment("path", "show"); - request.AddSegment("resource", "summary"); - request.AddSegment("tvdbId", tvdbSeriesId.ToString()); - - var tvdbSeries = tvdb.GetShow(tvdbSeriesId); + var tvdbSeries = _tvdb.GetShow(tvdbSeriesId); var episodes = tvdbSeries.Episodes.Select(MapEpisode); @@ -193,14 +158,6 @@ namespace NzbDrone.Core.MetadataSource return episode; } - private static string GetPosterThumbnailUrl(string posterUrl) - { - if (posterUrl.Contains("poster-small.jpg") || posterUrl.Contains("poster-dark.jpg")) return posterUrl; - - var extension = Path.GetExtension(posterUrl); - var withoutExtension = posterUrl.Substring(0, posterUrl.Length - extension.Length); - return withoutExtension + "-300" + extension; - } private static SeriesStatusType GetSeriesStatus(Status status) { @@ -212,27 +169,6 @@ namespace NzbDrone.Core.MetadataSource return SeriesStatusType.Continuing; } - private static DateTime? FromIso(string iso) - { - DateTime result; - - if (!DateTime.TryParse(iso, out result)) - return null; - - return result.ToUniversalTime(); - } - - private static string FromIsoToString(string iso) - { - if (String.IsNullOrWhiteSpace(iso)) return null; - - var match = Regex.Match(iso, @"^\d{4}\W\d{2}\W\d{2}"); - - if (!match.Success) return null; - - return match.Captures[0].Value; - } - private static string GetSearchTerm(string phrase) { phrase = phrase.RemoveAccent(); @@ -251,15 +187,6 @@ namespace NzbDrone.Core.MetadataSource return phrase; } - private static int GetYear(int year, int firstAired) - { - if (year > 1969) return year; - - if (firstAired == 0) return DateTime.Today.Year; - - return year; - } - private static Tv.Ratings GetRatings(int ratingCount, double? rating) { @@ -273,31 +200,6 @@ namespace NzbDrone.Core.MetadataSource return result; } - private static List GetActors(People people) - { - if (people == null) - { - return new List(); - } - - return GetActors(people.actors).ToList(); - } - - private static IEnumerable GetActors(IEnumerable trakcActors) - { - foreach (var traktActor in trakcActors) - { - var actor = new Tv.Actor - { - Name = traktActor.name, - Character = traktActor.character, - }; - - actor.Images.Add(new MediaCover.MediaCover(MediaCoverTypes.Headshot, traktActor.images.headshot)); - - yield return actor; - } - } private static List GetSeasons(TVDBSharp.Models.Show show) { diff --git a/src/NzbDrone.sln b/src/NzbDrone.sln index c7c6fea0b..a7642982d 100644 --- a/src/NzbDrone.sln +++ b/src/NzbDrone.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.30723.0 +VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{57A04B72-8088-4F75-A582-1158CF8291F7}" EndProject diff --git a/src/UI/AddSeries/EmptyViewTemplate.hbs b/src/UI/AddSeries/EmptyViewTemplate.hbs index a56208736..c6bcb0343 100644 --- a/src/UI/AddSeries/EmptyViewTemplate.hbs +++ b/src/UI/AddSeries/EmptyViewTemplate.hbs @@ -1,3 +1,3 @@ 
- You can also search by tvdbid and imdbid using the tvdb: and imdb: prefixes. + You can also search by tvdbid using the tvdb: prefixes.