|
|
|
@ -2,10 +2,13 @@ using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
|
|
|
|
using NzbDrone.Core.Languages;
|
|
|
|
|
using NzbDrone.Core.Messaging.Commands;
|
|
|
|
|
using NzbDrone.Core.Movies;
|
|
|
|
|
using NzbDrone.Core.Movies.Commands;
|
|
|
|
|
using NzbDrone.Core.Movies.Translations;
|
|
|
|
|
using Radarr.Http;
|
|
|
|
|
|
|
|
|
|
namespace Radarr.Api.V3.Movies
|
|
|
|
@ -14,12 +17,20 @@ namespace Radarr.Api.V3.Movies
|
|
|
|
|
public class MovieEditorController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly IMovieService _movieService;
|
|
|
|
|
private readonly IMovieTranslationService _movieTranslationService;
|
|
|
|
|
private readonly IConfigService _configService;
|
|
|
|
|
private readonly IManageCommandQueue _commandQueueManager;
|
|
|
|
|
private readonly IUpgradableSpecification _upgradableSpecification;
|
|
|
|
|
|
|
|
|
|
public MovieEditorController(IMovieService movieService, IManageCommandQueue commandQueueManager, IUpgradableSpecification upgradableSpecification)
|
|
|
|
|
public MovieEditorController(IMovieService movieService,
|
|
|
|
|
IMovieTranslationService movieTranslationService,
|
|
|
|
|
IConfigService configService,
|
|
|
|
|
IManageCommandQueue commandQueueManager,
|
|
|
|
|
IUpgradableSpecification upgradableSpecification)
|
|
|
|
|
{
|
|
|
|
|
_movieService = movieService;
|
|
|
|
|
_movieTranslationService = movieTranslationService;
|
|
|
|
|
_configService = configService;
|
|
|
|
|
_commandQueueManager = commandQueueManager;
|
|
|
|
|
_upgradableSpecification = upgradableSpecification;
|
|
|
|
|
}
|
|
|
|
@ -86,7 +97,23 @@ namespace Radarr.Api.V3.Movies
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Accepted(_movieService.UpdateMovie(moviesToUpdate, !resource.MoveFiles).ToResource(0, _upgradableSpecification));
|
|
|
|
|
var configLanguage = (Language)_configService.MovieInfoLanguage;
|
|
|
|
|
var availabilityDelay = _configService.AvailabilityDelay;
|
|
|
|
|
|
|
|
|
|
var translations = _movieTranslationService.GetAllTranslationsForLanguage(configLanguage);
|
|
|
|
|
var tdict = translations.ToDictionary(x => x.MovieMetadataId);
|
|
|
|
|
|
|
|
|
|
var updatedMovies = _movieService.UpdateMovie(moviesToUpdate, !resource.MoveFiles);
|
|
|
|
|
|
|
|
|
|
var moviesResources = new List<MovieResource>(updatedMovies.Count);
|
|
|
|
|
|
|
|
|
|
foreach (var movie in updatedMovies)
|
|
|
|
|
{
|
|
|
|
|
var translation = GetTranslationFromDict(tdict, movie.MovieMetadata, configLanguage);
|
|
|
|
|
moviesResources.Add(movie.ToResource(availabilityDelay, translation, _upgradableSpecification));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Accepted(moviesResources);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpDelete]
|
|
|
|
@ -96,5 +123,28 @@ namespace Radarr.Api.V3.Movies
|
|
|
|
|
|
|
|
|
|
return new { };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MovieTranslation GetTranslationFromDict(Dictionary<int, MovieTranslation> translations, MovieMetadata movie, Language configLanguage)
|
|
|
|
|
{
|
|
|
|
|
if (configLanguage == Language.Original)
|
|
|
|
|
{
|
|
|
|
|
return new MovieTranslation
|
|
|
|
|
{
|
|
|
|
|
Title = movie.OriginalTitle,
|
|
|
|
|
Overview = movie.Overview
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!translations.TryGetValue(movie.Id, out var translation))
|
|
|
|
|
{
|
|
|
|
|
translation = new MovieTranslation
|
|
|
|
|
{
|
|
|
|
|
Title = movie.Title,
|
|
|
|
|
Language = Language.English
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return translation;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|