From 2d15b8b78a04cdbf4bbd165f29ab5088f5e3efc8 Mon Sep 17 00:00:00 2001 From: Qstick Date: Fri, 5 Jul 2019 22:59:38 -0400 Subject: [PATCH] Fixed: Remove redundant checks from list sync --- .../NetImport/NetImportSearchService.cs | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/NzbDrone.Core/NetImport/NetImportSearchService.cs b/src/NzbDrone.Core/NetImport/NetImportSearchService.cs index ce7ac9dca..2616e4a33 100644 --- a/src/NzbDrone.Core/NetImport/NetImportSearchService.cs +++ b/src/NzbDrone.Core/NetImport/NetImportSearchService.cs @@ -125,12 +125,6 @@ namespace NzbDrone.Core.NetImport 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(); var moviesToAdd = new List(); @@ -138,25 +132,32 @@ namespace NzbDrone.Core.NetImport { var mapped = _movieSearch.MapMovieToTmdbMovie(movie); - if (mapped == null) - { - _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)) + if (mapped != null && mapped.TmdbId > 0) { - _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); }