mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Added FindByAlternativeTitle in MovieRepo.
This commit is contained in:
parent
f49d68ad6a
commit
0d85c7435c
@ -355,14 +355,11 @@ private ParsedEpisodeInfo ParseSpecialEpisodeTitle(string title, Series series)
|
||||
|
||||
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());
|
||||
@ -392,49 +389,50 @@ private Movie GetMovie(ParsedMovieInfo parsedEpisodeInfo, string imdbId, SearchC
|
||||
}
|
||||
}
|
||||
|
||||
if (possibleMovie != null && (parsedEpisodeInfo.Year < 1800 || possibleMovie.Year == parsedEpisodeInfo.Year))
|
||||
{
|
||||
return possibleMovie;
|
||||
}
|
||||
|
||||
|
||||
if (possibleMovie != null && (parsedEpisodeInfo.Year < 1800 || possibleMovie.Year == parsedEpisodeInfo.Year))
|
||||
{
|
||||
return possibleMovie;
|
||||
}
|
||||
}
|
||||
|
||||
Movie movie = null;
|
||||
|
||||
if (searchCriteria == null)
|
||||
else
|
||||
{
|
||||
// search by title and year
|
||||
if (parsedEpisodeInfo.Year > 1900)
|
||||
{
|
||||
movie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle, parsedEpisodeInfo.Year);
|
||||
|
||||
possibleMovie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle, parsedEpisodeInfo.Year);
|
||||
}
|
||||
else
|
||||
{
|
||||
movie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle);
|
||||
// search by title
|
||||
possibleMovie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle);
|
||||
}
|
||||
|
||||
if (movie == null)
|
||||
// search by title
|
||||
if (possibleMovie == null)
|
||||
{
|
||||
movie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle);
|
||||
possibleMovie = _movieService.FindByTitle(parsedEpisodeInfo.MovieTitle);
|
||||
}
|
||||
|
||||
// search by alternative titles
|
||||
if (possibleMovie == null)
|
||||
{
|
||||
possibleMovie = _movieService.FindByAlternativeTitle(parsedEpisodeInfo.MovieTitle);
|
||||
}
|
||||
return movie;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (movie == null && imdbId.IsNotNullOrWhiteSpace())
|
||||
if (possibleMovie == null && imdbId.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
movie = _movieService.FindByImdbId(imdbId);
|
||||
possibleMovie = _movieService.FindByImdbId(imdbId);
|
||||
}
|
||||
|
||||
if (movie == null)
|
||||
if (possibleMovie == null)
|
||||
{
|
||||
_logger.Debug("No matching movie {0}", parsedEpisodeInfo.MovieTitle);
|
||||
_logger.Error($"Unable to match movie {parsedEpisodeInfo.MovieTitle}, try adding a alternative title to themoviedb.org for this movie.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return movie;
|
||||
return possibleMovie;
|
||||
}
|
||||
|
||||
private Series GetSeries(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria)
|
||||
|
@ -13,6 +13,7 @@ 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);
|
||||
@ -61,16 +62,13 @@ public Movie FindByTitle(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);
|
||||
}
|
||||
|
||||
@ -102,6 +100,33 @@ public Movie FindByTitle(string cleanTitle)
|
||||
}
|
||||
}
|
||||
|
||||
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,6 +25,7 @@ public interface IMovieService
|
||||
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);
|
||||
@ -185,6 +186,11 @@ public Movie FindByTitle(string title)
|
||||
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…
Reference in New Issue
Block a user