fixed posters for add series search

This commit is contained in:
kay.one 2013-05-25 18:19:03 -07:00
parent 9ed187202a
commit 2a89897a99
6 changed files with 40 additions and 9 deletions

View File

@ -1,12 +1,14 @@
using System.Threading; using System.Collections.Generic;
using Nancy; using Nancy;
using NzbDrone.Api.Extensions; using NzbDrone.Api.Extensions;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource; using NzbDrone.Core.MetadataSource;
using System.Linq; using System.Linq;
using NzbDrone.Api.Mapping;
namespace NzbDrone.Api.Series namespace NzbDrone.Api.Series
{ {
public class SeriesLookupModule : NzbDroneApiModule public class SeriesLookupModule : NzbDroneRestModule<SeriesResource>
{ {
private readonly ISearchForNewSeries _searchProxy; private readonly ISearchForNewSeries _searchProxy;
@ -14,14 +16,30 @@ namespace NzbDrone.Api.Series
: base("/Series/lookup") : base("/Series/lookup")
{ {
_searchProxy = searchProxy; _searchProxy = searchProxy;
Get["/"] = x => GetQualityType(); Get["/"] = x => Search();
} }
private Response GetQualityType() private Response Search()
{ {
var tvDbResults = _searchProxy.SearchForNewSeries((string)Request.Query.term); var tvDbResults = _searchProxy.SearchForNewSeries((string)Request.Query.term);
return tvDbResults.FirstOrDefault().AsResponse(); return MapToResource(tvDbResults).FirstOrDefault().AsResponse();
}
private static IEnumerable<SeriesResource> MapToResource(IEnumerable<Core.Tv.Series> series)
{
foreach (var currentSeries in series)
{
var resource = currentSeries.InjectTo<SeriesResource>();
var poster = currentSeries.Images.FirstOrDefault(c => c.CoverType == MediaCoverTypes.Poster);
if (poster != null)
{
resource.RemotePoster = poster.Url;
}
yield return resource;
}
} }
} }
} }

View File

@ -26,6 +26,9 @@ namespace NzbDrone.Api.Series
public Int32 UtcOffset { get; set; } public Int32 UtcOffset { get; set; }
public List<Core.MediaCover.MediaCover> Images { get; set; } public List<Core.MediaCover.MediaCover> Images { get; set; }
public String RemotePoster { get; set; }
//View & Edit //View & Edit
public String Path { get; set; } public String Path { get; set; }
public Int32 QualityProfileId { get; set; } public Int32 QualityProfileId { get; set; }

View File

@ -5,7 +5,9 @@ define(['app', 'Series/SeriesModel'], function () {
model: NzbDrone.Series.SeriesModel, model: NzbDrone.Series.SeriesModel,
parse: function (response) { parse: function (response) {
response.id = undefined; if (response) {
response.id = undefined;
}
return response; return response;
} }
}); });

View File

@ -18,6 +18,10 @@ define([
'click .x-add': 'addSeries' 'click .x-add': 'addSeries'
}, },
initialize: function () {
this.model.set('isExisting', true);
},
addSeries: function () { addSeries: function () {
var icon = this.ui.addButton.find('icon'); var icon = this.ui.addButton.find('icon');
icon.removeClass('icon-plus').addClass('icon-spin icon-spinner disabled'); icon.removeClass('icon-plus').addClass('icon-spin icon-spinner disabled');

View File

@ -1,5 +1,8 @@
<div class="unmapped-folder-view"> <div class="unmapped-folder-view">
<div class="row"> <div class="row">
<div class="x-folder-name-match-results folder-name-matches"/>
</div>
<div class="row" style="visibility: collapse;">
<div class="folder-header span11"> <div class="folder-header span11">
<div class="input-prepend"> <div class="input-prepend">
<i class="add-on icon-search"></i> <i class="add-on icon-search"></i>
@ -11,7 +14,8 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row text-center">
<div class="x-folder-name-match-results folder-name-matches"/> load more
</div> </div>
</div> </div>

View File

@ -2,7 +2,7 @@
<div class="row"> <div class="row">
<div class="span2"> <div class="span2">
<a href="{{traktUrl}}" target="_blank"> <a href="{{traktUrl}}" target="_blank">
<img class="series-poster img-polaroid" src="{{poster}}"> <img class="series-poster img-polaroid" src="{{remotePoster}}">
</a> </a>
</div> </div>
<div class="span9"> <div class="span9">