diff --git a/src/NzbDrone.Core/Parser/ParsingService.cs b/src/NzbDrone.Core/Parser/ParsingService.cs index 205f1bfe8..7ad4d8afd 100644 --- a/src/NzbDrone.Core/Parser/ParsingService.cs +++ b/src/NzbDrone.Core/Parser/ParsingService.cs @@ -355,11 +355,14 @@ namespace NzbDrone.Core.Parser private Movie GetMovie(ParsedMovieInfo parsedEpisodeInfo, string imdbId, SearchCriteriaBase searchCriteria) { - Movie possibleMovie = null; if (searchCriteria != null) { var possibleTitles = new List(); + + Movie possibleMovie = null; + possibleTitles.Add(searchCriteria.Movie.CleanTitle); + foreach (string altTitle in searchCriteria.Movie.AlternativeTitles) { possibleTitles.Add(altTitle.CleanSeriesTitle()); @@ -389,50 +392,49 @@ namespace NzbDrone.Core.Parser } } - if (possibleMovie != null && (parsedEpisodeInfo.Year < 1800 || possibleMovie.Year == parsedEpisodeInfo.Year)) - { - return possibleMovie; - } + if (possibleMovie != null && (parsedEpisodeInfo.Year < 1800 || possibleMovie.Year == parsedEpisodeInfo.Year)) + { + return possibleMovie; + } + + } - else + + Movie movie = null; + + if (searchCriteria == null) { - // search by title and year if (parsedEpisodeInfo.Year > 1900) { - possibleMovie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle, parsedEpisodeInfo.Year); + movie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle, parsedEpisodeInfo.Year); + } else { - // search by title - possibleMovie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle); + movie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle); } - // search by title - if (possibleMovie == null) + if (movie == null) { - possibleMovie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle); - } - - // search by alternative titles - if (possibleMovie == null) - { - possibleMovie = _movieService.FindByAlternativeTitle(parsedEpisodeInfo.MovieTitle); + movie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle); } + return movie; } - if (possibleMovie == null && imdbId.IsNotNullOrWhiteSpace()) + + if (movie == null && imdbId.IsNotNullOrWhiteSpace()) { - possibleMovie = _movieService.FindByImdbId(imdbId); + movie = _movieService.FindByImdbId(imdbId); } - if (possibleMovie == null) + if (movie == null) { - _logger.Error($"Unable to match movie {parsedEpisodeInfo.MovieTitle}, try adding a alternative title to themoviedb.org for this movie."); + _logger.Debug("No matching movie {0}", parsedEpisodeInfo.MovieTitle); return null; } - return possibleMovie; + return movie; } private Series GetSeries(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria) diff --git a/src/NzbDrone.Core/Tv/MovieRepository.cs b/src/NzbDrone.Core/Tv/MovieRepository.cs index 03c234610..816b6f35d 100644 --- a/src/NzbDrone.Core/Tv/MovieRepository.cs +++ b/src/NzbDrone.Core/Tv/MovieRepository.cs @@ -13,7 +13,6 @@ namespace NzbDrone.Core.Tv public interface IMovieRepository : IBasicRepository { bool MoviePathExists(string path); - Movie FindByAlternativeTitle(string cleanTitle); Movie FindByTitle(string cleanTitle); Movie FindByTitle(string cleanTitle, int year); Movie FindByImdbId(string imdbid); @@ -62,13 +61,16 @@ namespace NzbDrone.Core.Tv cleanTitle = cleanTitle.ToLowerInvariant(); var cleanRoman = cleanTitle; + var cleanNum = cleanTitle; foreach (KeyValuePair entry in romanNumeralsMapper) { string num = entry.Key; string roman = entry.Value.ToLower(); + cleanRoman = cleanRoman.Replace(num, roman); + cleanNum = cleanNum.Replace(roman, num); } @@ -100,33 +102,6 @@ namespace NzbDrone.Core.Tv } } - public Movie FindByAlternativeTitle(string cleanTitle) - { - cleanTitle = cleanTitle.ToLowerInvariant(); - - var cleanRoman = cleanTitle; - - var cleanNum = cleanTitle; - - foreach (KeyValuePair entry in romanNumeralsMapper) - { - string num = entry.Key; - string roman = entry.Value.ToLower(); - - cleanRoman = cleanRoman.Replace(num, roman); - - cleanNum = cleanNum.Replace(roman, num); - } - - var result = Query.Where(m => m.AlternativeTitles.Any(t => - Parser.Parser.CleanSeriesTitle(t.ToLower()) == cleanTitle || - Parser.Parser.CleanSeriesTitle(t.ToLower()) == cleanRoman || - Parser.Parser.CleanSeriesTitle(t.ToLower()) == cleanNum)) - .FirstOrDefault(); - - return result; - } - public Movie FindByTitle(string cleanTitle, int year) { cleanTitle = cleanTitle.ToLowerInvariant(); diff --git a/src/NzbDrone.Core/Tv/MovieService.cs b/src/NzbDrone.Core/Tv/MovieService.cs index 85904bdcc..d535a1dc4 100644 --- a/src/NzbDrone.Core/Tv/MovieService.cs +++ b/src/NzbDrone.Core/Tv/MovieService.cs @@ -25,7 +25,6 @@ namespace NzbDrone.Core.Tv Movie AddMovie(Movie newMovie); List AddMovies(List newMovies); Movie FindByImdbId(string imdbid); - Movie FindByAlternativeTitle(string title); Movie FindByTitle(string title); Movie FindByTitle(string title, int year); Movie FindByTitleInexact(string title); @@ -186,11 +185,6 @@ namespace NzbDrone.Core.Tv return _movieRepository.FindByTitle(title.CleanSeriesTitle()); } - public Movie FindByAlternativeTitle(string title) - { - return _movieRepository.FindByAlternativeTitle(title.CleanSeriesTitle()); - } - public Movie FindByImdbId(string imdbid) { return _movieRepository.FindByImdbId(imdbid);