Fixed: Translate Movie Info in Discover View

pull/5043/head
Qstick 4 years ago
parent 9e79e91d39
commit 01f0f9d3bb

@ -41,28 +41,6 @@ namespace NzbDrone.Core.ImportLists.ImportListMovies
return listMovies;
}
//public List<ListMovie> SyncMoviesForList(List<ListMovie> listMovies)
//{
// var existingListMovies = GetAllListMovies();
// var newMovies = listMovies.GroupBy(x => x.TmdbId);
// listMovies = newMovies.Select(x =>
// {
// var movie = x.First();
// movie.ListIds = x.SelectMany(m => m.ListIds).ToList();
// return movie;
// }).ToList();
// listMovies.ForEach(l => l.Id = existingListMovies.FirstOrDefault(e => e.TmdbId == l.TmdbId)?.Id ?? 0);
// _listMovieRepository.InsertMany(listMovies.Where(l => l.Id == 0).ToList());
// _listMovieRepository.UpdateMany(listMovies.Where(l => l.Id > 0).ToList());
// _listMovieRepository.DeleteMany(existingListMovies.Where(l => !listMovies.Any(x => x.TmdbId == l.TmdbId)).ToList());
// return listMovies;
//}
public List<ImportListMovie> SyncMoviesForList(List<ImportListMovie> listMovies, int listId)
{
var existingListMovies = GetAllForList(listId);

@ -1,8 +1,10 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.ImportLists.ImportExclusions;
using NzbDrone.Core.ImportLists.ImportListMovies;
using NzbDrone.Core.Languages;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Movies;
@ -19,12 +21,14 @@ namespace Radarr.Api.V3.ImportLists
private readonly IBuildFileNames _fileNameBuilder;
private readonly IImportListMovieService _listMovieService;
private readonly IImportExclusionsService _importExclusionService;
private readonly IConfigService _configService;
public ImportListMoviesModule(IMovieService movieService,
IProvideMovieInfo movieInfo,
IBuildFileNames fileNameBuilder,
IImportListMovieService listMovieService,
IImportExclusionsService importExclusionsService)
IImportExclusionsService importExclusionsService,
IConfigService configService)
: base("/importlist/movie")
{
_movieService = movieService;
@ -32,12 +36,14 @@ namespace Radarr.Api.V3.ImportLists
_fileNameBuilder = fileNameBuilder;
_listMovieService = listMovieService;
_importExclusionService = importExclusionsService;
_configService = configService;
Get("/", x => GetDiscoverMovies());
}
private object GetDiscoverMovies()
{
var includeRecommendations = Request.GetBooleanQueryParameter("includeRecommendations");
var movieLanguge = (Language)_configService.MovieInfoLanguage;
var realResults = new List<ImportListMoviesResource>();
var listExclusions = _importExclusionService.GetAllExclusions();
@ -54,11 +60,11 @@ namespace Radarr.Api.V3.ImportLists
mapped = _movieInfo.GetBulkMovieInfo(results);
}
realResults.AddRange(MapToResource(mapped.Where(x => x != null)));
realResults.AddRange(MapToResource(mapped.Where(x => x != null), movieLanguge));
realResults.ForEach(x => x.IsRecommendation = true);
}
var listMovies = MapToResource(_listMovieService.GetAllListMovies()).ToList();
var listMovies = MapToResource(_listMovieService.GetAllListMovies(), movieLanguge).ToList();
realResults.AddRange(listMovies);
@ -80,7 +86,7 @@ namespace Radarr.Api.V3.ImportLists
return realResults;
}
private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<Movie> movies)
private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<Movie> movies, Language language)
{
foreach (var currentMovie in movies)
{
@ -91,13 +97,17 @@ namespace Radarr.Api.V3.ImportLists
resource.RemotePoster = poster.Url;
}
var translation = currentMovie.Translations.FirstOrDefault(t => t.Language == language);
resource.Title = translation?.Title ?? resource.Title;
resource.Overview = translation?.Overview ?? resource.Overview;
resource.Folder = _fileNameBuilder.GetMovieFolder(currentMovie);
yield return resource;
}
}
private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<ImportListMovie> movies)
private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<ImportListMovie> movies, Language language)
{
foreach (var currentMovie in movies)
{
@ -108,6 +118,10 @@ namespace Radarr.Api.V3.ImportLists
resource.RemotePoster = poster.Url;
}
var translation = currentMovie.Translations.FirstOrDefault(t => t.Language == language);
resource.Title = translation?.Title ?? resource.Title;
resource.Overview = translation?.Overview ?? resource.Overview;
resource.Folder = _fileNameBuilder.GetMovieFolder(new Movie { Title = currentMovie.Title, Year = currentMovie.Year, ImdbId = currentMovie.ImdbId, TmdbId = currentMovie.TmdbId });
yield return resource;

Loading…
Cancel
Save