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