|
|
|
@ -1,9 +1,11 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using FluentValidation;
|
|
|
|
|
using Nancy;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
|
using NzbDrone.Core.Datastore.Events;
|
|
|
|
@ -42,6 +44,7 @@ namespace Radarr.Api.V3.Movies
|
|
|
|
|
private readonly IManageCommandQueue _commandQueueManager;
|
|
|
|
|
private readonly IUpgradableSpecification _qualityUpgradableSpecification;
|
|
|
|
|
private readonly IConfigService _configService;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
public MovieModule(IBroadcastSignalRMessage signalRBroadcaster,
|
|
|
|
|
IMovieService moviesService,
|
|
|
|
@ -59,7 +62,8 @@ namespace Radarr.Api.V3.Movies
|
|
|
|
|
RecycleBinValidator recycleBinValidator,
|
|
|
|
|
SystemFolderValidator systemFolderValidator,
|
|
|
|
|
ProfileExistsValidator profileExistsValidator,
|
|
|
|
|
MovieFolderAsRootFolderValidator movieFolderAsRootFolderValidator)
|
|
|
|
|
MovieFolderAsRootFolderValidator movieFolderAsRootFolderValidator,
|
|
|
|
|
Logger logger)
|
|
|
|
|
: base(signalRBroadcaster)
|
|
|
|
|
{
|
|
|
|
|
_moviesService = moviesService;
|
|
|
|
@ -69,6 +73,7 @@ namespace Radarr.Api.V3.Movies
|
|
|
|
|
_configService = configService;
|
|
|
|
|
_coverMapper = coverMapper;
|
|
|
|
|
_commandQueueManager = commandQueueManager;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
|
|
|
|
|
GetResourceAll = AllMovie;
|
|
|
|
|
GetResourceById = GetMovie;
|
|
|
|
@ -122,11 +127,13 @@ namespace Radarr.Api.V3.Movies
|
|
|
|
|
{
|
|
|
|
|
var configLanguage = (Language)_configService.MovieInfoLanguage;
|
|
|
|
|
var availDelay = _configService.AvailabilityDelay;
|
|
|
|
|
|
|
|
|
|
var movieTask = Task.Run(() => _moviesService.GetAllMovies());
|
|
|
|
|
|
|
|
|
|
var translations = _movieTranslationService
|
|
|
|
|
.GetAllTranslationsForLanguage(configLanguage)
|
|
|
|
|
.ToDictionary(x => x.MovieId);
|
|
|
|
|
.GetAllTranslationsForLanguage(configLanguage);
|
|
|
|
|
|
|
|
|
|
var tdict = translations.ToDictionary(x => x.MovieId);
|
|
|
|
|
|
|
|
|
|
coverFileInfos = _coverMapper.GetCoverFileInfos();
|
|
|
|
|
|
|
|
|
@ -136,13 +143,13 @@ namespace Radarr.Api.V3.Movies
|
|
|
|
|
|
|
|
|
|
foreach (var movie in movies)
|
|
|
|
|
{
|
|
|
|
|
var translation = GetTranslationFromDict(translations, movie, configLanguage);
|
|
|
|
|
var resource = movie.ToResource(availDelay, translation, _qualityUpgradableSpecification);
|
|
|
|
|
_coverMapper.ConvertToLocalUrls(resource.Id, resource.Images, coverFileInfos);
|
|
|
|
|
moviesResources.Add(resource);
|
|
|
|
|
var translation = GetTranslationFromDict(tdict, movie, configLanguage);
|
|
|
|
|
moviesResources.Add(movie.ToResource(availDelay, translation, _qualityUpgradableSpecification));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MapCoversToLocal(moviesResources, coverFileInfos);
|
|
|
|
|
|
|
|
|
|
return moviesResources;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -249,6 +256,11 @@ namespace Radarr.Api.V3.Movies
|
|
|
|
|
_coverMapper.ConvertToLocalUrls(movie.Id, movie.Images);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MapCoversToLocal(IEnumerable<MovieResource> movies, Dictionary<string, FileInfo> coverFileInfos)
|
|
|
|
|
{
|
|
|
|
|
_coverMapper.ConvertToLocalUrls(movies.Select(x => Tuple.Create(x.Id, x.Images.AsEnumerable())), coverFileInfos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Handle(MovieImportedEvent message)
|
|
|
|
|
{
|
|
|
|
|
var availDelay = _configService.AvailabilityDelay;
|
|
|
|
|