1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Fixed: Translate Movie Info in Discover View

This commit is contained in:
Qstick 2020-09-19 23:01:02 -04:00
parent 9e79e91d39
commit 01f0f9d3bb
2 changed files with 19 additions and 27 deletions

View File

@ -41,28 +41,6 @@ public List<ImportListMovie> AddListMovies(List<ImportListMovie> listMovies)
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);

View File

@ -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 @@ public class ImportListMoviesModule : RadarrRestModule<ImportListMoviesResource>
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 @@ public ImportListMoviesModule(IMovieService movieService,
_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 @@ private object GetDiscoverMovies()
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 @@ private object GetDiscoverMovies()
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 @@ private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<Movie> m
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 @@ private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<ImportLi
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;