1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Rename CleanSeriesTitle to CleanMovieTitle

This commit is contained in:
Qstick 2020-07-21 22:08:59 -04:00
parent b6c75e7e1b
commit 6d4be67e36
9 changed files with 35 additions and 42 deletions

View File

@ -33,7 +33,7 @@ private void ValidateMovie(Movie movie)
{
movie.Should().NotBeNull();
movie.Title.Should().NotBeNullOrWhiteSpace();
movie.CleanTitle.Should().Be(Parser.Parser.CleanSeriesTitle(movie.Title));
movie.CleanTitle.Should().Be(Parser.Parser.CleanMovieTitle(movie.Title));
movie.SortTitle.Should().Be(MovieTitleNormalizer.Normalize(movie.Title, movie.TmdbId));
movie.Overview.Should().NotBeNullOrWhiteSpace();
movie.InCinemas.Should().HaveValue();

View File

@ -14,7 +14,7 @@ public class NormalizeTitleFixture : CoreTest
[TestCase("Law_and_Order_SVU", "lawordersvu")]
public void should_normalize_series_title(string parsedSeriesName, string seriesName)
{
var result = parsedSeriesName.CleanSeriesTitle();
var result = parsedSeriesName.CleanMovieTitle();
result.Should().Be(seriesName);
}
@ -28,7 +28,7 @@ public void should_normalize_series_title(string parsedSeriesName, string series
[TestCase("Im a cyborg, but thats ok", "imcyborgbutthatsok")]
public void should_remove_special_characters_and_casing(string dirty, string clean)
{
var result = dirty.CleanSeriesTitle();
var result = dirty.CleanMovieTitle();
result.Should().Be(clean);
}
@ -52,7 +52,7 @@ public void should_remove_common_words(string word)
foreach (var s in dirtyFormat)
{
var dirty = string.Format(s, word);
dirty.CleanSeriesTitle().Should().Be("wordword");
dirty.CleanMovieTitle().Should().Be("wordword");
}
}
@ -69,7 +69,7 @@ public void should_remove_a_from_middle_of_title()
foreach (var s in dirtyFormat)
{
var dirty = string.Format(s, "a");
dirty.CleanSeriesTitle().Should().Be("wordword");
dirty.CleanMovieTitle().Should().Be("wordword");
}
}
@ -86,7 +86,7 @@ public void should_not_remove_a_when_at_start_of_acronym()
foreach (var s in dirtyFormat)
{
var dirty = string.Format(s, "a");
dirty.CleanSeriesTitle().Should().Be("wordankleword");
dirty.CleanMovieTitle().Should().Be("wordankleword");
}
}
@ -103,7 +103,7 @@ public void should_not_remove_a_when_at_end_of_acronym()
foreach (var s in dirtyFormat)
{
var dirty = string.Format(s, "a");
dirty.CleanSeriesTitle().Should().Be("wordnkleaword");
dirty.CleanMovieTitle().Should().Be("wordnkleaword");
}
}
@ -128,7 +128,7 @@ public void should_not_remove_common_words_in_the_middle_of_word(string word)
foreach (var s in dirtyFormat)
{
var dirty = string.Format(s, word);
dirty.CleanSeriesTitle().Should().Be("word" + word.ToLower() + "word");
dirty.CleanMovieTitle().Should().Be("word" + word.ToLower() + "word");
}
}
@ -137,7 +137,7 @@ public void should_not_remove_common_words_in_the_middle_of_word(string word)
[TestCase("The.Daily.Show", "thedailyshow")]
public void should_not_remove_from_the_beginning_of_the_title(string parsedSeriesName, string seriesName)
{
var result = parsedSeriesName.CleanSeriesTitle();
var result = parsedSeriesName.CleanMovieTitle();
result.Should().Be(seriesName);
}
@ -159,14 +159,14 @@ public void should_not_clean_word_from_beginning_of_string(string word)
foreach (var s in dirtyFormat)
{
var dirty = string.Format(s, word);
dirty.CleanSeriesTitle().Should().Be(word + "wordword");
dirty.CleanMovieTitle().Should().Be(word + "wordword");
}
}
[Test]
public void should_not_clean_trailing_a()
{
"Tokyo Ghoul A".CleanSeriesTitle().Should().Be("tokyoghoula");
"Tokyo Ghoul A".CleanMovieTitle().Should().Be("tokyoghoula");
}
}
}

View File

@ -30,7 +30,7 @@ public void should_remove_accents_from_title()
{
const string title = "Carniv\u00E0le";
title.CleanSeriesTitle().Should().Be("carnivale");
title.CleanMovieTitle().Should().Be("carnivale");
}
[TestCase("The.Man.from.U.N.C.L.E.2015.1080p.BluRay.x264-SPARKS", "The Man from U.N.C.L.E.")]

View File

@ -164,7 +164,7 @@ public Movie MapMovie(MovieResource resource)
movie.Title = resource.Title;
movie.OriginalTitle = resource.OriginalTitle;
movie.TitleSlug = resource.TitleSlug;
movie.CleanTitle = resource.Title.CleanSeriesTitle();
movie.CleanTitle = resource.Title.CleanMovieTitle();
movie.SortTitle = Parser.Parser.NormalizeTitle(resource.Title);
movie.Overview = resource.Overview;
@ -459,7 +459,7 @@ private static AlternativeTitle MapAlternativeTitle(AlternativeTitleResource arg
{
Title = arg.Title,
SourceType = SourceType.TMDB,
CleanTitle = arg.Title.CleanSeriesTitle(),
CleanTitle = arg.Title.CleanMovieTitle(),
Language = IsoLanguages.Find(arg.Language.ToLower())?.Language ?? Language.English
};
@ -472,7 +472,7 @@ private static MovieTranslation MapTranslation(TranslationResource arg)
{
Title = arg.Title,
Overview = arg.Overview,
CleanTitle = arg.Title.CleanSeriesTitle(),
CleanTitle = arg.Title.CleanMovieTitle(),
Language = IsoLanguages.Find(arg.Language.ToLower())?.Language
};

View File

@ -100,7 +100,7 @@ private Movie SetPropertiesAndValidate(Movie newMovie)
newMovie.Path = Path.Combine(newMovie.RootFolderPath, folderName);
}
newMovie.CleanTitle = newMovie.Title.CleanSeriesTitle();
newMovie.CleanTitle = newMovie.Title.CleanMovieTitle();
newMovie.SortTitle = MovieTitleNormalizer.Normalize(newMovie.Title, newMovie.TmdbId);
newMovie.Added = DateTime.UtcNow;

View File

@ -22,7 +22,7 @@ public AlternativeTitle()
public AlternativeTitle(string title, SourceType sourceType = SourceType.TMDB, int sourceId = 0, Language language = null)
{
Title = title;
CleanTitle = title.CleanSeriesTitle();
CleanTitle = title.CleanMovieTitle();
SourceType = sourceType;
SourceId = sourceId;
Language = language ?? Language.English;

View File

@ -103,12 +103,12 @@ public List<Movie> AddMovies(List<Movie> newMovies)
public Movie FindByTitle(string title)
{
return FindByTitle(title.CleanSeriesTitle(), null);
return FindByTitle(title.CleanMovieTitle(), null);
}
public Movie FindByTitle(string title, int year)
{
return FindByTitle(title.CleanSeriesTitle(), year as int?);
return FindByTitle(title.CleanMovieTitle(), year as int?);
}
private Movie FindByTitle(string cleanTitle, int? year)
@ -166,7 +166,7 @@ public List<Movie> FindByTmdbId(List<int> tmdbids)
private List<Movie> FindByTitleInexactAll(string title)
{
// find any movie clean title within the provided release title
string cleanTitle = title.CleanSeriesTitle();
string cleanTitle = title.CleanMovieTitle();
var list = _movieRepository.FindByTitleInexact(cleanTitle);
if (!list.Any())
{
@ -180,7 +180,7 @@ private List<Movie> FindByTitleInexactAll(string title)
{
position = cleanTitle.IndexOf(movie.CleanTitle),
length = movie.CleanTitle.Length,
movie = movie
movie
})
.Where(s => (s.position >= 0))
.ToList()
@ -359,7 +359,7 @@ public bool MovieExists(Movie movie)
{
if (movie.Year > 1850)
{
result = FindByTitle(movie.Title.CleanSeriesTitle(), movie.Year);
result = FindByTitle(movie.Title.CleanMovieTitle(), movie.Year);
if (result != null)
{
return true;
@ -367,7 +367,7 @@ public bool MovieExists(Movie movie)
}
else
{
result = FindByTitle(movie.Title.CleanSeriesTitle());
result = FindByTitle(movie.Title.CleanMovieTitle());
if (result != null)
{
return true;
@ -389,7 +389,7 @@ public List<Movie> FilterExistingMovies(List<Movie> movies)
var ret = withTmdbid.ExceptBy(m => m.TmdbId, allMovies, m => m.TmdbId, EqualityComparer<int>.Default)
.Union(withImdbid.ExceptBy(m => m.ImdbId, allMovies, m => m.ImdbId, EqualityComparer<string>.Default))
.Union(rest.ExceptBy(m => m.Title.CleanSeriesTitle(), allMovies, m => m.CleanTitle, EqualityComparer<string>.Default)).ToList();
.Union(rest.ExceptBy(m => m.Title.CleanMovieTitle(), allMovies, m => m.CleanTitle, EqualityComparer<string>.Default)).ToList();
return ret;
}

View File

@ -374,7 +374,7 @@ public static string ToUrlSlug(string value)
return value;
}
public static string CleanSeriesTitle(this string title)
public static string CleanMovieTitle(this string title)
{
long number = 0;

View File

@ -68,20 +68,13 @@ public ParsedMovieInfo EnhanceMovieInfo(ParsedMovieInfo minimalInfo, List<object
{
if (helpers != null)
{
minimalInfo = AugmentMovieInfo(minimalInfo, helpers);
}
var augmenters = _augmenters.Where(a => helpers.Any(t => a.HelperType.IsInstanceOfType(t)) || a.HelperType == null);
return minimalInfo;
}
private ParsedMovieInfo AugmentMovieInfo(ParsedMovieInfo minimalInfo, List<object> helpers)
{
var augmenters = _augmenters.Where(a => helpers.Any(t => a.HelperType.IsInstanceOfType(t)) || a.HelperType == null);
foreach (var augmenter in augmenters)
{
minimalInfo = augmenter.AugmentMovieInfo(minimalInfo,
helpers.FirstOrDefault(h => augmenter.HelperType.IsInstanceOfType(h)));
foreach (var augmenter in augmenters)
{
minimalInfo = augmenter.AugmentMovieInfo(minimalInfo,
helpers.FirstOrDefault(h => augmenter.HelperType.IsInstanceOfType(h)));
}
}
return minimalInfo;
@ -255,11 +248,11 @@ private bool TryGetMovieBySearchCriteria(ParsedMovieInfo parsedMovieInfo, Search
possibleTitles.Add(altTitle.CleanTitle);
}
string cleanTitle = parsedMovieInfo.MovieTitle.CleanSeriesTitle();
string cleanTitle = parsedMovieInfo.MovieTitle.CleanMovieTitle();
foreach (string title in possibleTitles)
{
if (title == parsedMovieInfo.MovieTitle.CleanSeriesTitle())
if (title == parsedMovieInfo.MovieTitle.CleanMovieTitle())
{
possibleMovie = searchCriteria.Movie;
}
@ -270,12 +263,12 @@ private bool TryGetMovieBySearchCriteria(ParsedMovieInfo parsedMovieInfo, Search
string romanNumeral = numeralMapping.RomanNumeralLowerCase;
//_logger.Debug(cleanTitle);
if (title.Replace(arabicNumeral, romanNumeral) == parsedMovieInfo.MovieTitle.CleanSeriesTitle())
if (title.Replace(arabicNumeral, romanNumeral) == parsedMovieInfo.MovieTitle.CleanMovieTitle())
{
possibleMovie = searchCriteria.Movie;
}
if (title == parsedMovieInfo.MovieTitle.CleanSeriesTitle().Replace(arabicNumeral, romanNumeral))
if (title == parsedMovieInfo.MovieTitle.CleanMovieTitle().Replace(arabicNumeral, romanNumeral))
{
possibleMovie = searchCriteria.Movie;
}