Move up IMDB logic in ParsingService, should help with the mismatched movies

pull/2/head
Devin Buhl 8 years ago
parent 31fcac5bd9
commit 066c746e5f

@ -354,12 +354,17 @@ namespace NzbDrone.Core.Parser
private Movie GetMovie(ParsedMovieInfo parsedMovieInfo, string imdbId, SearchCriteriaBase searchCriteria)
{
if (searchCriteria != null)
// IMDbID is present, movie this logic up
if (imdbId.IsNotNullOrWhiteSpace())
{
var possibleTitles = new List<string>();
return _movieService.FindByImdbId(imdbId);
}
Movie possibleMovie = null;
Movie possibleMovie = null;
if (searchCriteria != null)
{
var possibleTitles = new List<string>();
possibleTitles.Add(searchCriteria.Movie.CleanTitle);
foreach (string altTitle in searchCriteria.Movie.AlternativeTitles)
@ -391,48 +396,35 @@ namespace NzbDrone.Core.Parser
}
}
if (possibleMovie != null && (parsedMovieInfo.Year < 1800 || possibleMovie.Year == parsedMovieInfo.Year))
{
return possibleMovie;
}
if (possibleMovie != null && (parsedMovieInfo.Year < 1900 || possibleMovie.Year == parsedMovieInfo.Year))
{
return possibleMovie;
}
}
Movie movie = null;
if (searchCriteria == null)
else
{
if (parsedMovieInfo.Year > 1900)
{
movie = _movieService.FindByTitle(parsedMovieInfo.MovieTitle, parsedMovieInfo.Year);
possibleMovie = _movieService.FindByTitle(parsedMovieInfo.MovieTitle, parsedMovieInfo.Year);
}
else
{
movie = _movieService.FindByTitle(parsedMovieInfo.MovieTitle);
possibleMovie = _movieService.FindByTitle(parsedMovieInfo.MovieTitle);
}
if (movie == null)
if (possibleMovie == null)
{
movie = _movieService.FindByTitle(parsedMovieInfo.MovieTitle);
possibleMovie = _movieService.FindByTitle(parsedMovieInfo.MovieTitle);
}
// return movie;
}
if (movie == null && imdbId.IsNotNullOrWhiteSpace())
{
movie = _movieService.FindByImdbId(imdbId);
}
if (movie == null)
if (possibleMovie == null)
{
_logger.Debug($"No matching movie {parsedMovieInfo.MovieTitle}");
return null;
}
return movie;
return possibleMovie;
}
private Series GetSeries(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria)

Loading…
Cancel
Save