mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-04-25 06:47:09 -04:00
parent
26228e546e
commit
ccc2c39d43
2 changed files with 13 additions and 0 deletions
|
@ -134,5 +134,13 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||||
{
|
{
|
||||||
"Tokyo Ghoul A".CleanSeriesTitle().Should().Be("tokyoghoula");
|
"Tokyo Ghoul A".CleanSeriesTitle().Should().Be("tokyoghoula");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase("3%", "3percent")]
|
||||||
|
[TestCase("Teen Top & 100% Outing Brothers", "teentop100percentoutingbrothers")]
|
||||||
|
[TestCase("Big Jay Oakerson's What's Your F@%king Deal?!", "bigjayoakersonswhatsyourfkingdeal")]
|
||||||
|
public void should_replace_percent_sign_with_percent_following_numbers(string input, string expected)
|
||||||
|
{
|
||||||
|
input.CleanSeriesTitle().Should().Be(expected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,6 +310,8 @@ namespace NzbDrone.Core.Parser
|
||||||
string.Empty,
|
string.Empty,
|
||||||
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
|
|
||||||
|
private static readonly Regex PercentRegex = new Regex(@"(?<=\b\d+)%", RegexOptions.Compiled);
|
||||||
|
|
||||||
private static readonly Regex FileExtensionRegex = new Regex(@"\.[a-z0-9]{2,4}$",
|
private static readonly Regex FileExtensionRegex = new Regex(@"\.[a-z0-9]{2,4}$",
|
||||||
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
|
|
||||||
|
@ -528,6 +530,9 @@ namespace NzbDrone.Core.Parser
|
||||||
if (long.TryParse(title, out number))
|
if (long.TryParse(title, out number))
|
||||||
return title;
|
return title;
|
||||||
|
|
||||||
|
// Replace `%` with `percent` to deal with the 3% case
|
||||||
|
title = PercentRegex.Replace(title, "percent");
|
||||||
|
|
||||||
return NormalizeRegex.Replace(title).ToLower().RemoveAccent();
|
return NormalizeRegex.Replace(title).ToLower().RemoveAccent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue