New: Better Polish language Release Parsing (#5592)

* Parse Polish language

* Tests for parsing Polish language
pull/5662/head
tenshiak 4 years ago committed by GitHub
parent 1c58e26183
commit 4bac44e893
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -158,6 +158,14 @@ namespace NzbDrone.Core.Test.ParserTests
}
[TestCase("Pulp.Fiction.1994.Polish.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.PL.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.PLDUB.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.DUBPL.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.PL-DUB.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.DUB-PL.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.PLLEK.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.LEKPL.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.PL-LEK.1080p.XviD-LOL")]
public void should_parse_language_polish(string postTitle)
{
var result = Parser.Parser.ParseMovieTitle(postTitle, true);

@ -14,10 +14,10 @@ namespace NzbDrone.Core.Parser
{
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(LanguageParser));
private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_|^)(?<italian>\b(?:ita|italian)\b)|(?<german>\b(?:german|videomann|ger)\b)|(?<flemish>flemish)|(?<bulgarian>bgaudio)|(?<brazilian>dublado)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR|VO|VFF|VFQ|VFI|VF2|TRUEFRENCH)(?:\W|_))|(?<russian>\brus\b)|(?<english>\beng\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>\b(?:german|videomann|ger)\b)|(?<flemish>flemish)|(?<bulgarian>bgaudio)|(?<brazilian>dublado)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR|VO|VFF|VFQ|VFI|VF2|TRUEFRENCH)(?:\W|_))|(?<russian>\brus\b)|(?<english>\beng\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);
private static readonly Regex SubtitleLanguageRegex = new Regex(".+?[-_. ](?<iso_code>[a-z]{2,3})(?:[-_. ]forced)?$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
@ -155,6 +155,11 @@ namespace NzbDrone.Core.Parser
languages.Add(Language.Czech);
}
if (caseSensitiveMatch.Groups["polish"].Captures.Cast<Capture>().Any())
{
languages.Add(Language.Polish);
}
var matches = LanguageRegex.Matches(title);
foreach (Match match in matches)
@ -219,6 +224,11 @@ namespace NzbDrone.Core.Parser
languages.Add(Language.Hebrew);
}
if (match.Groups["polish"].Success)
{
languages.Add(Language.Polish);
}
if (match.Groups["chinese"].Success)
{
languages.Add(Language.Chinese);

Loading…
Cancel
Save