Fixed: Posters not always showing when searching for new authors

(cherry picked from commit 10dc884fa87a8337e9f0622c269adede0b262029)

Co-authored-by: optimous012

Closes #145
This commit is contained in:
Taloth Saldono
2020-01-12 22:26:29 +01:00
committed by Bogdan
parent 52c3a95e63
commit bb5ad605fd
11 changed files with 184 additions and 34 deletions
@@ -11,10 +11,12 @@ namespace Readarr.Api.V1.Author
public class AuthorLookupController : Controller
{
private readonly ISearchForNewAuthor _searchProxy;
private readonly IMapCoversToLocal _coverMapper;
public AuthorLookupController(ISearchForNewAuthor searchProxy)
public AuthorLookupController(ISearchForNewAuthor searchProxy, IMapCoversToLocal coverMapper)
{
_searchProxy = searchProxy;
_coverMapper = coverMapper;
}
[HttpGet]
@@ -24,12 +26,16 @@ namespace Readarr.Api.V1.Author
return MapToResource(searchResults).ToList();
}
private static IEnumerable<AuthorResource> MapToResource(IEnumerable<NzbDrone.Core.Books.Author> author)
private IEnumerable<AuthorResource> MapToResource(IEnumerable<NzbDrone.Core.Books.Author> author)
{
foreach (var currentAuthor in author)
{
var resource = currentAuthor.ToResource();
_coverMapper.ConvertToLocalUrls(resource.Id, MediaCoverEntity.Author, resource.Images);
var poster = currentAuthor.Metadata.Value.Images.FirstOrDefault(c => c.CoverType == MediaCoverTypes.Poster);
if (poster != null)
{
resource.RemotePoster = poster.Url;