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