1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-26 12:42:31 +01:00

Fixed: Ignore series title before SxxExx when parsing language.

ref #861
This commit is contained in:
Taloth Saldono 2019-02-04 22:01:25 +01:00
parent 1d862db7c9
commit b3ff91608e
3 changed files with 26 additions and 0 deletions

View File

@ -213,5 +213,13 @@ namespace NzbDrone.Core.Test.ParserTests
result.Language.Id.Should().Be(Language.Czech.Id);
}
[TestCase("Russian.Puppets.S01E07.Cold.Action.HDTV.XviD-Droned")]
public void should_not_parse_series_or_episode_title(string postTitle)
{
var result = Parser.Parser.ParseTitle(postTitle);
result.Language.Name.Should().Be(Language.English.Name);
}
}
}

View File

@ -12,6 +12,11 @@ namespace NzbDrone.Core.Parser
{
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(LanguageParser));
private static readonly RegexReplace[] CleanSeriesTitleRegex = new[]
{
new RegexReplace(@".*?\.(S\d{2}E\d{2,4}\..*)", "$1", RegexOptions.Compiled | RegexOptions.IgnoreCase)
};
private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?<italian>\b(?:ita|italian)\b)|(?<german>german\b|videomann)|(?<flemish>flemish)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR|VOSTFR)(?:\W|_))|(?<russian>\brus\b)|(?<dutch>nl\W?subs?)|(?<hungarian>\b(?:HUNDUB|HUN)\b)|(?<hebrew>\bHebDub\b)",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
@ -23,6 +28,12 @@ namespace NzbDrone.Core.Parser
public static Language ParseLanguage(string title)
{
foreach (var regex in CleanSeriesTitleRegex)
{
if (regex.TryReplace(ref title))
break;
}
var lowerTitle = title.ToLower();
if (lowerTitle.Contains("english"))

View File

@ -22,5 +22,12 @@ namespace NzbDrone.Core.Parser
{
return _regex.Replace(input, _replacement);
}
public bool TryReplace(ref string input)
{
var result = _regex.IsMatch(input);
input = _regex.Replace(input, _replacement);
return result;
}
}
}