mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
Fixed: Series title sorting won't remove special/part/episode
This commit is contained in:
parent
fd71bd6969
commit
ddc4c359cb
@ -20,6 +20,7 @@ public void should_use_precomputed_title_for_a_to_z()
|
||||
[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 @@ public static string CleanupEpisodeTitle(string title)
|
||||
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 @@ public List<Episode> GetEpisodesBySeason(int seriesId, int seasonNumber)
|
||||
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…
Reference in New Issue
Block a user