1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-30 07:22:35 +01:00

Fixed: Ignore language in split episode title

This commit is contained in:
Mark McDowall 2024-02-26 21:33:07 -08:00 committed by GitHub
parent 4c170d0452
commit b34e0f8259
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 1 deletions

View File

@ -0,0 +1,23 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ParserTests
{
[TestFixture]
public class NormalizeEpisodeTitleFixture : CoreTest
{
[TestCase("Episode Title", "episode title")]
[TestCase("A.B,C;", "a b c")]
[TestCase("Episode Title", "episode title")]
[TestCase("French Title (1)", "french title")]
[TestCase("Series.Title.S01.Special.Episode.Title.720p.HDTV.x264-Sonarr", "episode title")]
[TestCase("Series.Title.S01E00.Episode.Title.720p.HDTV.x264-Sonarr", "episode title")]
public void should_normalize_episode_title(string input, string expected)
{
var result = Parser.Parser.NormalizeEpisodeTitle(input);
result.Should().Be(expected);
}
}
}

View File

@ -6,7 +6,7 @@ using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ParserTests
{
[TestFixture]
public class NormalizeTitleFixture : CoreTest
public class NormalizeSeriesTitleFixture : CoreTest
{
[TestCase("Series", "series")]
[TestCase("Series (2009)", "series2009")]

View File

@ -541,6 +541,7 @@ namespace NzbDrone.Core.Parser
private static readonly Regex TitleComponentsRegex = new Regex(@"^(?:(?<title>.+?) \((?<title>.+?)\)|(?<title>.+?) \| (?<title>.+?))$",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex PartRegex = new Regex(@"\(\d+\)$", RegexOptions.Compiled);
private static readonly Regex PunctuationRegex = new Regex(@"[^\w\s]", RegexOptions.Compiled);
private static readonly Regex ArticleWordRegex = new Regex(@"^(a|an|the)\s", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex SpecialEpisodeWordRegex = new Regex(@"\b(part|special|edition|christmas)\b\s?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
@ -792,6 +793,7 @@ namespace NzbDrone.Core.Parser
// Disabled, Until we run into specific testcases for the removal of these words.
// title = SpecialEpisodeWordRegex.Replace(title, string.Empty);
title = PartRegex.Replace(title, "");
title = PunctuationRegex.Replace(title, " ");
title = DuplicateSpacesRegex.Replace(title, " ");