From 2a89897a99a1bdaea8b207692448f0837c3eb1fb Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sat, 25 May 2013 18:19:03 -0700 Subject: [PATCH] fixed posters for add series search --- NzbDrone.Api/Series/SeriesLookupModule.cs | 28 +++++++++++++++---- NzbDrone.Api/Series/SeriesResource.cs | 3 ++ UI/AddSeries/Collection.js | 4 ++- UI/AddSeries/Existing/ImportSeriesView.js | 4 +++ .../UnmappedFolderCompositeViewTemplate.html | 8 ++++-- UI/AddSeries/SearchResultTemplate.html | 2 +- 6 files changed, 40 insertions(+), 9 deletions(-) diff --git a/NzbDrone.Api/Series/SeriesLookupModule.cs b/NzbDrone.Api/Series/SeriesLookupModule.cs index 7cf6832bb..ffa36ea83 100644 --- a/NzbDrone.Api/Series/SeriesLookupModule.cs +++ b/NzbDrone.Api/Series/SeriesLookupModule.cs @@ -1,12 +1,14 @@ -using System.Threading; +using System.Collections.Generic; using Nancy; using NzbDrone.Api.Extensions; +using NzbDrone.Core.MediaCover; using NzbDrone.Core.MetadataSource; using System.Linq; +using NzbDrone.Api.Mapping; namespace NzbDrone.Api.Series { - public class SeriesLookupModule : NzbDroneApiModule + public class SeriesLookupModule : NzbDroneRestModule { private readonly ISearchForNewSeries _searchProxy; @@ -14,14 +16,30 @@ namespace NzbDrone.Api.Series : base("/Series/lookup") { _searchProxy = searchProxy; - Get["/"] = x => GetQualityType(); + Get["/"] = x => Search(); } - private Response GetQualityType() + private Response Search() { var tvDbResults = _searchProxy.SearchForNewSeries((string)Request.Query.term); - return tvDbResults.FirstOrDefault().AsResponse(); + return MapToResource(tvDbResults).FirstOrDefault().AsResponse(); + } + + + private static IEnumerable MapToResource(IEnumerable series) + { + foreach (var currentSeries in series) + { + var resource = currentSeries.InjectTo(); + var poster = currentSeries.Images.FirstOrDefault(c => c.CoverType == MediaCoverTypes.Poster); + if (poster != null) + { + resource.RemotePoster = poster.Url; + } + + yield return resource; + } } } } \ No newline at end of file diff --git a/NzbDrone.Api/Series/SeriesResource.cs b/NzbDrone.Api/Series/SeriesResource.cs index a5f71a7d5..06eda15f8 100644 --- a/NzbDrone.Api/Series/SeriesResource.cs +++ b/NzbDrone.Api/Series/SeriesResource.cs @@ -26,6 +26,9 @@ namespace NzbDrone.Api.Series public Int32 UtcOffset { get; set; } public List Images { get; set; } + public String RemotePoster { get; set; } + + //View & Edit public String Path { get; set; } public Int32 QualityProfileId { get; set; } diff --git a/UI/AddSeries/Collection.js b/UI/AddSeries/Collection.js index 41e1a2c31..030fc5026 100644 --- a/UI/AddSeries/Collection.js +++ b/UI/AddSeries/Collection.js @@ -5,7 +5,9 @@ define(['app', 'Series/SeriesModel'], function () { model: NzbDrone.Series.SeriesModel, parse: function (response) { - response.id = undefined; + if (response) { + response.id = undefined; + } return response; } }); diff --git a/UI/AddSeries/Existing/ImportSeriesView.js b/UI/AddSeries/Existing/ImportSeriesView.js index 026cc386d..8bff9bee4 100644 --- a/UI/AddSeries/Existing/ImportSeriesView.js +++ b/UI/AddSeries/Existing/ImportSeriesView.js @@ -18,6 +18,10 @@ define([ 'click .x-add': 'addSeries' }, + initialize: function () { + this.model.set('isExisting', true); + }, + addSeries: function () { var icon = this.ui.addButton.find('icon'); icon.removeClass('icon-plus').addClass('icon-spin icon-spinner disabled'); diff --git a/UI/AddSeries/Existing/UnmappedFolderCompositeViewTemplate.html b/UI/AddSeries/Existing/UnmappedFolderCompositeViewTemplate.html index 071fb4fde..5190eb73e 100644 --- a/UI/AddSeries/Existing/UnmappedFolderCompositeViewTemplate.html +++ b/UI/AddSeries/Existing/UnmappedFolderCompositeViewTemplate.html @@ -1,5 +1,8 @@ 
+
+
+
@@ -11,7 +14,8 @@
-
-
+
+ load more
+
\ No newline at end of file diff --git a/UI/AddSeries/SearchResultTemplate.html b/UI/AddSeries/SearchResultTemplate.html index e3d330d87..cbd763dc5 100644 --- a/UI/AddSeries/SearchResultTemplate.html +++ b/UI/AddSeries/SearchResultTemplate.html @@ -2,7 +2,7 @@