mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 20:12:41 +02:00
parent
9cb3ff238b
commit
e3fb000226
@ -8,6 +8,7 @@
|
||||
using NzbDrone.Core.Languages;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Movies.AlternativeTitles;
|
||||
using NzbDrone.Core.Movies.Translations;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
@ -23,6 +24,7 @@ public class MapFixture : TestBase<ParsingService>
|
||||
private ParsedMovieInfo _wrongTitleInfo;
|
||||
private ParsedMovieInfo _romanTitleInfo;
|
||||
private ParsedMovieInfo _alternativeTitleInfo;
|
||||
private ParsedMovieInfo _translationTitleInfo;
|
||||
private ParsedMovieInfo _umlautInfo;
|
||||
private ParsedMovieInfo _umlautAltInfo;
|
||||
private MovieSearchCriteria _movieSearchCriteria;
|
||||
@ -35,6 +37,7 @@ public void Setup()
|
||||
.With(m => m.CleanTitle = "fackjugoethe2")
|
||||
.With(m => m.Year = 2015)
|
||||
.With(m => m.AlternativeTitles = new List<AlternativeTitle> { new AlternativeTitle("Fack Ju Göthe 2: Same same") })
|
||||
.With(m => m.Translations = new List<MovieTranslation> { new MovieTranslation { Title = "Translated Title", CleanTitle = "translatedtitle" } })
|
||||
.With(m => m.OriginalLanguage = Language.English)
|
||||
.Build();
|
||||
|
||||
@ -66,6 +69,13 @@ public void Setup()
|
||||
Year = _movie.Year,
|
||||
};
|
||||
|
||||
_translationTitleInfo = new ParsedMovieInfo
|
||||
{
|
||||
MovieTitle = _movie.Translations.First().Title,
|
||||
Languages = new List<Language> { Language.English },
|
||||
Year = _movie.Year,
|
||||
};
|
||||
|
||||
_romanTitleInfo = new ParsedMovieInfo
|
||||
{
|
||||
MovieTitle = "Fack Ju Göthe II",
|
||||
@ -152,6 +162,12 @@ public void should_match_alternative_title()
|
||||
Subject.Map(_alternativeTitleInfo, "", _movieSearchCriteria).Movie.Should().Be(_movieSearchCriteria.Movie);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_match_translation_title()
|
||||
{
|
||||
Subject.Map(_translationTitleInfo, "", _movieSearchCriteria).Movie.Should().Be(_movieSearchCriteria.Movie);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_match_roman_title()
|
||||
{
|
||||
|
@ -49,6 +49,7 @@ public NzbSearchService(IIndexerFactory indexerFactory,
|
||||
public List<DownloadDecision> MovieSearch(int movieId, bool userInvokedSearch, bool interactiveSearch)
|
||||
{
|
||||
var movie = _movieService.GetMovie(movieId);
|
||||
movie.Translations = _movieTranslationService.GetAllTranslationsForMovie(movie.Id);
|
||||
|
||||
return MovieSearch(movie, userInvokedSearch, interactiveSearch);
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Languages;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Movies.AlternativeTitles;
|
||||
using NzbDrone.Core.Parser.Augmenters;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Parser.RomanNumerals;
|
||||
@ -148,8 +147,8 @@ public MappingResult Map(ParsedMovieInfo parsedMovieInfo, string imdbId, SearchC
|
||||
|
||||
private MappingResult GetMovie(ParsedMovieInfo parsedMovieInfo, string imdbId, SearchCriteriaBase searchCriteria)
|
||||
{
|
||||
// TODO: Answer me this: Wouldn't it be smarter to start out looking for a movie if we have an ImDb Id?
|
||||
MappingResult result = null;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(imdbId) && imdbId != "0")
|
||||
{
|
||||
if (TryGetMovieByImDbId(parsedMovieInfo, imdbId, out result))
|
||||
@ -167,9 +166,11 @@ private MappingResult GetMovie(ParsedMovieInfo parsedMovieInfo, string imdbId, S
|
||||
}
|
||||
else
|
||||
{
|
||||
TryGetMovieByTitleAndOrYear(parsedMovieInfo, out result);
|
||||
if (TryGetMovieByTitleAndOrYear(parsedMovieInfo, out result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// nothing found up to here => logging that and returning null
|
||||
_logger.Debug($"No matching movie {parsedMovieInfo.MovieTitle}");
|
||||
@ -202,7 +203,7 @@ private bool TryGetMovieByImDbId(ParsedMovieInfo parsedMovieInfo, string imdbId,
|
||||
private bool TryGetMovieByTitleAndOrYear(ParsedMovieInfo parsedMovieInfo, out MappingResult result)
|
||||
{
|
||||
Func<Movie, bool> isNotNull = movie => movie != null;
|
||||
Movie movieByTitleAndOrYear = null;
|
||||
Movie movieByTitleAndOrYear;
|
||||
|
||||
if (parsedMovieInfo.Year > 1800)
|
||||
{
|
||||
@ -239,36 +240,33 @@ private bool TryGetMovieBySearchCriteria(ParsedMovieInfo parsedMovieInfo, Search
|
||||
{
|
||||
Movie possibleMovie = null;
|
||||
|
||||
List<string> possibleTitles = new List<string>();
|
||||
var possibleTitles = new List<string>();
|
||||
|
||||
possibleTitles.Add(searchCriteria.Movie.CleanTitle);
|
||||
possibleTitles.AddRange(searchCriteria.Movie.AlternativeTitles.Select(t => t.CleanTitle));
|
||||
possibleTitles.AddRange(searchCriteria.Movie.Translations.Select(t => t.CleanTitle));
|
||||
|
||||
foreach (AlternativeTitle altTitle in searchCriteria.Movie.AlternativeTitles)
|
||||
var cleanTitle = parsedMovieInfo.MovieTitle.CleanMovieTitle();
|
||||
|
||||
foreach (var title in possibleTitles)
|
||||
{
|
||||
possibleTitles.Add(altTitle.CleanTitle);
|
||||
}
|
||||
|
||||
string cleanTitle = parsedMovieInfo.MovieTitle.CleanMovieTitle();
|
||||
|
||||
foreach (string title in possibleTitles)
|
||||
{
|
||||
if (title == parsedMovieInfo.MovieTitle.CleanMovieTitle())
|
||||
if (title == cleanTitle)
|
||||
{
|
||||
possibleMovie = searchCriteria.Movie;
|
||||
}
|
||||
|
||||
foreach (ArabicRomanNumeral numeralMapping in _arabicRomanNumeralMappings)
|
||||
foreach (var numeralMapping in _arabicRomanNumeralMappings)
|
||||
{
|
||||
string arabicNumeral = numeralMapping.ArabicNumeralAsString;
|
||||
string romanNumeral = numeralMapping.RomanNumeralLowerCase;
|
||||
var arabicNumeral = numeralMapping.ArabicNumeralAsString;
|
||||
var romanNumeral = numeralMapping.RomanNumeralLowerCase;
|
||||
|
||||
//_logger.Debug(cleanTitle);
|
||||
if (title.Replace(arabicNumeral, romanNumeral) == parsedMovieInfo.MovieTitle.CleanMovieTitle())
|
||||
if (title.Replace(arabicNumeral, romanNumeral) == cleanTitle)
|
||||
{
|
||||
possibleMovie = searchCriteria.Movie;
|
||||
}
|
||||
|
||||
if (title == parsedMovieInfo.MovieTitle.CleanMovieTitle().Replace(arabicNumeral, romanNumeral))
|
||||
if (title == cleanTitle.Replace(arabicNumeral, romanNumeral))
|
||||
{
|
||||
possibleMovie = searchCriteria.Movie;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user