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)
{
Movie possibleMovie = null;
if (searchCriteria != null)
{
var possibleTitles = new List<string>();
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)

@ -13,7 +13,6 @@ namespace NzbDrone.Core.Tv
public interface IMovieRepository : IBasicRepository<Movie>
{
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<string, string> 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<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)
{
cleanTitle = cleanTitle.ToLowerInvariant();

@ -25,7 +25,6 @@ namespace NzbDrone.Core.Tv
Movie AddMovie(Movie newMovie);
List<Movie> AddMovies(List<Movie> 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);

Loading…
Cancel
Save