mirror of
https://github.com/Radarr/Radarr
synced 2025-02-27 16:42:46 +00:00
Fixed: Series title sorting won't remove special/part/episode
This commit is contained in:
parent
fd71bd6969
commit
ddc4c359cb
3 changed files with 16 additions and 7 deletions
|
@ -20,6 +20,7 @@ public void should_use_precomputed_title_for_a_to_z()
|
||||||
[TestCase("The Mentalist", "mentalist")]
|
[TestCase("The Mentalist", "mentalist")]
|
||||||
[TestCase("The Good Wife", "good wife")]
|
[TestCase("The Good Wife", "good wife")]
|
||||||
[TestCase("The Newsroom (2012)", "newsroom 2012")]
|
[TestCase("The Newsroom (2012)", "newsroom 2012")]
|
||||||
|
[TestCase("Special Agent Oso", "special agent oso")]
|
||||||
public void should_normalize_title(String title, String expected)
|
public void should_normalize_title(String title, String expected)
|
||||||
{
|
{
|
||||||
SeriesTitleNormalizer.Normalize(title, 0).Should().Be(expected);
|
SeriesTitleNormalizer.Normalize(title, 0).Should().Be(expected);
|
||||||
|
|
|
@ -323,13 +323,20 @@ public static string CleanupEpisodeTitle(string title)
|
||||||
return MultiPartCleanupRegex.Replace(title, string.Empty).Trim();
|
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)
|
public static string NormalizeTitle(string title)
|
||||||
{
|
{
|
||||||
string singleSpaces = WordDelimiterRegex.Replace(title, " ");
|
title = WordDelimiterRegex.Replace(title, " ");
|
||||||
string noPunctuation = PunctuationRegex.Replace(singleSpaces, String.Empty);
|
title = PunctuationRegex.Replace(title, String.Empty);
|
||||||
string noCommonWords = CommonWordRegex.Replace(noPunctuation, String.Empty);
|
title = CommonWordRegex.Replace(title, String.Empty);
|
||||||
string normalized = SpecialEpisodeWordRegex.Replace(noCommonWords, String.Empty);
|
|
||||||
return normalized.Trim().ToLower();
|
return title.Trim().ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ParseReleaseGroup(string title)
|
public static string ParseReleaseGroup(string title)
|
||||||
|
|
|
@ -106,12 +106,13 @@ public List<Episode> GetEpisodesBySeason(int seriesId, int seasonNumber)
|
||||||
public Episode FindEpisodeByName(int seriesId, int seasonNumber, string episodeTitle)
|
public Episode FindEpisodeByName(int seriesId, int seasonNumber, string episodeTitle)
|
||||||
{
|
{
|
||||||
// TODO: can replace this search mechanism with something smarter/faster/better
|
// 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)
|
return _episodeRepository.GetEpisodes(seriesId, seasonNumber)
|
||||||
.FirstOrDefault(e =>
|
.FirstOrDefault(e =>
|
||||||
{
|
{
|
||||||
// normalize episode title
|
// normalize episode title
|
||||||
string title = Parser.Parser.NormalizeTitle(e.Title);
|
var title = Parser.Parser.NormalizeEpisodeTitle(e.Title);
|
||||||
// find episode title within search string
|
// find episode title within search string
|
||||||
return (title.Length > 0) && search.Contains(title);
|
return (title.Length > 0) && search.Contains(title);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue