From 3477dfacd0ebf6480b3e7ff07c9939dee699e7f8 Mon Sep 17 00:00:00 2001 From: Gylesie <86306812+Gylesie@users.noreply.github.com> Date: Thu, 22 Sep 2022 18:47:19 +0200 Subject: [PATCH] New: Add Slovak Language --- .../ParserTests/LanguageParserFixture.cs | 8 ++++++++ src/NzbDrone.Core/Languages/Language.cs | 4 +++- src/NzbDrone.Core/Parser/IsoLanguages.cs | 1 + src/NzbDrone.Core/Parser/LanguageParser.cs | 12 +++++++++++- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs index f4743754b..834a21ba7 100644 --- a/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs @@ -298,6 +298,14 @@ namespace NzbDrone.Core.Test.ParserTests result.First().Id.Should().Be(Language.Ukrainian.Id); } + [TestCase("Title.the.Series.2022.S02E22.Slovak.HDTV.XviD-LOL")] + [TestCase("Title.the.Series.2021.S01E11.HDTV.XviD.ENG.SK-LOL")] + public void should_parse_language_slovak(string postTitle) + { + var result = LanguageParser.ParseLanguage(postTitle); + result.Id.Should().Be(Language.Slovak.Id); + } + [TestCase("Title.the.Russian.Series.S01E07.Cold.Action.HDTV.XviD-Droned")] [TestCase("Title.the.Russian.Series.S01E07E08.Cold.Action.HDTV.XviD-Droned")] [TestCase("Title.the.Russian.Series.S01.1080p.WEBRip.DDP5.1.x264-Drone")] diff --git a/src/NzbDrone.Core/Languages/Language.cs b/src/NzbDrone.Core/Languages/Language.cs index c276bda3b..ab400fc01 100644 --- a/src/NzbDrone.Core/Languages/Language.cs +++ b/src/NzbDrone.Core/Languages/Language.cs @@ -101,6 +101,7 @@ namespace NzbDrone.Core.Languages public static Language Bulgarian => new Language(28, "Bulgarian"); public static Language Malayalam => new Language(29, "Malayalam"); public static Language Ukrainian => new Language(30, "Ukrainian"); + public static Language Slovak => new Language(31, "Slovak"); public static List All { @@ -138,7 +139,8 @@ namespace NzbDrone.Core.Languages Hindi, Bulgarian, Malayalam, - Ukrainian + Ukrainian, + Slovak }; } } diff --git a/src/NzbDrone.Core/Parser/IsoLanguages.cs b/src/NzbDrone.Core/Parser/IsoLanguages.cs index d6f908e84..a28fec2fa 100644 --- a/src/NzbDrone.Core/Parser/IsoLanguages.cs +++ b/src/NzbDrone.Core/Parser/IsoLanguages.cs @@ -41,6 +41,7 @@ namespace NzbDrone.Core.Parser new IsoLanguage("bg", "", "bul", Language.Bulgarian), new IsoLanguage("ml", "", "mal", Language.Malayalam), new IsoLanguage("uk", "", "ukr", Language.Ukrainian), + new IsoLanguage("sk", "", "slk", Language.Slovak) }; public static IsoLanguage Find(string isoCode) diff --git a/src/NzbDrone.Core/Parser/LanguageParser.cs b/src/NzbDrone.Core/Parser/LanguageParser.cs index a2d89dfd5..2549b6974 100644 --- a/src/NzbDrone.Core/Parser/LanguageParser.cs +++ b/src/NzbDrone.Core/Parser/LanguageParser.cs @@ -22,7 +22,7 @@ namespace NzbDrone.Core.Parser private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?\b(?:ita|italian)\b)|(?german\b|videomann|ger[. ]dub)|(?flemish)|(?greek)|(?(?:\W|_)(?:FR|VF|VF2|VFF|VFQ|TRUEFRENCH)(?:\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)\]|简|繁|字幕)|(?\bbgaudio\b)|(?\b(?:español|castellano)\b)|(?\b(?:ukr)\b)", RegexOptions.IgnoreCase | RegexOptions.Compiled); - private static readonly Regex CaseSensitiveLanguageRegex = new Regex(@"(?:(?i)(?\bLT\b)|(?\bCZ\b)|(?\bPL\b)|(?\bBG\b))(?:(?i)(?![\W|_|^]SUB))", + private static readonly Regex CaseSensitiveLanguageRegex = new Regex(@"(?:(?i)(?\bLT\b)|(?\bCZ\b)|(?\bPL\b)|(?\bBG\b)|(?\bSK\b))(?:(?i)(?![\W|_|^]SUB))", RegexOptions.Compiled); private static readonly Regex SubtitleLanguageRegex = new Regex(".+?[-_. ](?[a-z]{2,3})([-_. ](?full|forced|foreign|default|cc|psdh|sdh))*$", RegexOptions.Compiled | RegexOptions.IgnoreCase); @@ -156,6 +156,11 @@ namespace NzbDrone.Core.Parser languages.Add(Language.Bulgarian); } + if (lowerTitle.Contains("slovak")) + { + languages.Add(Language.Slovak); + } + var regexLanguages = RegexLanguage(title); if (regexLanguages.Any()) @@ -257,6 +262,11 @@ namespace NzbDrone.Core.Parser languages.Add(Language.Bulgarian); } + if (caseSensitiveMatch.Groups["slovak"].Captures.Cast().Any()) + { + languages.Add(Language.Slovak); + } + // Case insensitive var match = LanguageRegex.Match(title);