From 32a2407ad1fd54a58390cd12047c20f04587bf83 Mon Sep 17 00:00:00 2001 From: Leonardo Galli Date: Sat, 15 Apr 2017 14:50:34 +0200 Subject: [PATCH] Fixed an issue where movies which were labelled with an alternative title could not be found. Fixes #557 Fixes #1387 Probably fixes #1372, probably fixes #555 --- src/NzbDrone.Core/Download/CompletedDownloadService.cs | 9 ++++++++- src/NzbDrone.Core/Parser/ParsingService.cs | 2 +- src/NzbDrone.Core/Tv/MovieRepository.cs | 6 +++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Core/Download/CompletedDownloadService.cs b/src/NzbDrone.Core/Download/CompletedDownloadService.cs index 6e9695ec3..291f413a7 100644 --- a/src/NzbDrone.Core/Download/CompletedDownloadService.cs +++ b/src/NzbDrone.Core/Download/CompletedDownloadService.cs @@ -129,7 +129,14 @@ namespace NzbDrone.Core.Download { var statusMessages = importResults .Where(v => v.Result != ImportResultType.Imported) - .Select(v => new TrackedDownloadStatusMessage(Path.GetFileName(v.ImportDecision.LocalMovie.Path), v.Errors)) + .Select(v => + { + if (v.ImportDecision.LocalMovie == null) + { + return new TrackedDownloadStatusMessage("", v.Errors); + } + return new TrackedDownloadStatusMessage(Path.GetFileName(v.ImportDecision.LocalMovie.Path), v.Errors); + }) .ToArray(); trackedDownload.Warn(statusMessages); diff --git a/src/NzbDrone.Core/Parser/ParsingService.cs b/src/NzbDrone.Core/Parser/ParsingService.cs index 1090e9895..a9cf88e33 100644 --- a/src/NzbDrone.Core/Parser/ParsingService.cs +++ b/src/NzbDrone.Core/Parser/ParsingService.cs @@ -178,7 +178,7 @@ namespace NzbDrone.Core.Parser return _movieService.FindByTitle(title); } - var movies = _movieService.FindByTitle(parsedMovieInfo.MovieTitle); + var movies = _movieService.FindByTitle(parsedMovieInfo.MovieTitle, parsedMovieInfo.Year); if (movies == null) { diff --git a/src/NzbDrone.Core/Tv/MovieRepository.cs b/src/NzbDrone.Core/Tv/MovieRepository.cs index aa500de88..e963461a3 100644 --- a/src/NzbDrone.Core/Tv/MovieRepository.cs +++ b/src/NzbDrone.Core/Tv/MovieRepository.cs @@ -240,18 +240,18 @@ namespace NzbDrone.Core.Tv IEnumerable results = Query.Where(s => s.CleanTitle == cleanTitle); - if (results == null) + if (results == null || results.Count() == 0) { results = Query.Where(movie => movie.CleanTitle == cleanTitleWithArabicNumbers) ?? Query.Where(movie => movie.CleanTitle == cleanTitleWithRomanNumbers); - if (results == null) + if (results == null || results.Count() == 0) { IEnumerable movies = All(); Func titleCleaner = title => CoreParser.CleanSeriesTitle(title.ToLower()); Func, string, bool> altTitleComparer = (alternativeTitles, atitle) => - alternativeTitles.Any(altTitle => altTitle == titleCleaner(atitle)); + alternativeTitles.Any(altTitle => titleCleaner(altTitle) == atitle); results = movies.Where(m => altTitleComparer(m.AlternativeTitles, cleanTitle) || altTitleComparer(m.AlternativeTitles, cleanTitleWithRomanNumbers) ||