mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-18 16:29:41 +02:00
Add media proxy for collections, credits and discovery images
This commit is contained in:
parent
9db0058114
commit
07cfbb59da
@ -3,6 +3,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Datastore.Events;
|
using NzbDrone.Core.Datastore.Events;
|
||||||
|
using NzbDrone.Core.MediaCover;
|
||||||
using NzbDrone.Core.Messaging.Commands;
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Core.Movies;
|
using NzbDrone.Core.Movies;
|
||||||
@ -28,6 +29,7 @@ public class CollectionController : RestControllerWithSignalR<CollectionResource
|
|||||||
private readonly IMovieMetadataService _movieMetadataService;
|
private readonly IMovieMetadataService _movieMetadataService;
|
||||||
private readonly IBuildFileNames _fileNameBuilder;
|
private readonly IBuildFileNames _fileNameBuilder;
|
||||||
private readonly INamingConfigService _namingService;
|
private readonly INamingConfigService _namingService;
|
||||||
|
private readonly IMapCoversToLocal _coverMapper;
|
||||||
private readonly IManageCommandQueue _commandQueueManager;
|
private readonly IManageCommandQueue _commandQueueManager;
|
||||||
|
|
||||||
public CollectionController(IBroadcastSignalRMessage signalRBroadcaster,
|
public CollectionController(IBroadcastSignalRMessage signalRBroadcaster,
|
||||||
@ -36,6 +38,7 @@ public CollectionController(IBroadcastSignalRMessage signalRBroadcaster,
|
|||||||
IMovieMetadataService movieMetadataService,
|
IMovieMetadataService movieMetadataService,
|
||||||
IBuildFileNames fileNameBuilder,
|
IBuildFileNames fileNameBuilder,
|
||||||
INamingConfigService namingService,
|
INamingConfigService namingService,
|
||||||
|
IMapCoversToLocal coverMapper,
|
||||||
IManageCommandQueue commandQueueManager)
|
IManageCommandQueue commandQueueManager)
|
||||||
: base(signalRBroadcaster)
|
: base(signalRBroadcaster)
|
||||||
{
|
{
|
||||||
@ -44,6 +47,7 @@ public CollectionController(IBroadcastSignalRMessage signalRBroadcaster,
|
|||||||
_movieMetadataService = movieMetadataService;
|
_movieMetadataService = movieMetadataService;
|
||||||
_fileNameBuilder = fileNameBuilder;
|
_fileNameBuilder = fileNameBuilder;
|
||||||
_namingService = namingService;
|
_namingService = namingService;
|
||||||
|
_coverMapper = coverMapper;
|
||||||
_commandQueueManager = commandQueueManager;
|
_commandQueueManager = commandQueueManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +150,8 @@ private IEnumerable<CollectionResource> MapToResource(List<MovieCollection> coll
|
|||||||
var movieResource = movie.ToResource();
|
var movieResource = movie.ToResource();
|
||||||
movieResource.Folder = _fileNameBuilder.GetMovieFolder(new Movie { MovieMetadata = movie }, namingConfig);
|
movieResource.Folder = _fileNameBuilder.GetMovieFolder(new Movie { MovieMetadata = movie }, namingConfig);
|
||||||
|
|
||||||
|
_coverMapper.ConvertToLocalUrls(0, movieResource.Images);
|
||||||
|
|
||||||
if (!existingMoviesTmdbIds.Contains(movie.TmdbId))
|
if (!existingMoviesTmdbIds.Contains(movie.TmdbId))
|
||||||
{
|
{
|
||||||
resource.MissingMovies++;
|
resource.MissingMovies++;
|
||||||
@ -169,6 +175,8 @@ private CollectionResource MapToResource(MovieCollection collection)
|
|||||||
var movieResource = movie.ToResource();
|
var movieResource = movie.ToResource();
|
||||||
movieResource.Folder = _fileNameBuilder.GetMovieFolder(new Movie { MovieMetadata = movie }, namingConfig);
|
movieResource.Folder = _fileNameBuilder.GetMovieFolder(new Movie { MovieMetadata = movie }, namingConfig);
|
||||||
|
|
||||||
|
_coverMapper.ConvertToLocalUrls(0, movieResource.Images);
|
||||||
|
|
||||||
if (!existingMoviesTmdbIds.Contains(movie.TmdbId))
|
if (!existingMoviesTmdbIds.Contains(movie.TmdbId))
|
||||||
{
|
{
|
||||||
resource.MissingMovies++;
|
resource.MissingMovies++;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NzbDrone.Core.MediaCover;
|
||||||
using NzbDrone.Core.Movies;
|
using NzbDrone.Core.Movies;
|
||||||
using NzbDrone.Core.Movies.Credits;
|
using NzbDrone.Core.Movies.Credits;
|
||||||
using Radarr.Http;
|
using Radarr.Http;
|
||||||
@ -12,11 +13,13 @@ public class CreditController : RestController<CreditResource>
|
|||||||
{
|
{
|
||||||
private readonly ICreditService _creditService;
|
private readonly ICreditService _creditService;
|
||||||
private readonly IMovieService _movieService;
|
private readonly IMovieService _movieService;
|
||||||
|
private readonly IMapCoversToLocal _coverMapper;
|
||||||
|
|
||||||
public CreditController(ICreditService creditService, IMovieService movieService)
|
public CreditController(ICreditService creditService, IMovieService movieService, IMapCoversToLocal coverMapper)
|
||||||
{
|
{
|
||||||
_creditService = creditService;
|
_creditService = creditService;
|
||||||
_movieService = movieService;
|
_movieService = movieService;
|
||||||
|
_coverMapper = coverMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override CreditResource GetResourceById(int id)
|
protected override CreditResource GetResourceById(int id)
|
||||||
@ -25,20 +28,32 @@ protected override CreditResource GetResourceById(int id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public List<CreditResource> GetCredits(int? movieId, int? movieMetadataId)
|
public object GetCredits(int? movieId, int? movieMetadataId)
|
||||||
{
|
{
|
||||||
if (movieMetadataId.HasValue)
|
if (movieMetadataId.HasValue)
|
||||||
{
|
{
|
||||||
return _creditService.GetAllCreditsForMovieMetadata(movieMetadataId.Value).ToResource();
|
return MapToResource(_creditService.GetAllCreditsForMovieMetadata(movieMetadataId.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (movieId.HasValue)
|
if (movieId.HasValue)
|
||||||
{
|
{
|
||||||
var movie = _movieService.GetMovie(movieId.Value);
|
var movie = _movieService.GetMovie(movieId.Value);
|
||||||
return _creditService.GetAllCreditsForMovieMetadata(movie.MovieMetadataId).ToResource();
|
|
||||||
|
return MapToResource(_creditService.GetAllCreditsForMovieMetadata(movie.MovieMetadataId));
|
||||||
}
|
}
|
||||||
|
|
||||||
return _creditService.GetAllCredits().ToResource();
|
return MapToResource(_creditService.GetAllCredits());
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<CreditResource> MapToResource(IEnumerable<Credit> credits)
|
||||||
|
{
|
||||||
|
foreach (var currentCredits in credits)
|
||||||
|
{
|
||||||
|
var resource = currentCredits.ToResource();
|
||||||
|
_coverMapper.ConvertToLocalUrls(0, resource.Images);
|
||||||
|
|
||||||
|
yield return resource;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ public class ImportListMoviesController : Controller
|
|||||||
private readonly IImportExclusionsService _importExclusionService;
|
private readonly IImportExclusionsService _importExclusionService;
|
||||||
private readonly INamingConfigService _namingService;
|
private readonly INamingConfigService _namingService;
|
||||||
private readonly IMovieTranslationService _movieTranslationService;
|
private readonly IMovieTranslationService _movieTranslationService;
|
||||||
|
private readonly IMapCoversToLocal _coverMapper;
|
||||||
private readonly IConfigService _configService;
|
private readonly IConfigService _configService;
|
||||||
|
|
||||||
public ImportListMoviesController(IMovieService movieService,
|
public ImportListMoviesController(IMovieService movieService,
|
||||||
@ -39,6 +40,7 @@ public ImportListMoviesController(IMovieService movieService,
|
|||||||
IImportExclusionsService importExclusionsService,
|
IImportExclusionsService importExclusionsService,
|
||||||
INamingConfigService namingService,
|
INamingConfigService namingService,
|
||||||
IMovieTranslationService movieTranslationService,
|
IMovieTranslationService movieTranslationService,
|
||||||
|
IMapCoversToLocal coverMapper,
|
||||||
IConfigService configService)
|
IConfigService configService)
|
||||||
{
|
{
|
||||||
_movieService = movieService;
|
_movieService = movieService;
|
||||||
@ -50,13 +52,14 @@ public ImportListMoviesController(IMovieService movieService,
|
|||||||
_importExclusionService = importExclusionsService;
|
_importExclusionService = importExclusionsService;
|
||||||
_namingService = namingService;
|
_namingService = namingService;
|
||||||
_movieTranslationService = movieTranslationService;
|
_movieTranslationService = movieTranslationService;
|
||||||
|
_coverMapper = coverMapper;
|
||||||
_configService = configService;
|
_configService = configService;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public object GetDiscoverMovies(bool includeRecommendations = false)
|
public object GetDiscoverMovies(bool includeRecommendations = false)
|
||||||
{
|
{
|
||||||
var movieLanguge = (Language)_configService.MovieInfoLanguage;
|
var movieLanguage = (Language)_configService.MovieInfoLanguage;
|
||||||
|
|
||||||
var realResults = new List<ImportListMoviesResource>();
|
var realResults = new List<ImportListMoviesResource>();
|
||||||
var listExclusions = _importExclusionService.GetAllExclusions();
|
var listExclusions = _importExclusionService.GetAllExclusions();
|
||||||
@ -73,11 +76,11 @@ public object GetDiscoverMovies(bool includeRecommendations = false)
|
|||||||
mapped = _movieInfo.GetBulkMovieInfo(results).Select(m => new Movie { MovieMetadata = m }).ToList();
|
mapped = _movieInfo.GetBulkMovieInfo(results).Select(m => new Movie { MovieMetadata = m }).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
realResults.AddRange(MapToResource(mapped.Where(x => x != null), movieLanguge));
|
realResults.AddRange(MapToResource(mapped.Where(x => x != null), movieLanguage));
|
||||||
realResults.ForEach(x => x.IsRecommendation = true);
|
realResults.ForEach(x => x.IsRecommendation = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var listMovies = MapToResource(_listMovieService.GetAllForLists(_importListFactory.Enabled().Select(x => x.Definition.Id).ToList()), movieLanguge).ToList();
|
var listMovies = MapToResource(_listMovieService.GetAllForLists(_importListFactory.Enabled().Select(x => x.Definition.Id).ToList()), movieLanguage).ToList();
|
||||||
|
|
||||||
realResults.AddRange(listMovies);
|
realResults.AddRange(listMovies);
|
||||||
|
|
||||||
@ -114,7 +117,9 @@ private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<Movie> m
|
|||||||
|
|
||||||
foreach (var currentMovie in movies)
|
foreach (var currentMovie in movies)
|
||||||
{
|
{
|
||||||
var resource = DiscoverMoviesResourceMapper.ToResource(currentMovie);
|
var resource = currentMovie.ToResource();
|
||||||
|
_coverMapper.ConvertToLocalUrls(0, resource.Images);
|
||||||
|
|
||||||
var poster = currentMovie.MovieMetadata.Value.Images.FirstOrDefault(c => c.CoverType == MediaCoverTypes.Poster);
|
var poster = currentMovie.MovieMetadata.Value.Images.FirstOrDefault(c => c.CoverType == MediaCoverTypes.Poster);
|
||||||
if (poster != null)
|
if (poster != null)
|
||||||
{
|
{
|
||||||
@ -142,7 +147,9 @@ private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<ImportLi
|
|||||||
|
|
||||||
foreach (var currentMovie in movies)
|
foreach (var currentMovie in movies)
|
||||||
{
|
{
|
||||||
var resource = DiscoverMoviesResourceMapper.ToResource(currentMovie);
|
var resource = currentMovie.ToResource();
|
||||||
|
_coverMapper.ConvertToLocalUrls(0, resource.Images);
|
||||||
|
|
||||||
var poster = currentMovie.MovieMetadata.Value.Images.FirstOrDefault(c => c.CoverType == MediaCoverTypes.Poster);
|
var poster = currentMovie.MovieMetadata.Value.Images.FirstOrDefault(c => c.CoverType == MediaCoverTypes.Poster);
|
||||||
if (poster != null)
|
if (poster != null)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user