From a8aac36379c0ba6e1817be0f4bb8a6da60a919fd Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 7 May 2015 08:43:52 -0700 Subject: [PATCH] Use skyhook for searching --- src/NzbDrone.Api/Series/SeriesLookupModule.cs | 2 +- .../SearchSeriesComparerFixture.cs | 2 +- .../SkyHook/SKyHookProxySearchFixture.cs} | 7 +- .../NzbDrone.Core.Test.csproj | 4 +- .../TvTests/RefreshEpisodeServiceFixture.cs | 4 +- .../SkyHook/SkyHookException.cs | 17 + .../MetadataSource/SkyHook/SkyHookProxy.cs | 71 ++++- src/NzbDrone.Core/MetadataSource/TvDbProxy.cs | 272 ---------------- .../MetadataSource/Tvdb/TvdbException.cs | 16 - src/NzbDrone.Core/NzbDrone.Core.csproj | 7 +- src/NzbDrone.sln | 12 - src/TVDBSharp/App.config | 6 - src/TVDBSharp/Models/Builder.cs | 290 ------------------ src/TVDBSharp/Models/DAO/DataProvider.cs | 55 ---- src/TVDBSharp/Models/DAO/IDataProvider.cs | 45 --- src/TVDBSharp/Models/Enums/ContentRating.cs | 43 --- src/TVDBSharp/Models/Enums/Frequency.cs | 14 - src/TVDBSharp/Models/Enums/Interval.cs | 32 -- src/TVDBSharp/Models/Enums/Status.cs | 23 -- src/TVDBSharp/Models/Episode.cs | 116 ------- src/TVDBSharp/Models/Show.cs | 122 -------- src/TVDBSharp/Models/Updates.cs | 49 --- src/TVDBSharp/Properties/AssemblyInfo.cs | 39 --- src/TVDBSharp/TVDB.cs | 72 ----- src/TVDBSharp/TVDBSharp.csproj | 83 ----- src/TVDBSharp/Utilities/Extensions.cs | 58 ---- src/TVDBSharp/Utilities/Utils.cs | 73 ----- 27 files changed, 90 insertions(+), 1444 deletions(-) rename src/NzbDrone.Core.Test/{MetadataSourceTests => MetadataSource}/SearchSeriesComparerFixture.cs (97%) rename src/NzbDrone.Core.Test/{MetadataSourceTests/TvdbDataProxyFixture.cs => MetadataSource/SkyHook/SKyHookProxySearchFixture.cs} (96%) create mode 100644 src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookException.cs delete mode 100644 src/NzbDrone.Core/MetadataSource/TvDbProxy.cs delete mode 100644 src/NzbDrone.Core/MetadataSource/Tvdb/TvdbException.cs delete mode 100644 src/TVDBSharp/App.config delete mode 100644 src/TVDBSharp/Models/Builder.cs delete mode 100644 src/TVDBSharp/Models/DAO/DataProvider.cs delete mode 100644 src/TVDBSharp/Models/DAO/IDataProvider.cs delete mode 100644 src/TVDBSharp/Models/Enums/ContentRating.cs delete mode 100644 src/TVDBSharp/Models/Enums/Frequency.cs delete mode 100644 src/TVDBSharp/Models/Enums/Interval.cs delete mode 100644 src/TVDBSharp/Models/Enums/Status.cs delete mode 100644 src/TVDBSharp/Models/Episode.cs delete mode 100644 src/TVDBSharp/Models/Show.cs delete mode 100644 src/TVDBSharp/Models/Updates.cs delete mode 100644 src/TVDBSharp/Properties/AssemblyInfo.cs delete mode 100644 src/TVDBSharp/TVDB.cs delete mode 100644 src/TVDBSharp/TVDBSharp.csproj delete mode 100644 src/TVDBSharp/Utilities/Extensions.cs delete mode 100644 src/TVDBSharp/Utilities/Utils.cs diff --git a/src/NzbDrone.Api/Series/SeriesLookupModule.cs b/src/NzbDrone.Api/Series/SeriesLookupModule.cs index 7072f2514..f799754a9 100644 --- a/src/NzbDrone.Api/Series/SeriesLookupModule.cs +++ b/src/NzbDrone.Api/Series/SeriesLookupModule.cs @@ -13,7 +13,7 @@ namespace NzbDrone.Api.Series private readonly ISearchForNewSeries _searchProxy; public SeriesLookupModule(ISearchForNewSeries searchProxy) - : base("/Series/lookup") + : base("/series/lookup") { _searchProxy = searchProxy; Get["/"] = x => Search(); diff --git a/src/NzbDrone.Core.Test/MetadataSourceTests/SearchSeriesComparerFixture.cs b/src/NzbDrone.Core.Test/MetadataSource/SearchSeriesComparerFixture.cs similarity index 97% rename from src/NzbDrone.Core.Test/MetadataSourceTests/SearchSeriesComparerFixture.cs rename to src/NzbDrone.Core.Test/MetadataSource/SearchSeriesComparerFixture.cs index 734f814f3..f7f9053dd 100644 --- a/src/NzbDrone.Core.Test/MetadataSourceTests/SearchSeriesComparerFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSource/SearchSeriesComparerFixture.cs @@ -6,7 +6,7 @@ using NzbDrone.Core.MetadataSource; using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Tv; -namespace NzbDrone.Core.Test.MetadataSourceTests +namespace NzbDrone.Core.Test.MetadataSource { [TestFixture] public class SearchSeriesComparerFixture : CoreTest diff --git a/src/NzbDrone.Core.Test/MetadataSourceTests/TvdbDataProxyFixture.cs b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SKyHookProxySearchFixture.cs similarity index 96% rename from src/NzbDrone.Core.Test/MetadataSourceTests/TvdbDataProxyFixture.cs rename to src/NzbDrone.Core.Test/MetadataSource/SkyHook/SKyHookProxySearchFixture.cs index 3679dba36..dc0e7f319 100644 --- a/src/NzbDrone.Core.Test/MetadataSourceTests/TvdbDataProxyFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SKyHookProxySearchFixture.cs @@ -1,21 +1,20 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Net; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.MediaCover; -using NzbDrone.Core.MetadataSource; +using NzbDrone.Core.MetadataSource.SkyHook; using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Tv; using NzbDrone.Test.Common; using NzbDrone.Test.Common.Categories; -namespace NzbDrone.Core.Test.MetadataSourceTests +namespace NzbDrone.Core.Test.MetadataSource.SkyHook { [TestFixture] [IntegrationTest] - public class TvdbDataProxyFixture : CoreTest + public class SkyHookProxySearchFixture : CoreTest { [SetUp] public void Setup() diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index a4d4c1d19..12babe197 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -239,8 +239,8 @@ - - + + diff --git a/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs b/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs index 392f6344f..e2b786716 100644 --- a/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs +++ b/src/NzbDrone.Core.Test/TvTests/RefreshEpisodeServiceFixture.cs @@ -6,7 +6,7 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Extensions; -using NzbDrone.Core.MetadataSource; +using NzbDrone.Core.MetadataSource.SkyHook; using NzbDrone.Core.Tv; using NzbDrone.Core.Test.Framework; @@ -25,7 +25,7 @@ namespace NzbDrone.Core.Test.TvTests { UseRealHttp(); - _gameOfThrones = Mocker.Resolve().GetSeriesInfo(121361);//Game of thrones + _gameOfThrones = Mocker.Resolve().GetSeriesInfo(121361);//Game of thrones // Remove specials. _gameOfThrones.Item2.RemoveAll(v => v.SeasonNumber == 0); diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookException.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookException.cs new file mode 100644 index 000000000..a9591fd6b --- /dev/null +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookException.cs @@ -0,0 +1,17 @@ +using System.Net; +using NzbDrone.Core.Exceptions; + +namespace NzbDrone.Core.MetadataSource.SkyHook +{ + public class SkyHookException : NzbDroneClientException + { + public SkyHookException(string message) : base(HttpStatusCode.ServiceUnavailable, message) + { + } + + public SkyHookException(string message, params object[] args) + : base(HttpStatusCode.ServiceUnavailable, message, args) + { + } + } +} diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index b888a1d50..9af5a0cc7 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -1,6 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net; +using System.Text.RegularExpressions; +using System.Web; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; @@ -10,23 +13,25 @@ using NzbDrone.Core.Tv; namespace NzbDrone.Core.MetadataSource.SkyHook { - public class SkyHookProxy : IProvideSeriesInfo + public class SkyHookProxy : IProvideSeriesInfo, ISearchForNewSeries { - private readonly Logger _logger; private readonly IHttpClient _httpClient; + private readonly Logger _logger; private readonly HttpRequestBuilder _requestBuilder; - public SkyHookProxy(Logger logger, IHttpClient httpClient) + public SkyHookProxy(IHttpClient httpClient, Logger logger) { - _logger = logger; _httpClient = httpClient; + _logger = logger; - _requestBuilder = new HttpRequestBuilder("http://skyhook.sonarr.tv/v1/tvdb/shows/en/"); + _requestBuilder = new HttpRequestBuilder("http://skyhook.sonarr.tv/v1/tvdb/{route}/en/"); } public Tuple> GetSeriesInfo(int tvdbSeriesId) { var httpRequest = _requestBuilder.Build(tvdbSeriesId.ToString()); + httpRequest.AddSegment("route", "shows"); + var httpResponse = _httpClient.Get(httpRequest); var episodes = httpResponse.Resource.Episodes.Select(MapEpisode); var series = MapSeries(httpResponse.Resource); @@ -34,6 +39,58 @@ namespace NzbDrone.Core.MetadataSource.SkyHook return new Tuple>(series, episodes.ToList()); } + public List SearchForNewSeries(string title) + { + try + { + var lowerTitle = title.ToLowerInvariant(); + + if (lowerTitle.StartsWith("tvdb:") || lowerTitle.StartsWith("tvdbid:")) + { + var slug = lowerTitle.Split(':')[1].Trim(); + + int tvdbId; + + if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || !Int32.TryParse(slug, out tvdbId) || tvdbId <= 0) + { + return new List(); + } + + try + { + return new List { GetSeriesInfo(tvdbId).Item1 }; + } + catch (Common.Http.HttpException ex) + { + if (ex.Response.StatusCode == HttpStatusCode.NotFound) + { + return new List(); + } + + throw; + } + } + + var term = HttpUtility.UrlEncode((title.ToLower().Trim())); + var httpRequest = _requestBuilder.Build("?term={term}"); + httpRequest.AddSegment("route", "search"); + httpRequest.AddSegment("term", term); + + var httpResponse = _httpClient.Get>(httpRequest); + + return httpResponse.Resource.SelectList(MapSeries); + } + catch (Common.Http.HttpException) + { + throw new SkyHookException("Search for '{0}' failed. Unable to communicate with SkyHook.", title); + } + catch (Exception ex) + { + _logger.WarnException(ex.Message, ex); + throw new SkyHookException("Search for '{0}' failed. Invalid response received from SkyHook.", title); + } + } + private static Series MapSeries(ShowResource show) { var series = new Series(); @@ -91,8 +148,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook var newActor = new Actor { Name = arg.Name, - Character = arg.Character, - + Character = arg.Character }; if (arg.Image != null) @@ -185,6 +241,5 @@ namespace NzbDrone.Core.MetadataSource.SkyHook return MediaCoverTypes.Unknown; } } - } } diff --git a/src/NzbDrone.Core/MetadataSource/TvDbProxy.cs b/src/NzbDrone.Core/MetadataSource/TvDbProxy.cs deleted file mode 100644 index be12009f4..000000000 --- a/src/NzbDrone.Core/MetadataSource/TvDbProxy.cs +++ /dev/null @@ -1,272 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Text.RegularExpressions; -using System.Web; -using NLog; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.MediaCover; -using NzbDrone.Core.MetadataSource.Tvdb; -using NzbDrone.Core.Tv; -using TVDBSharp; -using TVDBSharp.Models.Enums; - -namespace NzbDrone.Core.MetadataSource -{ - public class TvDbProxy : ISearchForNewSeries - { - private readonly Logger _logger; - private static readonly Regex CollapseSpaceRegex = new Regex(@"\s+", RegexOptions.Compiled); - private static readonly Regex InvalidSearchCharRegex = new Regex(@"(?:\*|\(|\)|'|!|@|\+)", RegexOptions.Compiled); - - private readonly TVDB _tvdb; - - public TvDbProxy(Logger logger) - { - _logger = logger; - _tvdb = new TVDB("5D2D188E86E07F4F"); - } - - private IEnumerable SearchTvdb(string title) - { - var lowerTitle = title.ToLowerInvariant(); - - if (lowerTitle.StartsWith("tvdb:") || lowerTitle.StartsWith("tvdbid:")) - { - var slug = lowerTitle.Split(':')[1].Trim(); - - int tvdbId; - - if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || !Int32.TryParse(slug, out tvdbId) || tvdbId <= 0) - { - return Enumerable.Empty(); - } - - try - { - return new[] { _tvdb.GetShow(tvdbId) }; - } - catch (Common.Http.HttpException ex) - { - if (ex.Response.StatusCode == HttpStatusCode.NotFound) - { - return Enumerable.Empty(); - } - - throw; - } - } - - return _tvdb.Search(GetSearchTerm(lowerTitle), 10); - } - - public List SearchForNewSeries(string title) - { - try - { - var tvdbSeries = SearchTvdb(title.Trim()); - - var series = tvdbSeries.Select(MapSeries).ToList(); - - series.Sort(new SearchSeriesComparer(title)); - - return series; - } - catch (Common.Http.HttpException) - { - throw new TvdbException("Search for '{0}' failed. Unable to communicate with TVDB.", title); - } - catch (Exception ex) - { - _logger.WarnException(ex.Message, ex); - throw new TvdbException("Search for '{0}' failed. Invalid response received from TVDB.", title); - } - } - - public Tuple> GetSeriesInfo(int tvdbSeriesId) - { - var tvdbSeries = _tvdb.GetShow(tvdbSeriesId); - - var episodes = tvdbSeries.Episodes.Select(MapEpisode); - - episodes = RemoveDuplicates(episodes); - - var series = MapSeries(tvdbSeries); - - return new Tuple>(series, episodes.ToList()); - } - - private static IEnumerable RemoveDuplicates(IEnumerable episodes) - { - //http://support.trakt.tv/forums/188762-general/suggestions/4430690-anger-management-duplicate-episode - var episodeGroup = episodes.GroupBy(e => e.SeasonNumber.ToString("0000") + e.EpisodeNumber.ToString("0000")); - return episodeGroup.Select(g => g.First()); - } - - private static Series MapSeries(TVDBSharp.Models.Show show) - { - var series = new Series(); - series.TvdbId = show.Id; - //series.TvRageId = show.tvrage_id; - series.ImdbId = show.ImdbId; - series.Title = show.Name; - series.CleanTitle = Parser.Parser.CleanSeriesTitle(show.Name); - series.SortTitle = SeriesTitleNormalizer.Normalize(show.Name, show.Id); - - if (show.FirstAired != null) - { - series.Year = show.FirstAired.Value.Year; - series.FirstAired = show.FirstAired.Value.ToUniversalTime(); - } - - series.Overview = show.Description; - - if (show.Runtime != null) - { - series.Runtime = show.Runtime.Value; - } - - series.Network = show.Network; - - if (show.AirTime != null) - { - series.AirTime = show.AirTime.Value.ToString(); - } - - series.TitleSlug = GenerateSlug(show.Name); - series.Status = GetSeriesStatus(show.Status); - series.Ratings = GetRatings(show.RatingCount, show.Rating); - series.Genres = show.Genres; - series.Certification = show.ContentRating.ToString().ToUpper(); - series.Actors = new List(); - series.Seasons = GetSeasons(show); - - if (show.Banner != null) - { - series.Images.Add(new MediaCover.MediaCover { CoverType = MediaCoverTypes.Banner, Url = show.Banner.ToString() }); - } - - if (show.Poster != null) - { - series.Images.Add(new MediaCover.MediaCover { CoverType = MediaCoverTypes.Poster, Url = show.Poster.ToString() }); - } - - if (show.Fanart != null) - { - series.Images.Add(new MediaCover.MediaCover { CoverType = MediaCoverTypes.Fanart, Url = show.Fanart.ToString() }); - } - - return series; - } - - private static Episode MapEpisode(TVDBSharp.Models.Episode traktEpisode) - { - var episode = new Episode(); - episode.Overview = traktEpisode.Description; - episode.SeasonNumber = traktEpisode.SeasonNumber; - episode.EpisodeNumber = traktEpisode.EpisodeNumber; - episode.AbsoluteEpisodeNumber = traktEpisode.AbsoluteEpisodeNumber; - episode.Title = traktEpisode.Title; - - if (traktEpisode.FirstAired != null) - { - episode.AirDate = traktEpisode.FirstAired.Value.ToString("yyyy-MM-dd"); - episode.AirDateUtc = traktEpisode.FirstAired.Value.ToUniversalTime(); - } - - episode.Ratings = GetRatings(traktEpisode.RatingCount, traktEpisode.Rating); - - //Don't include series fanart images as episode screenshot - if (traktEpisode.EpisodeImage != null) - { - episode.Images.Add(new MediaCover.MediaCover(MediaCoverTypes.Screenshot, traktEpisode.EpisodeImage.ToString())); - } - - return episode; - } - - - private static SeriesStatusType GetSeriesStatus(Status status) - { - if (status == Status.Ended) - { - return SeriesStatusType.Ended; - } - - return SeriesStatusType.Continuing; - } - - private static string GetSearchTerm(string phrase) - { - phrase = phrase.RemoveAccent(); - phrase = InvalidSearchCharRegex.Replace(phrase, ""); - - // if (!phrase.Any(char.IsWhiteSpace) && phrase.Any(char.IsUpper) && phrase.Any(char.IsLower) && phrase.Length > 4) - // { - // phrase = ExpandCamelCaseRegEx.Replace(phrase, " "); - // } - - phrase = CollapseSpaceRegex.Replace(phrase, " ").Trim(); - phrase = phrase.Trim('-'); - - phrase = HttpUtility.UrlEncode(phrase.ToLower()); - - return phrase; - } - - private static Tv.Ratings GetRatings(int ratingCount, decimal? rating) - { - - var result = new Tv.Ratings { Votes = ratingCount }; - - if (rating != null) - { - result.Value = rating.Value; - } - - return result; - } - - - private static List GetSeasons(TVDBSharp.Models.Show show) - { - var seasons = new List(); - - foreach (var seasonNumber in show.Episodes.Select(c => c.SeasonNumber).Distinct().OrderByDescending(c => c)) - { - var season = new Tv.Season - { - SeasonNumber = seasonNumber - }; - - /* if (season.images != null) - { - season.Images.Add(new MediaCover.MediaCover(MediaCoverTypes.Poster, season.images.poster)); - }*/ - - seasons.Add(season); - } - - return seasons; - } - - - private static readonly Regex RemoveRegex = new Regex(@"[^\w-]", RegexOptions.Compiled); - - public static string GenerateSlug(string showTitle) - { - if (showTitle.StartsWith(".")) - { - showTitle = "dot" + showTitle.Substring(1); - } - showTitle = showTitle.Replace(" ", "-"); - showTitle = showTitle.Replace("&", "and"); - showTitle = RemoveRegex.Replace(showTitle, String.Empty); - showTitle = showTitle.RemoveAccent(); - showTitle = showTitle.ToLowerInvariant(); - - return showTitle; - } - } -} diff --git a/src/NzbDrone.Core/MetadataSource/Tvdb/TvdbException.cs b/src/NzbDrone.Core/MetadataSource/Tvdb/TvdbException.cs deleted file mode 100644 index a87b6aaf4..000000000 --- a/src/NzbDrone.Core/MetadataSource/Tvdb/TvdbException.cs +++ /dev/null @@ -1,16 +0,0 @@ -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 a4eec048f..2ab763458 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -646,9 +646,8 @@ - - + @@ -961,10 +960,6 @@ {F2BE0FDF-6E47-4827-A420-DD4EF82407F8} NzbDrone.Common - - {0cc493d7-0a9f-4199-9615-0a977945d716} - TVDBSharp - diff --git a/src/NzbDrone.sln b/src/NzbDrone.sln index a33c70359..d80b15706 100644 --- a/src/NzbDrone.sln +++ b/src/NzbDrone.sln @@ -34,9 +34,6 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceUninstall", "ServiceHelpers\ServiceUninstall\ServiceUninstall.csproj", "{700D0B95-95CD-43F3-B6C9-FAA0FC1358D4}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.Core", "NzbDrone.Core\NzbDrone.Core.csproj", "{FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}" - ProjectSection(ProjectDependencies) = postProject - {0CC493D7-0A9F-4199-9615-0A977945D716} = {0CC493D7-0A9F-4199-9615-0A977945D716} - EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.Update", "NzbDrone.Update\NzbDrone.Update.csproj", "{4CCC53CD-8D5E-4CC4-97D2-5C9312AC2BD7}" EndProject @@ -91,8 +88,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogentriesNLog", "Logentrie {90D6E9FC-7B88-4E1B-B018-8FA742274558} = {90D6E9FC-7B88-4E1B-B018-8FA742274558} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TVDBSharp", "TVDBSharp\TVDBSharp.csproj", "{0CC493D7-0A9F-4199-9615-0A977945D716}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 @@ -273,12 +268,6 @@ Global {9DC31DE3-79FF-47A8-96B4-6BA18F6BB1CB}.Mono|x86.Build.0 = Release|x86 {9DC31DE3-79FF-47A8-96B4-6BA18F6BB1CB}.Release|x86.ActiveCfg = Release|x86 {9DC31DE3-79FF-47A8-96B4-6BA18F6BB1CB}.Release|x86.Build.0 = Release|x86 - {0CC493D7-0A9F-4199-9615-0A977945D716}.Debug|x86.ActiveCfg = Debug|x86 - {0CC493D7-0A9F-4199-9615-0A977945D716}.Debug|x86.Build.0 = Debug|x86 - {0CC493D7-0A9F-4199-9615-0A977945D716}.Mono|x86.ActiveCfg = Release|x86 - {0CC493D7-0A9F-4199-9615-0A977945D716}.Mono|x86.Build.0 = Release|x86 - {0CC493D7-0A9F-4199-9615-0A977945D716}.Release|x86.ActiveCfg = Release|x86 - {0CC493D7-0A9F-4199-9615-0A977945D716}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -311,7 +300,6 @@ Global {411A9E0E-FDC6-4E25-828A-0C2CD1CD96F8} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA} {90D6E9FC-7B88-4E1B-B018-8FA742274558} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA} {9DC31DE3-79FF-47A8-96B4-6BA18F6BB1CB} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA} - {0CC493D7-0A9F-4199-9615-0A977945D716} = {F6E3A728-AE77-4D02-BAC8-82FBC1402DDA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.0\lib\NET35;packages\Unity.2.1.505.2\lib\NET35 diff --git a/src/TVDBSharp/App.config b/src/TVDBSharp/App.config deleted file mode 100644 index b04d01078..000000000 --- a/src/TVDBSharp/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/src/TVDBSharp/Models/Builder.cs b/src/TVDBSharp/Models/Builder.cs deleted file mode 100644 index ecdb69511..000000000 --- a/src/TVDBSharp/Models/Builder.cs +++ /dev/null @@ -1,290 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Xml.Linq; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Http; -using TVDBSharp.Models.DAO; -using TVDBSharp.Models.Enums; -using TVDBSharp.Utilities; - -namespace TVDBSharp.Models -{ - /// - /// Provides builder classes for complex entities. - /// - public class Builder - { - private const string UriPrefix = "http://thetvdb.com/banners/"; - private readonly IDataProvider _dataProvider; - - /// - /// Initializes a new Builder object with the given . - /// - /// The DataProvider used to retrieve XML responses. - public Builder(IDataProvider dataProvider) - { - _dataProvider = dataProvider; - } - - /// - /// Builds a show object from the given show ID. - /// - /// ID of the show to serialize into a object. - /// Returns the Show object. - public Show BuildShow(int showID) - { - var builder = new ShowBuilder(_dataProvider.GetShow(showID)); - return builder.GetResult(); - } - - public Episode BuildEpisode(int episodeId, string lang) - { - var builder = new EpisodeBuilder(_dataProvider.GetEpisode(episodeId, lang).Descendants("Episode").First()); - return builder.GetResult(); - } - - public Updates BuildUpdates(Interval interval) - { - var builder = new UpdatesBuilder(_dataProvider.GetUpdates(interval)); - return builder.GetResult(); - } - - /// - /// Returns a list of objects that match the given query. - /// - /// Query the search is performed with. - /// Maximal amount of shows the resultset should return. - /// Returns a list of show objects. - public List Search(string query, int results) - { - var shows = new List(); - var doc = _dataProvider.Search(query); - - foreach (var element in doc.Descendants("Series").Take(results)) - { - var id = int.Parse(element.GetXmlData("seriesid")); - - try - { - var response = _dataProvider.GetShow(id); - shows.Add(new ShowBuilder(response).GetResult()); - } - catch (HttpException ex) - { - - } - - } - - return shows; - } - - private static Uri GetBannerUri(string uriSuffix) - { - if (uriSuffix.IsNullOrWhiteSpace()) - { - return null; - } - - return new Uri(UriPrefix + uriSuffix, UriKind.Absolute); - } - - private class ShowBuilder - { - private readonly Show _show; - - public ShowBuilder(XDocument doc) - { - _show = new Show(); - _show.Id = int.Parse(doc.GetSeriesData("id")); - _show.ImdbId = doc.GetSeriesData("IMDB_ID"); - _show.Name = doc.GetSeriesData("SeriesName"); - _show.Language = doc.GetSeriesData("Language"); - _show.Network = doc.GetSeriesData("Network"); - _show.Description = doc.GetSeriesData("Overview"); - _show.Rating = string.IsNullOrWhiteSpace(doc.GetSeriesData("Rating")) - ? (decimal?) null - : Convert.ToDecimal(doc.GetSeriesData("Rating"), - System.Globalization.CultureInfo.InvariantCulture); - _show.RatingCount = string.IsNullOrWhiteSpace(doc.GetSeriesData("RatingCount")) - ? 0 - : Convert.ToInt32(doc.GetSeriesData("RatingCount")); - _show.Runtime = string.IsNullOrWhiteSpace(doc.GetSeriesData("Runtime")) - ? (int?) null - : Convert.ToInt32(doc.GetSeriesData("Runtime")); - _show.Banner = GetBannerUri(doc.GetSeriesData("banner")); - _show.Fanart = GetBannerUri(doc.GetSeriesData("fanart")); - _show.LastUpdated = string.IsNullOrWhiteSpace(doc.GetSeriesData("lastupdated")) - ? (long?) null - : Convert.ToInt64(doc.GetSeriesData("lastupdated")); - _show.Poster = GetBannerUri(doc.GetSeriesData("poster")); - _show.Zap2ItID = doc.GetSeriesData("zap2it_id"); - _show.FirstAired = string.IsNullOrWhiteSpace(doc.GetSeriesData("FirstAired")) - ? (DateTime?) null - : Utils.ParseDate(doc.GetSeriesData("FirstAired")); - _show.AirTime = string.IsNullOrWhiteSpace(doc.GetSeriesData("Airs_Time")) - ? (TimeSpan?) null - : Utils.ParseTime(doc.GetSeriesData("Airs_Time")); - _show.AirDay = string.IsNullOrWhiteSpace(doc.GetSeriesData("Airs_DayOfWeek")) - ? (Frequency?) null - : (Frequency) Enum.Parse(typeof (Frequency), doc.GetSeriesData("Airs_DayOfWeek")); - _show.Status = string.IsNullOrWhiteSpace(doc.GetSeriesData("Status")) - ? Status.Unknown - : (Status) Enum.Parse(typeof (Status), doc.GetSeriesData("Status")); - _show.ContentRating = Utils.GetContentRating(doc.GetSeriesData("ContentRating")); - _show.Genres = - new List(doc.GetSeriesData("Genre") - .Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries)); - _show.Actors = - new List(doc.GetSeriesData("Actors") - .Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries)); - _show.Episodes = new EpisodesBuilder(doc).BuildEpisodes(); - } - - public Show GetResult() - { - return _show; - } - } - - public class EpisodeBuilder - { - private readonly Episode _episode; - - public EpisodeBuilder(XElement episodeNode) - { - _episode = new Episode - { - Id = int.Parse(episodeNode.GetXmlData("id")), - Title = episodeNode.GetXmlData("EpisodeName"), - Description = episodeNode.GetXmlData("Overview"), - AbsoluteEpisodeNumber = - string.IsNullOrWhiteSpace(episodeNode.GetXmlData("absolute_number")) - ? (int?)null - : int.Parse(episodeNode.GetXmlData("absolute_number")), - EpisodeNumber = int.Parse(episodeNode.GetXmlData("EpisodeNumber")), - Director = episodeNode.GetXmlData("Director"), - EpisodeImage = GetBannerUri(episodeNode.GetXmlData("filename")), - FirstAired = - string.IsNullOrWhiteSpace(episodeNode.GetXmlData("FirstAired")) - ? (DateTime?) null - : Utils.ParseDate(episodeNode.GetXmlData("FirstAired")), - GuestStars = - new List(episodeNode.GetXmlData("GuestStars") - .Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries)), - ImdbId = episodeNode.GetXmlData("IMDB_ID"), - Language = episodeNode.GetXmlData("Language"), - LastUpdated = - string.IsNullOrWhiteSpace(episodeNode.GetXmlData("lastupdated")) - ? 0L - : Convert.ToInt64(episodeNode.GetXmlData("lastupdated")), - Rating = - string.IsNullOrWhiteSpace(episodeNode.GetXmlData("Rating")) - ? (Decimal?) null - : Convert.ToDecimal(episodeNode.GetXmlData("Rating"), - System.Globalization.CultureInfo.InvariantCulture), - RatingCount = - string.IsNullOrWhiteSpace(episodeNode.GetXmlData("RatingCount")) - ? 0 - : Convert.ToInt32(episodeNode.GetXmlData("RatingCount")), - SeasonId = int.Parse(episodeNode.GetXmlData("seasonid")), - SeasonNumber = int.Parse(episodeNode.GetXmlData("SeasonNumber")), - SeriesId = int.Parse(episodeNode.GetXmlData("seriesid")), - ThumbHeight = - string.IsNullOrWhiteSpace(episodeNode.GetXmlData("thumb_height")) - ? (int?) null - : Convert.ToInt32(episodeNode.GetXmlData("thumb_height")), - ThumbWidth = - string.IsNullOrWhiteSpace(episodeNode.GetXmlData("thumb_width")) - ? (int?) null - : Convert.ToInt32(episodeNode.GetXmlData("thumb_width")), - TmsExport = episodeNode.GetXmlData("tms_export"), - Writers = - new List(episodeNode.GetXmlData("Writer") - .Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries)) - }; - } - - public Episode GetResult() - { - return _episode; - } - } - - private class EpisodesBuilder - { - private readonly XDocument _doc; - - public EpisodesBuilder(XDocument doc) - { - _doc = doc; - } - - public List BuildEpisodes() - { - var result = new List(); - - foreach (var episodeNode in _doc.Descendants("Episode")) - { - var episode = new EpisodeBuilder(episodeNode).GetResult(); - result.Add(episode); - } - - return result; - } - } - - public class UpdatesBuilder - { - private readonly Updates _updates; - - public UpdatesBuilder(XDocument doc) - { - if (doc.Root != null) - { - _updates = new Updates - { - Time = int.Parse(doc.Root.Attribute("time").Value), - UpdatedSeries = doc.Root.Elements("Series") - .Select(elt => new UpdatedSerie - { - Id = int.Parse(elt.Element("id").Value), - Time = int.Parse(elt.Element("time").Value) - }) - .ToList(), - UpdatedEpisodes = doc.Root.Elements("Episode") - .Select(elt => new UpdatedEpisode - { - Id = int.Parse(elt.Element("id").Value), - SerieId = int.Parse(elt.Element("Series").Value), - Time = int.Parse(elt.Element("time").Value) - }) - .ToList(), - UpdatedBanners = doc.Root.Elements("Banner") - .Select(elt => new UpdatedBanner - { - SerieId = int.Parse(elt.Element("Series").Value), - Format = elt.Element("format").Value, - Language = - elt.Elements("language").Select(n => n.Value).FirstOrDefault() ?? string.Empty, - Path = elt.Element("path").Value, - Type = elt.Element("type").Value, - SeasonNumber = elt.Elements("SeasonNumber").Any() - ? int.Parse(elt.Element("SeasonNumber").Value) - : (int?) null, - Time = int.Parse(elt.Element("time").Value) - }) - .ToList() - }; - } - } - - public Updates GetResult() - { - return _updates; - } - } - } -} \ No newline at end of file diff --git a/src/TVDBSharp/Models/DAO/DataProvider.cs b/src/TVDBSharp/Models/DAO/DataProvider.cs deleted file mode 100644 index 069233ac1..000000000 --- a/src/TVDBSharp/Models/DAO/DataProvider.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.IO; -using System.Net; -using System.Xml.Linq; -using NzbDrone.Common.Cache; -using NzbDrone.Common.Http; -using NzbDrone.Common.Instrumentation; -using TVDBSharp.Models.Enums; - -namespace TVDBSharp.Models.DAO -{ - /// - /// Standard implementation of the interface. - /// - public class DataProvider : IDataProvider - { - public string ApiKey { get; set; } - private const string BaseUrl = "http://thetvdb.com"; - - - private static HttpClient httpClient = new HttpClient(new CacheManager(), NzbDroneLogger.GetLogger(typeof(DataProvider))); - - public XDocument GetShow(int showID) - { - return GetXDocumentFromUrl(string.Format("{0}/api/{1}/series/{2}/all/en.xml", BaseUrl, ApiKey, showID)); - } - - public XDocument GetEpisode(int episodeId, string lang) - { - return GetXDocumentFromUrl(string.Format("{0}/api/{1}/episodes/{2}/{3}.xml", BaseUrl, ApiKey, episodeId, lang)); - } - - public XDocument GetUpdates(Interval interval) - { - return GetXDocumentFromUrl(string.Format("{0}/api/{1}/updates/updates_{2}.xml", BaseUrl, ApiKey, IntervalHelpers.Print(interval))); - } - - public XDocument Search(string query) - { - return GetXDocumentFromUrl(string.Format("{0}/api/GetSeries.php?seriesname={1}", BaseUrl, query)); - } - - private static XDocument GetXDocumentFromUrl(string url) - { - - 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/Models/DAO/IDataProvider.cs b/src/TVDBSharp/Models/DAO/IDataProvider.cs deleted file mode 100644 index 58eb3981b..000000000 --- a/src/TVDBSharp/Models/DAO/IDataProvider.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Xml.Linq; -using TVDBSharp.Models.Enums; - -namespace TVDBSharp.Models.DAO -{ - /// - /// Defines a Dataprovider API. - /// - public interface IDataProvider - { - /// - /// The API key provided by TVDB. - /// - string ApiKey { get; set; } - - /// - /// Retrieves the show with the given id and returns the corresponding XML tree. - /// - /// ID of the show you wish to lookup. - /// Returns an XML tree of the show object. - XDocument GetShow(int showID); - - /// - /// Retrieves the episode with the given id and returns the corresponding XML tree. - /// - /// ID of the episode to retrieve - /// ISO 639-1 language code of the episode - /// XML tree of the episode object - XDocument GetEpisode(int episodeId, string lang); - - /// - /// Retrieves updates on tvdb (Shows, Episodes and Banners) - /// - /// The interval for the updates - /// XML tree of the Updates object - XDocument GetUpdates(Interval interval); - - /// - /// Returns an XML tree representing a search query for the given parameter. - /// - /// Query to perform the search with. - /// Returns an XML tree of a search result. - XDocument Search(string query); - } -} \ No newline at end of file diff --git a/src/TVDBSharp/Models/Enums/ContentRating.cs b/src/TVDBSharp/Models/Enums/ContentRating.cs deleted file mode 100644 index 8c1b43867..000000000 --- a/src/TVDBSharp/Models/Enums/ContentRating.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace TVDBSharp.Models.Enums -{ - /// - /// Different content ratings. View http://en.wikipedia.org/wiki/TV_Parental_Guidelines for more info. - /// - public enum ContentRating - { - /// - /// Not suitable for children under 14. - /// - TV14, - - /// - /// This program contains material that parents may find unsuitable for younger children. - /// - TVPG, - - /// - /// This program is designed to be appropriate for all children. - /// - TVY, - - /// - /// This program is designed for children age 7 and above. - /// - TVY7, - - /// - /// Most parents would find this program suitable for all ages. - /// - TVG, - - /// - /// This program is specifically designed to be viewed by adults and therefore may be unsuitable for children under 17. - /// - TVMA, - - /// - /// Default value if no rating is given. - /// - Unknown - } -} \ No newline at end of file diff --git a/src/TVDBSharp/Models/Enums/Frequency.cs b/src/TVDBSharp/Models/Enums/Frequency.cs deleted file mode 100644 index f59ddb192..000000000 --- a/src/TVDBSharp/Models/Enums/Frequency.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace TVDBSharp.Models.Enums -{ - public enum Frequency - { - Monday, - Tuesday, - Wednesday, - Thursday, - Friday, - Saturday, - Sunday, - Daily - } -} \ No newline at end of file diff --git a/src/TVDBSharp/Models/Enums/Interval.cs b/src/TVDBSharp/Models/Enums/Interval.cs deleted file mode 100644 index 9783a25e2..000000000 --- a/src/TVDBSharp/Models/Enums/Interval.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; - -namespace TVDBSharp.Models.Enums -{ - public enum Interval - { - Day, - Week, - Month, - All - } - - public static class IntervalHelpers - { - public static string Print(Interval interval) - { - switch (interval) - { - case Interval.Day: - return "day"; - case Interval.Week: - return "week"; - case Interval.Month: - return "month"; - case Interval.All: - return "all"; - default: - throw new ArgumentException("Unsupported interval enum: " + interval); - } - } - } -} \ No newline at end of file diff --git a/src/TVDBSharp/Models/Enums/Status.cs b/src/TVDBSharp/Models/Enums/Status.cs deleted file mode 100644 index 1cbe6ab07..000000000 --- a/src/TVDBSharp/Models/Enums/Status.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace TVDBSharp.Models.Enums -{ - /// - /// Describes the current status of a show. - /// - public enum Status - { - /// - /// No more episodes are being released. - /// - Ended, - - /// - /// The show is ongoing. - /// - Continuing, - - /// - /// Default value if no status is specified. - /// - Unknown - } -} \ No newline at end of file diff --git a/src/TVDBSharp/Models/Episode.cs b/src/TVDBSharp/Models/Episode.cs deleted file mode 100644 index 23e53d64d..000000000 --- a/src/TVDBSharp/Models/Episode.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TVDBSharp.Models -{ - /// - /// Entity describing an episode of a show. - /// - public class Episode - { - /// - /// Unique identifier for an episode. - /// - public int Id { get; set; } - - /// - /// Director of the episode. - /// - public string Director { get; set; } - - /// - /// This episode's title. - /// - public string Title { get; set; } - - /// - /// This episode's absolute number - /// - public int? AbsoluteEpisodeNumber { get; set; } - - /// - /// This episode's number in the appropriate season. - /// - public int EpisodeNumber { get; set; } - - /// - /// This episode's season. - /// - public int SeasonNumber { get; set; } - - /// - /// The date of the first time this episode has aired. - /// - public DateTime? FirstAired { get; set; } - - /// - /// A list of guest stars. - /// - public List GuestStars { get; set; } - - /// - /// Unique identifier on IMDb. - /// - public string ImdbId { get; set; } - - /// - /// Main language spoken in the episode. - /// - public string Language { get; set; } - - /// - /// A short description of the episode. - /// - public string Description { get; set; } - - /// - /// Average rating as shown on IMDb. - /// - public decimal? Rating { get; set; } - - /// - /// Amount of votes cast. - /// - public int RatingCount { get; set; } - - /// - /// Writers(s) of the episode. - /// - public List Writers { get; set; } - - /// - /// Let me know if you find out what this is. - /// - public Uri EpisodeImage { get; set; } - - /// - /// Timestamp of the last update to this episode. - /// - public long? LastUpdated { get; set; } - - /// - /// Unique identifier of the season. - /// - public int SeasonId { get; set; } - - /// - /// Unique identifier of the show. - /// - public int SeriesId { get; set; } - - /// - /// Height dimension of the thumbnail in pixels. - /// - public int? ThumbHeight { get; set; } - - /// - /// Width dimension of the thumbnail in pixels; - /// - public int? ThumbWidth { get; set; } - - /// - /// Let me know if you find out what this is. - /// - public string TmsExport { get; set; } - } -} \ No newline at end of file diff --git a/src/TVDBSharp/Models/Show.cs b/src/TVDBSharp/Models/Show.cs deleted file mode 100644 index 5b671bb06..000000000 --- a/src/TVDBSharp/Models/Show.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System; -using System.Collections.Generic; -using TVDBSharp.Models.Enums; - -namespace TVDBSharp.Models -{ - /// - /// Entity describing a show. - /// - public class Show - { - /// - /// Unique identifier used by IMDb. - /// - public string ImdbId { get; set; } - - /// - /// Unique identifier used by TVDB and TVDBSharp. - /// - public int Id { get; set; } - - /// - /// List of all actors in the show. - /// - public List Actors { get; set; } - - /// - /// Day of the week when the show airs. - /// - public Frequency? AirDay { get; set; } - - /// - /// Time of the day when the show airs. - /// - public TimeSpan? AirTime { get; set; } - - /// - /// Rating of the content provided by an official organ. - /// - public ContentRating ContentRating { get; set; } - - /// - /// The date the show aired for the first time. - /// - public DateTime? FirstAired { get; set; } - - /// - /// A list of genres the show is associated with. - /// - public List Genres { get; set; } - - /// - /// Main language of the show. - /// - public string Language { get; set; } - - /// - /// Network that broadcasts the show. - /// - public string Network { get; set; } - - /// - /// A short overview of the show. - /// - public string Description { get; set; } - - /// - /// Average rating as shown on IMDb. - /// - public decimal? Rating { get; set; } - - /// - /// Amount of votes cast. - /// - public int RatingCount { get; set; } - - /// - /// Let me know if you find out what this is. - /// - public int? Runtime { get; set; } - - /// - /// Name of the show. - /// - public string Name { get; set; } - - /// - /// Current status of the show. - /// - public Status Status { get; set; } - - /// - /// Link to the banner image. - /// - public Uri Banner { get; set; } - - /// - /// Link to a fanart image. - /// - public Uri Fanart { get; set; } - - /// - /// Timestamp of the latest update. - /// - public long? LastUpdated { get; set; } - - /// - /// Let me know if you find out what this is. - /// - public Uri Poster { get; set; } - - /// - /// No clue - /// - public string Zap2ItID { get; set; } - - /// - /// A list of all episodes associated with this show. - /// - public List Episodes { get; set; } - } -} \ No newline at end of file diff --git a/src/TVDBSharp/Models/Updates.cs b/src/TVDBSharp/Models/Updates.cs deleted file mode 100644 index 743def719..000000000 --- a/src/TVDBSharp/Models/Updates.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TVDBSharp.Models -{ - public class Updates : UnixTimestampedObject - { - public List UpdatedBanners { get; set; } - public List UpdatedEpisodes { get; set; } - public List UpdatedSeries { get; set; } - } - - public class UnixTimestampedObject - { - private static DateTime _startDate = new DateTime(1970, 1, 1); - private int _unixTimestamp; - - public DateTime Timestamp - { - get { return _startDate.AddSeconds(_unixTimestamp); } - } - - public int Time - { - set { _unixTimestamp = value; } - } - } - - public class UpdatedSerie : UnixTimestampedObject - { - public int Id { get; set; } - } - - public class UpdatedEpisode : UnixTimestampedObject - { - public int Id { get; set; } - public int SerieId { get; set; } - } - - public class UpdatedBanner : UnixTimestampedObject - { - public int SerieId { get; set; } - public string Format { get; set; } - public string Language { get; set; } - public string Path { get; set; } - public string Type { get; set; } - public int? SeasonNumber { get; set; } - } -} \ No newline at end of file diff --git a/src/TVDBSharp/Properties/AssemblyInfo.cs b/src/TVDBSharp/Properties/AssemblyInfo.cs deleted file mode 100644 index 6b7f6448f..000000000 --- a/src/TVDBSharp/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("TVDBSharp")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TVDBSharp")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("c78961a8-afda-4a36-910b-bf5a090eebb3")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/src/TVDBSharp/TVDB.cs b/src/TVDBSharp/TVDB.cs deleted file mode 100644 index 2566c0943..000000000 --- a/src/TVDBSharp/TVDB.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.Collections.Generic; -using TVDBSharp.Models; -using TVDBSharp.Models.DAO; -using TVDBSharp.Models.Enums; - -namespace TVDBSharp -{ - /// - /// The main class which will handle all user interaction. - /// - public class TVDB - { - private readonly IDataProvider _dataProvider; - - /// - /// Creates a new instance with the provided API key and dataProvider. - /// - /// The API key provided by TVDB. - /// Specify your own instance. - public TVDB(string apiKey, IDataProvider dataProvider) - { - _dataProvider = dataProvider; - _dataProvider.ApiKey = apiKey; - } - - /// - /// Creates a new instance with the provided API key and standard . - /// - /// The API key provided by TVDB. - public TVDB(string apiKey) - { - _dataProvider = new DataProvider {ApiKey = apiKey}; - } - - /// - /// Search for a show in the database. - /// - /// Query that identifies the show. - /// Maximal amount of results in the returning set. Default is 5. - /// Returns a list of shows. - public List Search(string query, int results = 5) - { - return new Builder(_dataProvider).Search(query, results); - } - - /// - /// Get a specific show based on its ID. - /// - /// ID of the show. - /// Returns the corresponding show. - public Show GetShow(int showId) - { - return new Builder(_dataProvider).BuildShow(showId); - } - - /// - /// Get a specific episode based on its ID. - /// - /// ID of the episode - /// ISO 639-1 language code for the episode - /// The corresponding episode - public Episode GetEpisode(int episodeId, string lang = "en") - { - return new Builder(_dataProvider).BuildEpisode(episodeId, lang); - } - - public Updates GetUpdates(Interval interval) - { - return new Builder(_dataProvider).BuildUpdates(interval); - } - } -} \ No newline at end of file diff --git a/src/TVDBSharp/TVDBSharp.csproj b/src/TVDBSharp/TVDBSharp.csproj deleted file mode 100644 index 7bac75553..000000000 --- a/src/TVDBSharp/TVDBSharp.csproj +++ /dev/null @@ -1,83 +0,0 @@ - - - - Debug - x86 - {0CC493D7-0A9F-4199-9615-0A977945D716} - Library - Properties - TVDBSharp - TVDBSharp - v4.0 - 512 - ..\ - true - - - - - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - prompt - MinimumRecommendedRules.ruleset - - - - ..\packages\NLog.2.1.0\lib\net40\NLog.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {F2BE0FDF-6E47-4827-A420-DD4EF82407F8} - NzbDrone.Common - - - - - diff --git a/src/TVDBSharp/Utilities/Extensions.cs b/src/TVDBSharp/Utilities/Extensions.cs deleted file mode 100644 index 641413717..000000000 --- a/src/TVDBSharp/Utilities/Extensions.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Xml.Linq; -using System.Xml.Schema; - -namespace TVDBSharp.Utilities -{ - /// - /// Extension methods used to simplify data extraction. - /// - public static class Extensions - { - /// - /// Retrieves a value from an XML tree representing a show. - /// - /// XML tree representing a show. - /// Name of the element with the data. - /// Returns the value corresponding to the given element name. - /// Thrown when the element doesn't exist or the XML tree is incorrect. - public static string GetSeriesData(this XDocument doc, string element) - { - var root = doc.Element("Data"); - if (root != null) - { - var xElement = root.Element("Series"); - if (xElement != null) - { - var result = xElement.Element(element); - if (result != null) - { - return result.Value; - } - throw new XmlSchemaException("Could not find element <" + element + ">"); - } - throw new XmlSchemaException("Could not find element "); - } - throw new XmlSchemaException("Could not find element "); - } - - /// - /// Retrieves a value from an XML tree. - /// - /// The given XML (sub)tree. - /// Name of the element with the data. - /// Returns the value corresponding to the given element name; - /// Thrown when the element doesn't exist. - public static string GetXmlData(this XElement xmlObject, string element) - { - var result = xmlObject.Element(element); - - return result != null ? result.Value : null; - - // Removed in favor of returning a null value - // This will allow us to catch a non-existing tag with the null-coalescing operator - // Never trust the XML provider. - - //throw new XmlSchemaException("Element <" + element + "> could not be found."); - } - } -} \ No newline at end of file diff --git a/src/TVDBSharp/Utilities/Utils.cs b/src/TVDBSharp/Utilities/Utils.cs deleted file mode 100644 index 5a3280da3..000000000 --- a/src/TVDBSharp/Utilities/Utils.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Globalization; -using TVDBSharp.Models.Enums; - -namespace TVDBSharp.Utilities -{ - /// - /// Provides static utility methods. - /// - public static class Utils - { - /// - /// Parses a string of format yyyy-MM-dd to a object. - /// - /// String to be parsed. - /// Returns a representation. - public static DateTime ParseDate(string value) - { - DateTime date; - DateTime.TryParseExact(value, "yyyy-MM-dd", CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal, out date); - return date; - } - - /// - /// Parses a string of format hh:mm tt to a object. - /// - /// String to be parsed. - /// Returns a representation. - public static TimeSpan ParseTime(string value) - { - DateTime date; - - if (!DateTime.TryParse(value, out date)) - { - return new TimeSpan(); - } - return date.TimeOfDay; - } - - /// - /// Translates the incoming string to a enum, if applicable. - /// - /// The rating in string format. - /// Returns the appropriate value. - /// Throws an exception if no conversion could be applied. - public static ContentRating GetContentRating(string rating) - { - switch (rating) - { - case "TV-14": - return ContentRating.TV14; - - case "TV-PG": - return ContentRating.TVPG; - - case "TV-Y": - return ContentRating.TVY; - - case "TV-Y7": - return ContentRating.TVY7; - - case "TV-G": - return ContentRating.TVG; - - case "TV-MA": - return ContentRating.TVMA; - - default: - return ContentRating.Unknown; - } - } - } -} \ No newline at end of file