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:
parent
9e79e91d39
commit
01f0f9d3bb
@ -41,28 +41,6 @@ public List<ImportListMovie> AddListMovies(List<ImportListMovie> listMovies)
|
|||||||
return 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)
|
public List<ImportListMovie> SyncMoviesForList(List<ImportListMovie> listMovies, int listId)
|
||||||
{
|
{
|
||||||
var existingListMovies = GetAllForList(listId);
|
var existingListMovies = GetAllForList(listId);
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.ImportLists.ImportExclusions;
|
using NzbDrone.Core.ImportLists.ImportExclusions;
|
||||||
using NzbDrone.Core.ImportLists.ImportListMovies;
|
using NzbDrone.Core.ImportLists.ImportListMovies;
|
||||||
|
using NzbDrone.Core.Languages;
|
||||||
using NzbDrone.Core.MediaCover;
|
using NzbDrone.Core.MediaCover;
|
||||||
using NzbDrone.Core.MetadataSource;
|
using NzbDrone.Core.MetadataSource;
|
||||||
using NzbDrone.Core.Movies;
|
using NzbDrone.Core.Movies;
|
||||||
@ -19,12 +21,14 @@ public class ImportListMoviesModule : RadarrRestModule<ImportListMoviesResource>
|
|||||||
private readonly IBuildFileNames _fileNameBuilder;
|
private readonly IBuildFileNames _fileNameBuilder;
|
||||||
private readonly IImportListMovieService _listMovieService;
|
private readonly IImportListMovieService _listMovieService;
|
||||||
private readonly IImportExclusionsService _importExclusionService;
|
private readonly IImportExclusionsService _importExclusionService;
|
||||||
|
private readonly IConfigService _configService;
|
||||||
|
|
||||||
public ImportListMoviesModule(IMovieService movieService,
|
public ImportListMoviesModule(IMovieService movieService,
|
||||||
IProvideMovieInfo movieInfo,
|
IProvideMovieInfo movieInfo,
|
||||||
IBuildFileNames fileNameBuilder,
|
IBuildFileNames fileNameBuilder,
|
||||||
IImportListMovieService listMovieService,
|
IImportListMovieService listMovieService,
|
||||||
IImportExclusionsService importExclusionsService)
|
IImportExclusionsService importExclusionsService,
|
||||||
|
IConfigService configService)
|
||||||
: base("/importlist/movie")
|
: base("/importlist/movie")
|
||||||
{
|
{
|
||||||
_movieService = movieService;
|
_movieService = movieService;
|
||||||
@ -32,12 +36,14 @@ public ImportListMoviesModule(IMovieService movieService,
|
|||||||
_fileNameBuilder = fileNameBuilder;
|
_fileNameBuilder = fileNameBuilder;
|
||||||
_listMovieService = listMovieService;
|
_listMovieService = listMovieService;
|
||||||
_importExclusionService = importExclusionsService;
|
_importExclusionService = importExclusionsService;
|
||||||
|
_configService = configService;
|
||||||
Get("/", x => GetDiscoverMovies());
|
Get("/", x => GetDiscoverMovies());
|
||||||
}
|
}
|
||||||
|
|
||||||
private object GetDiscoverMovies()
|
private object GetDiscoverMovies()
|
||||||
{
|
{
|
||||||
var includeRecommendations = Request.GetBooleanQueryParameter("includeRecommendations");
|
var includeRecommendations = Request.GetBooleanQueryParameter("includeRecommendations");
|
||||||
|
var movieLanguge = (Language)_configService.MovieInfoLanguage;
|
||||||
|
|
||||||
var realResults = new List<ImportListMoviesResource>();
|
var realResults = new List<ImportListMoviesResource>();
|
||||||
var listExclusions = _importExclusionService.GetAllExclusions();
|
var listExclusions = _importExclusionService.GetAllExclusions();
|
||||||
@ -54,11 +60,11 @@ private object GetDiscoverMovies()
|
|||||||
mapped = _movieInfo.GetBulkMovieInfo(results);
|
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);
|
realResults.ForEach(x => x.IsRecommendation = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var listMovies = MapToResource(_listMovieService.GetAllListMovies()).ToList();
|
var listMovies = MapToResource(_listMovieService.GetAllListMovies(), movieLanguge).ToList();
|
||||||
|
|
||||||
realResults.AddRange(listMovies);
|
realResults.AddRange(listMovies);
|
||||||
|
|
||||||
@ -80,7 +86,7 @@ private object GetDiscoverMovies()
|
|||||||
return realResults;
|
return realResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<Movie> movies)
|
private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<Movie> movies, Language language)
|
||||||
{
|
{
|
||||||
foreach (var currentMovie in movies)
|
foreach (var currentMovie in movies)
|
||||||
{
|
{
|
||||||
@ -91,13 +97,17 @@ private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<Movie> m
|
|||||||
resource.RemotePoster = poster.Url;
|
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);
|
resource.Folder = _fileNameBuilder.GetMovieFolder(currentMovie);
|
||||||
|
|
||||||
yield return resource;
|
yield return resource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<ImportListMovie> movies)
|
private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<ImportListMovie> movies, Language language)
|
||||||
{
|
{
|
||||||
foreach (var currentMovie in movies)
|
foreach (var currentMovie in movies)
|
||||||
{
|
{
|
||||||
@ -108,6 +118,10 @@ private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<ImportLi
|
|||||||
resource.RemotePoster = poster.Url;
|
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 });
|
resource.Folder = _fileNameBuilder.GetMovieFolder(new Movie { Title = currentMovie.Title, Year = currentMovie.Year, ImdbId = currentMovie.ImdbId, TmdbId = currentMovie.TmdbId });
|
||||||
|
|
||||||
yield return resource;
|
yield return resource;
|
||||||
|
Loading…
Reference in New Issue
Block a user