1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00

Fixed: Remove redundant checks from list sync

This commit is contained in:
Qstick 2019-07-05 22:59:38 -04:00
parent 12fba024f0
commit 2d15b8b78a

View File

@ -125,12 +125,6 @@ public void Execute(NetImportSyncCommand message)
CleanLibrary(listedMovies);
}
listedMovies = listedMovies.Where(x => !_movieService.MovieExists(x)).ToList();
if (listedMovies.Any())
{
_logger.Info($"Found {listedMovies.Count()} movies on your auto enabled lists not in your library");
}
var importExclusions = new List<string>();
var moviesToAdd = new List<Movie>();
@ -138,25 +132,32 @@ public void Execute(NetImportSyncCommand message)
{
var mapped = _movieSearch.MapMovieToTmdbMovie(movie);
if (mapped == null)
if (mapped != null && mapped.TmdbId > 0)
{
_logger.Debug($"{movie.Title} could not be mapped to a valid tmdb ID, will not be added from list");
}
else if (_exclusionService.IsMovieExcluded(mapped.TmdbId))
{
_logger.Debug($"{mapped.Title} ({mapped.TitleSlug}) will not be added since it was found on the exclusions list");
}
else if (_movieService.MovieExists(mapped))
{
_logger.Debug($"{mapped.Title} ({mapped.TitleSlug}) will not be added since it exists in DB");
}
else
{
mapped.AddOptions = new AddMovieOptions { SearchForMovie = true };
moviesToAdd.Add(mapped);
if (_exclusionService.IsMovieExcluded(mapped.TmdbId))
{
_logger.Debug($"{mapped.Title} ({mapped.TitleSlug}) will not be added since it was found on the exclusions list");
}
else if (_movieService.MovieExists(mapped))
{
_logger.Trace($"{mapped.Title} ({mapped.TitleSlug}) will not be added since it exists in Library");
}
else
{
if (!moviesToAdd.Any(c => c.TmdbId == mapped.TmdbId))
{
mapped.AddOptions = new AddMovieOptions { SearchForMovie = true };
moviesToAdd.Add(mapped);
}
}
}
}
if (moviesToAdd.Any())
{
_logger.Info($"Adding {moviesToAdd.Count()} movies from your auto enabled lists to library");
}
_movieService.AddMovies(moviesToAdd);
}