From 057086a63022d7f4a7d9c4e3cd951ed4ff851b82 Mon Sep 17 00:00:00 2001 From: halali Date: Wed, 12 Sep 2018 16:46:57 +0200 Subject: [PATCH] Added: Czech Language (#2948) --- .../ParserTests/LanguageParserFixture.cs | 3 +++ src/NzbDrone.Core/Parser/IsoLanguages.cs | 3 ++- src/NzbDrone.Core/Parser/Language.cs | 3 ++- src/NzbDrone.Core/Parser/LanguageParser.cs | 10 ++++++++-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs index ab2d3941c..ab5e0a79d 100644 --- a/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs @@ -32,6 +32,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("Castle.2009.S01E14.Norwegian.HDTV.XviD-LOL", Language.Norwegian)] [TestCase("Castle.2009.S01E14.Finnish.HDTV.XviD-LOL", Language.Finnish)] [TestCase("Castle.2009.S01E14.Turkish.HDTV.XviD-LOL", Language.Turkish)] + [TestCase("Castle.2009.S01E14.Czech.HDTV.XviD-LOL", Language.Czech)] [TestCase("Castle.2009.S01E14.Portuguese.HDTV.XviD-LOL", Language.Portuguese)] [TestCase("Burn.Notice.S04E15.Brotherly.Love.GERMAN.DUBBED.WS.WEBRiP.XviD.REPACK-TVP", Language.German)] [TestCase("Revolution S01E03 No Quarter 2012 WEB-DL 720p Nordic-philipo mkv", Language.Norwegian)] @@ -39,6 +40,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("Castle.2009.S01E14.HDTV.XviD.HUNDUB-LOL", Language.Hungarian)] [TestCase("Castle.2009.S01E14.HDTV.XviD.ENG.HUN-LOL", Language.Hungarian)] [TestCase("Castle.2009.S01E14.HDTV.XviD.HUN-LOL", Language.Hungarian)] + [TestCase("Castle.2009.S01E14.HDTV.XviD.CZ-LOL", Language.Czech)] [TestCase("Passengers.2016.German.DL.AC3.Dubbed.1080p.WebHD.h264.iNTERNAL-PsO", Language.German)] [TestCase("Der.Soldat.James.German.Bluray.FuckYou.Pso.Why.cant.you.follow.scene.rules.1998", Language.German)] [TestCase("Passengers.German.DL.AC3.Dubbed..BluRay.x264-PsO", Language.German)] @@ -46,6 +48,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("Smurfs.​The.​Lost.​Village.​2017.​1080p.​BluRay.​HebDub.​x264-​iSrael",Language.Hebrew)] [TestCase("The Danish Girl 2015", Language.English)] [TestCase("Nocturnal Animals (2016) MULTi VFQ English [1080p] BluRay x264-PopHD", Language.English, Language.French)] + [TestCase("Wonder.Woman.2017.720p.BluRay.DD5.1.x264-TayTO.CZ-FTU", Language.Czech)] public void should_parse_language(string postTitle, params Language[] languages) { var movieInfo = Parser.Parser.ParseMovieTitle(postTitle, true); diff --git a/src/NzbDrone.Core/Parser/IsoLanguages.cs b/src/NzbDrone.Core/Parser/IsoLanguages.cs index 289288f1c..a5147cdeb 100644 --- a/src/NzbDrone.Core/Parser/IsoLanguages.cs +++ b/src/NzbDrone.Core/Parser/IsoLanguages.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; namespace NzbDrone.Core.Parser @@ -30,6 +30,7 @@ namespace NzbDrone.Core.Parser new IsoLanguage("ko", "kor", Language.Korean), new IsoLanguage("hu", "hun", Language.Hungarian), new IsoLanguage("he", "heb", Language.Hebrew), + new IsoLanguage("cs", "ces", Language.Czech), new IsoLanguage("an", "any", Language.Any) }; diff --git a/src/NzbDrone.Core/Parser/Language.cs b/src/NzbDrone.Core/Parser/Language.cs index 37e47ff9d..0d52db05f 100644 --- a/src/NzbDrone.Core/Parser/Language.cs +++ b/src/NzbDrone.Core/Parser/Language.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; namespace NzbDrone.Core.Parser @@ -29,6 +29,7 @@ namespace NzbDrone.Core.Parser Korean = 21, Hungarian = 22, Hebrew = 23, + Czech = 24, Any = -1, } diff --git a/src/NzbDrone.Core/Parser/LanguageParser.cs b/src/NzbDrone.Core/Parser/LanguageParser.cs index 2d022cc3c..d139dbe79 100644 --- a/src/NzbDrone.Core/Parser/LanguageParser.cs +++ b/src/NzbDrone.Core/Parser/LanguageParser.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -13,7 +13,7 @@ namespace NzbDrone.Core.Parser { private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(LanguageParser)); - private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?\b(?:ita|italian)\b)|(?german\b|videomann)|(?flemish)|(?greek)|(?(?:\W|_)(?:FR|VOSTFR|VO|VFF|VFQ|VF2|TRUEFRENCH)(?:\W|_))|(?\brus\b)|(?nl\W?subs?)|(?\b(?:HUNDUB|HUN)\b)|(?\bHebDub\b)", + private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?\b(?:ita|italian)\b)|(?german\b|videomann)|(?flemish)|(?greek)|(?(?:\W|_)(?:FR|VOSTFR|VO|VFF|VFQ|VF2|TRUEFRENCH)(?:\W|_))|(?\brus\b)|(?nl\W?subs?)|(?\b(?:HUNDUB|HUN)\b)|(?\bHebDub\b)|(?\bCZ|SK\b)", RegexOptions.IgnoreCase | RegexOptions.Compiled); private static readonly Regex SubtitleLanguageRegex = new Regex(".+?[-_. ](?[a-z]{2,3})$", RegexOptions.Compiled | RegexOptions.IgnoreCase); @@ -83,6 +83,9 @@ namespace NzbDrone.Core.Parser if (lowerTitle.Contains("hebrew")) languages.Add( Language.Hebrew); + if (lowerTitle.Contains("czech")) + languages.Add( Language.Czech); + var match = LanguageRegex.Match(title); if (match.Groups["italian"].Captures.Cast().Any()) @@ -112,6 +115,9 @@ namespace NzbDrone.Core.Parser if (match.Groups["hebrew"].Success) languages.Add( Language.Hebrew); + if (match.Groups["czech"].Success) + languages.Add( Language.Czech); + return languages.DistinctBy(l => (int)l).ToList(); }