From 5557ac84547bbaf6b6d9bec70063790e2775914c Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Mon, 2 Sep 2013 23:18:54 -0700 Subject: [PATCH] emergency hack to fix breaking trakt api. --- .../Trakt/{Show.cs => FullShow.cs} | 27 +++++++++++++++++++ NzbDrone.Core/MetadataSource/TraktProxy.cs | 26 ++++++++++++++++-- NzbDrone.Core/NzbDrone.Core.csproj | 2 +- 3 files changed, 52 insertions(+), 3 deletions(-) rename NzbDrone.Core/MetadataSource/Trakt/{Show.cs => FullShow.cs} (52%) diff --git a/NzbDrone.Core/MetadataSource/Trakt/Show.cs b/NzbDrone.Core/MetadataSource/Trakt/FullShow.cs similarity index 52% rename from NzbDrone.Core/MetadataSource/Trakt/Show.cs rename to NzbDrone.Core/MetadataSource/Trakt/FullShow.cs index bf7745d43..32c60c5fb 100644 --- a/NzbDrone.Core/MetadataSource/Trakt/Show.cs +++ b/NzbDrone.Core/MetadataSource/Trakt/FullShow.cs @@ -29,4 +29,31 @@ namespace NzbDrone.Core.MetadataSource.Trakt public List genres { get; set; } public List seasons { 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/NzbDrone.Core/MetadataSource/TraktProxy.cs b/NzbDrone.Core/MetadataSource/TraktProxy.cs index 4a84c0cbd..2c18b5594 100644 --- a/NzbDrone.Core/MetadataSource/TraktProxy.cs +++ b/NzbDrone.Core/MetadataSource/TraktProxy.cs @@ -19,9 +19,9 @@ namespace NzbDrone.Core.MetadataSource { var client = BuildClient("search", "shows"); var restRequest = new RestRequest(GetSearchTerm(title)); - var response = client.ExecuteAndValidate>(restRequest); + var response = client.ExecuteAndValidate>(restRequest); - return response.Select(MapSeries).ToList(); + return response.Select(MapSearchSeries).ToList(); } @@ -77,6 +77,28 @@ namespace NzbDrone.Core.MetadataSource return series; } + private static Series MapSearchSeries(SearchShow show) + { + var series = new Series(); + series.TvdbId = show.tvdb_id; + series.TvRageId = show.tvrage_id; + series.ImdbId = show.imdb_id; + series.Title = show.title; + series.CleanTitle = Parser.Parser.CleanSeriesTitle(show.title); + series.FirstAired = FromIso(show.first_aired_iso); + series.Overview = show.overview; + series.Runtime = show.runtime; + series.Network = show.network; + series.AirTime = show.air_time_utc; + series.TitleSlug = show.url.ToLower().Replace("http://trakt.tv/show/", ""); + series.Status = GetSeriesStatus(show.status); + + series.Images.Add(new MediaCover.MediaCover { CoverType = MediaCoverTypes.Banner, Url = show.images.banner }); + series.Images.Add(new MediaCover.MediaCover { CoverType = MediaCoverTypes.Poster, Url = GetPosterThumbnailUrl(show.images.poster) }); + series.Images.Add(new MediaCover.MediaCover { CoverType = MediaCoverTypes.Fanart, Url = show.images.fanart }); + return series; + } + private static Episode MapEpisode(Trakt.Episode traktEpisode) { var episode = new Episode(); diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 3f95a1ab6..793db0f0a 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -297,7 +297,7 @@ - +