diff --git a/src/NzbDrone.Core/ImportLists/ImportListMovies/ImportListMovieService.cs b/src/NzbDrone.Core/ImportLists/ImportListMovies/ImportListMovieService.cs index 833c379bb..0cc7c5b38 100644 --- a/src/NzbDrone.Core/ImportLists/ImportListMovies/ImportListMovieService.cs +++ b/src/NzbDrone.Core/ImportLists/ImportListMovies/ImportListMovieService.cs @@ -41,28 +41,6 @@ public List AddListMovies(List listMovies) return listMovies; } - //public List SyncMoviesForList(List 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 SyncMoviesForList(List listMovies, int listId) { var existingListMovies = GetAllForList(listId); diff --git a/src/Radarr.Api.V3/ImportLists/ImportListMoviesModule.cs b/src/Radarr.Api.V3/ImportLists/ImportListMoviesModule.cs index 8fbb70d7a..602faf89b 100644 --- a/src/Radarr.Api.V3/ImportLists/ImportListMoviesModule.cs +++ b/src/Radarr.Api.V3/ImportLists/ImportListMoviesModule.cs @@ -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 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(); 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 MapToResource(IEnumerable movies) + private IEnumerable MapToResource(IEnumerable movies, Language language) { foreach (var currentMovie in movies) { @@ -91,13 +97,17 @@ private IEnumerable MapToResource(IEnumerable 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 MapToResource(IEnumerable movies) + private IEnumerable MapToResource(IEnumerable movies, Language language) { foreach (var currentMovie in movies) { @@ -108,6 +118,10 @@ private IEnumerable MapToResource(IEnumerable 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;