mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 07:22:35 +01:00
Fixed: Ignore series title before SxxExx when parsing language.
ref #861
This commit is contained in:
parent
1d862db7c9
commit
b3ff91608e
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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"))
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user