Revert "Added FindByAlternativeTitle in MovieRepo."

It won't work. You have to do it like in FindByTitle. This reverts commit 0d85c7435c.
Devin Buhl 8 years ago committed by Leonardo Galli
parent f3b5d9a1d6
commit 91c71ed6a0

@ -355,11 +355,14 @@ namespace NzbDrone.Core.Parser
private Movie GetMovie(ParsedMovieInfo parsedEpisodeInfo, string imdbId, SearchCriteriaBase searchCriteria) private Movie GetMovie(ParsedMovieInfo parsedEpisodeInfo, string imdbId, SearchCriteriaBase searchCriteria)
{ {
Movie possibleMovie = null;
if (searchCriteria != null) if (searchCriteria != null)
{ {
var possibleTitles = new List<string>(); var possibleTitles = new List<string>();
Movie possibleMovie = null;
possibleTitles.Add(searchCriteria.Movie.CleanTitle); possibleTitles.Add(searchCriteria.Movie.CleanTitle);
foreach (string altTitle in searchCriteria.Movie.AlternativeTitles) foreach (string altTitle in searchCriteria.Movie.AlternativeTitles)
{ {
possibleTitles.Add(altTitle.CleanSeriesTitle()); possibleTitles.Add(altTitle.CleanSeriesTitle());
@ -389,50 +392,49 @@ namespace NzbDrone.Core.Parser
} }
} }
if (possibleMovie != null && (parsedEpisodeInfo.Year < 1800 || possibleMovie.Year == parsedEpisodeInfo.Year)) if (possibleMovie != null && (parsedEpisodeInfo.Year < 1800 || possibleMovie.Year == parsedEpisodeInfo.Year))
{ {
return possibleMovie; return possibleMovie;
} }
} }
else
Movie movie = null;
if (searchCriteria == null)
{ {
// search by title and year
if (parsedEpisodeInfo.Year > 1900) if (parsedEpisodeInfo.Year > 1900)
{ {
possibleMovie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle, parsedEpisodeInfo.Year); movie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle, parsedEpisodeInfo.Year);
} }
else else
{ {
// search by title movie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle);
possibleMovie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle);
} }
// search by title if (movie == null)
if (possibleMovie == null)
{ {
possibleMovie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle); movie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle);
}
// search by alternative titles
if (possibleMovie == null)
{
possibleMovie = _movieService.FindByAlternativeTitle(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 null;
} }
return possibleMovie; return movie;
} }
private Series GetSeries(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria) private Series GetSeries(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria)

@ -13,7 +13,6 @@ namespace NzbDrone.Core.Tv
public interface IMovieRepository : IBasicRepository<Movie> public interface IMovieRepository : IBasicRepository<Movie>
{ {
bool MoviePathExists(string path); bool MoviePathExists(string path);
Movie FindByAlternativeTitle(string cleanTitle);
Movie FindByTitle(string cleanTitle); Movie FindByTitle(string cleanTitle);
Movie FindByTitle(string cleanTitle, int year); Movie FindByTitle(string cleanTitle, int year);
Movie FindByImdbId(string imdbid); Movie FindByImdbId(string imdbid);
@ -62,13 +61,16 @@ namespace NzbDrone.Core.Tv
cleanTitle = cleanTitle.ToLowerInvariant(); cleanTitle = cleanTitle.ToLowerInvariant();
var cleanRoman = cleanTitle; var cleanRoman = cleanTitle;
var cleanNum = cleanTitle; var cleanNum = cleanTitle;
foreach (KeyValuePair<string, string> entry in romanNumeralsMapper) foreach (KeyValuePair<string, string> entry in romanNumeralsMapper)
{ {
string num = entry.Key; string num = entry.Key;
string roman = entry.Value.ToLower(); string roman = entry.Value.ToLower();
cleanRoman = cleanRoman.Replace(num, roman); cleanRoman = cleanRoman.Replace(num, roman);
cleanNum = cleanNum.Replace(roman, num); 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<string, string> 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) public Movie FindByTitle(string cleanTitle, int year)
{ {
cleanTitle = cleanTitle.ToLowerInvariant(); cleanTitle = cleanTitle.ToLowerInvariant();

@ -25,7 +25,6 @@ namespace NzbDrone.Core.Tv
Movie AddMovie(Movie newMovie); Movie AddMovie(Movie newMovie);
List<Movie> AddMovies(List<Movie> newMovies); List<Movie> AddMovies(List<Movie> newMovies);
Movie FindByImdbId(string imdbid); Movie FindByImdbId(string imdbid);
Movie FindByAlternativeTitle(string title);
Movie FindByTitle(string title); Movie FindByTitle(string title);
Movie FindByTitle(string title, int year); Movie FindByTitle(string title, int year);
Movie FindByTitleInexact(string title); Movie FindByTitleInexact(string title);
@ -186,11 +185,6 @@ namespace NzbDrone.Core.Tv
return _movieRepository.FindByTitle(title.CleanSeriesTitle()); return _movieRepository.FindByTitle(title.CleanSeriesTitle());
} }
public Movie FindByAlternativeTitle(string title)
{
return _movieRepository.FindByAlternativeTitle(title.CleanSeriesTitle());
}
public Movie FindByImdbId(string imdbid) public Movie FindByImdbId(string imdbid)
{ {
return _movieRepository.FindByImdbId(imdbid); return _movieRepository.FindByImdbId(imdbid);

Loading…
Cancel
Save