mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-22 22:16:13 -04:00
New: Series folder hint when selecting a root folder while adding a new series
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using Nancy;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.MetadataSource;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.SeriesStats;
|
||||
using Sonarr.Http;
|
||||
using Sonarr.Http.Extensions;
|
||||
@@ -12,33 +13,35 @@ namespace Sonarr.Api.V3.Series
|
||||
public class SeriesLookupModule : SonarrRestModule<SeriesResource>
|
||||
{
|
||||
private readonly ISearchForNewSeries _searchProxy;
|
||||
private readonly IBuildFileNames _fileNameBuilder;
|
||||
|
||||
public SeriesLookupModule(ISearchForNewSeries searchProxy)
|
||||
public SeriesLookupModule(ISearchForNewSeries searchProxy, IBuildFileNames fileNameBuilder)
|
||||
: base("/series/lookup")
|
||||
{
|
||||
_searchProxy = searchProxy;
|
||||
_fileNameBuilder = fileNameBuilder;
|
||||
Get["/"] = x => Search();
|
||||
}
|
||||
|
||||
|
||||
private Response Search()
|
||||
{
|
||||
var tvDbResults = _searchProxy.SearchForNewSeries((string)Request.Query.term);
|
||||
return MapToResource(tvDbResults).AsResponse();
|
||||
}
|
||||
|
||||
|
||||
private static IEnumerable<SeriesResource> MapToResource(IEnumerable<NzbDrone.Core.Tv.Series> series)
|
||||
private IEnumerable<SeriesResource> MapToResource(IEnumerable<NzbDrone.Core.Tv.Series> series)
|
||||
{
|
||||
foreach (var currentSeries in series)
|
||||
{
|
||||
var resource = currentSeries.ToResource();
|
||||
var poster = currentSeries.Images.FirstOrDefault(c => c.CoverType == MediaCoverTypes.Poster);
|
||||
|
||||
if (poster != null)
|
||||
{
|
||||
resource.RemotePoster = poster.Url;
|
||||
}
|
||||
|
||||
resource.Folder = _fileNameBuilder.GetSeriesFolder(currentSeries);
|
||||
resource.Statistics = new SeriesStatistics().ToResource(resource.Seasons);
|
||||
|
||||
yield return resource;
|
||||
|
||||
Reference in New Issue
Block a user