From c7b950f2130686c080cfcd6a26a7120aa736edce Mon Sep 17 00:00:00 2001 From: tenshiak <75363841+tenshiak@users.noreply.github.com> Date: Wed, 30 Dec 2020 21:11:47 +0100 Subject: [PATCH] Fixed: Parsing Polish language --- .../ParserTests/LanguageParserFixture.cs | 9 +++++++++ src/NzbDrone.Core/Parser/LanguageParser.cs | 10 ++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs index 8476489c0..2f76662eb 100644 --- a/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs @@ -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); diff --git a/src/NzbDrone.Core/Parser/LanguageParser.cs b/src/NzbDrone.Core/Parser/LanguageParser.cs index 676e7966b..9b5ba021a 100644 --- a/src/NzbDrone.Core/Parser/LanguageParser.cs +++ b/src/NzbDrone.Core/Parser/LanguageParser.cs @@ -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|_)(?\b(?:ita|italian)\b)|(?german\b|videomann)|(?flemish)|(?greek)|(?(?:\W|_)(?:FR)(?:\W|_))|(?\brus\b)|(?\b(?:HUNDUB|HUN)\b)|(?\bHebDub\b)|(?\[(?:CH[ST]|BIG5|GB)\]|简|繁|字幕)", + private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?\b(?:ita|italian)\b)|(?german\b|videomann)|(?flemish)|(?greek)|(?(?:\W|_)(?:FR)(?:\W|_))|(?\brus\b)|(?\b(?:HUNDUB|HUN)\b)|(?\bHebDub\b)|(?\b(?:PL\W?DUB|DUB\W?PL|LEK\W?PL|PL\W?LEK)\b)|(?\[(?:CH[ST]|BIG5|GB)\]|简|繁|字幕)", RegexOptions.IgnoreCase | RegexOptions.Compiled); - private static readonly Regex CaseSensitiveLanguageRegex = new Regex(@"(?\bLT\b)|(?\bCZ\b)", + private static readonly Regex CaseSensitiveLanguageRegex = new Regex(@"(?\bLT\b)|(?\bCZ\b)|(?\bPL\b)", RegexOptions.Compiled); @@ -148,6 +148,9 @@ namespace NzbDrone.Core.Parser if (caseSensitiveMatch.Groups["czech"].Captures.Cast().Any()) return Language.Czech; + + if (caseSensitiveMatch.Groups["polish"].Captures.Cast().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;