Fixed: Parsing Polish language

pull/4193/head
tenshiak 4 years ago committed by GitHub
parent 36f231ea24
commit c7b950f213
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -131,6 +131,15 @@ namespace NzbDrone.Core.Test.ParserTests
}
[TestCase("Castle.2009.S01E14.Polish.HDTV.XviD-LOL")]
[TestCase("Castle.2009.S01E14.PL.HDTV.XviD-LOL")]
[TestCase("Castle.2009.S01E14.PLLEK.HDTV.XviD-LOL")]
[TestCase("Castle.2009.S01E14.PL-LEK.HDTV.XviD-LOL")]
[TestCase("Castle.2009.S01E14.LEKPL.HDTV.XviD-LOL")]
[TestCase("Castle.2009.S01E14.LEK-PL.HDTV.XviD-LOL")]
[TestCase("Castle.2009.S01E14.PLDUB.HDTV.XviD-LOL")]
[TestCase("Castle.2009.S01E14.PL-DUB.HDTV.XviD-LOL")]
[TestCase("Castle.2009.S01E14.DUBPL.HDTV.XviD-LOL")]
[TestCase("Castle.2009.S01E14.DUB-PL.HDTV.XviD-LOL")]
public void should_parse_language_polish(string postTitle)
{
var result = Parser.Parser.ParseTitle(postTitle);

@ -17,10 +17,10 @@ namespace NzbDrone.Core.Parser
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)(?:\W|_))|(?<russian>\brus\b)|(?<hungarian>\b(?:HUNDUB|HUN)\b)|(?<hebrew>\bHebDub\b)|(?<chinese>\[(?:CH[ST]|BIG5|GB)\]|简|繁|字幕)",
private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?<italian>\b(?:ita|italian)\b)|(?<german>german\b|videomann)|(?<flemish>flemish)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR)(?:\W|_))|(?<russian>\brus\b)|(?<hungarian>\b(?:HUNDUB|HUN)\b)|(?<hebrew>\bHebDub\b)|(?<polish>\b(?:PL\W?DUB|DUB\W?PL|LEK\W?PL|PL\W?LEK)\b)|(?<chinese>\[(?:CH[ST]|BIG5|GB)\]|简|繁|字幕)",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex CaseSensitiveLanguageRegex = new Regex(@"(?<lithuanian>\bLT\b)|(?<czech>\bCZ\b)",
private static readonly Regex CaseSensitiveLanguageRegex = new Regex(@"(?<lithuanian>\bLT\b)|(?<czech>\bCZ\b)|(?<polish>\bPL\b)",
RegexOptions.Compiled);
@ -148,6 +148,9 @@ namespace NzbDrone.Core.Parser
if (caseSensitiveMatch.Groups["czech"].Captures.Cast<Capture>().Any())
return Language.Czech;
if (caseSensitiveMatch.Groups["polish"].Captures.Cast<Capture>().Any())
return Language.Polish;
// Case insensitive
var match = LanguageRegex.Match(title);
@ -179,6 +182,9 @@ namespace NzbDrone.Core.Parser
if (match.Groups["hebrew"].Success)
return Language.Hebrew;
if (match.Groups["polish"].Success)
return Language.Polish;
if (match.Groups["chinese"].Success)
return Language.Chinese;

Loading…
Cancel
Save