Fixed: Series title sorting won't remove special/part/episode

pull/6/head
Mark McDowall 10 years ago
parent fd71bd6969
commit ddc4c359cb

@ -20,6 +20,7 @@ namespace NzbDrone.Core.Test.TvTests
[TestCase("The Mentalist", "mentalist")]
[TestCase("The Good Wife", "good wife")]
[TestCase("The Newsroom (2012)", "newsroom 2012")]
[TestCase("Special Agent Oso", "special agent oso")]
public void should_normalize_title(String title, String expected)
{
SeriesTitleNormalizer.Normalize(title, 0).Should().Be(expected);

@ -323,13 +323,20 @@ namespace NzbDrone.Core.Parser
return MultiPartCleanupRegex.Replace(title, string.Empty).Trim();
}
public static string NormalizeEpisodeTitle(string title)
{
return SpecialEpisodeWordRegex.Replace(title, String.Empty)
.Trim()
.ToLower();
}
public static string NormalizeTitle(string title)
{
string singleSpaces = WordDelimiterRegex.Replace(title, " ");
string noPunctuation = PunctuationRegex.Replace(singleSpaces, String.Empty);
string noCommonWords = CommonWordRegex.Replace(noPunctuation, String.Empty);
string normalized = SpecialEpisodeWordRegex.Replace(noCommonWords, String.Empty);
return normalized.Trim().ToLower();
title = WordDelimiterRegex.Replace(title, " ");
title = PunctuationRegex.Replace(title, String.Empty);
title = CommonWordRegex.Replace(title, String.Empty);
return title.Trim().ToLower();
}
public static string ParseReleaseGroup(string title)

@ -106,12 +106,13 @@ namespace NzbDrone.Core.Tv
public Episode FindEpisodeByName(int seriesId, int seasonNumber, string episodeTitle)
{
// TODO: can replace this search mechanism with something smarter/faster/better
var search = Parser.Parser.NormalizeTitle(episodeTitle);
var search = Parser.Parser.NormalizeEpisodeTitle(episodeTitle);
return _episodeRepository.GetEpisodes(seriesId, seasonNumber)
.FirstOrDefault(e =>
{
// normalize episode title
string title = Parser.Parser.NormalizeTitle(e.Title);
var title = Parser.Parser.NormalizeEpisodeTitle(e.Title);
// find episode title within search string
return (title.Length > 0) && search.Contains(title);
});

Loading…
Cancel
Save