From 7c4c6ccd5c3b7bae51c13a6f24b11c8876ed691b Mon Sep 17 00:00:00 2001 From: Rotem Date: Sat, 12 Aug 2017 01:48:57 +0300 Subject: [PATCH] Added: Hebrew language (#1909) --- .../ParserTests/LanguageParserFixture.cs | 1 + src/NzbDrone.Core/Parser/IsoLanguages.cs | 3 ++- src/NzbDrone.Core/Parser/Language.cs | 3 ++- src/NzbDrone.Core/Parser/LanguageParser.cs | 8 +++++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs index 9c0e75a1a..610e79908 100644 --- a/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs @@ -54,6 +54,7 @@ public class LanguageParserFixture : CoreTest [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)] [TestCase("Valana la Legende FRENCH BluRay 720p 2016 kjhlj", Language.French)] + [TestCase("Smurfs.​The.​Lost.​Village.​2017.​1080p.​BluRay.​HebDub.​x264-​iSrael",Language.Hebrew)] public void should_parse_language(string postTitle, Language language) { var result = Parser.Parser.ParseMovieTitle(postTitle, true); diff --git a/src/NzbDrone.Core/Parser/IsoLanguages.cs b/src/NzbDrone.Core/Parser/IsoLanguages.cs index ddbbe74c2..7aeee15df 100644 --- a/src/NzbDrone.Core/Parser/IsoLanguages.cs +++ b/src/NzbDrone.Core/Parser/IsoLanguages.cs @@ -28,7 +28,8 @@ public static class IsoLanguages // new IsoLanguage("nl", "nld", Language.Flemish), new IsoLanguage("el", "ell", Language.Greek), new IsoLanguage("ko", "kor", Language.Korean), - new IsoLanguage("hu", "hun", Language.Hungarian) + new IsoLanguage("hu", "hun", Language.Hungarian), + new IsoLanguage("he", "heb", Language.Hebrew) }; public static IsoLanguage Find(string isoCode) diff --git a/src/NzbDrone.Core/Parser/Language.cs b/src/NzbDrone.Core/Parser/Language.cs index f85281dd1..e720890e7 100644 --- a/src/NzbDrone.Core/Parser/Language.cs +++ b/src/NzbDrone.Core/Parser/Language.cs @@ -24,6 +24,7 @@ public enum Language Flemish = 19, Greek = 20, Korean = 21, - Hungarian = 22 + Hungarian = 22, + Hebrew = 23 } } diff --git a/src/NzbDrone.Core/Parser/LanguageParser.cs b/src/NzbDrone.Core/Parser/LanguageParser.cs index 2f705ca1f..5dc19f4e4 100644 --- a/src/NzbDrone.Core/Parser/LanguageParser.cs +++ b/src/NzbDrone.Core/Parser/LanguageParser.cs @@ -11,7 +11,7 @@ public static class LanguageParser { 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|TRUEFRENCH)(?:\W|_))|(?\brus\b)|(?nl\W?subs?)|(?\b(?:HUNDUB|HUN)\b)", + private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?\b(?:ita|italian)\b)|(?german\b|videomann)|(?flemish)|(?greek)|(?(?:\W|_)(?:FR|VOSTFR|VO|VFF|VFQ|TRUEFRENCH)(?:\W|_))|(?\brus\b)|(?nl\W?subs?)|(?\b(?:HUNDUB|HUN)\b)|(?\bHebDub\b)", RegexOptions.IgnoreCase | RegexOptions.Compiled); private static readonly Regex SubtitleLanguageRegex = new Regex(".+?[-_. ](?[a-z]{2,3})$", RegexOptions.Compiled | RegexOptions.IgnoreCase); @@ -77,6 +77,9 @@ public static Language ParseLanguage(string title) if (lowerTitle.Contains("hungarian")) return Language.Hungarian; + if (lowerTitle.Contains("hebrew")) + return Language.Hebrew; + var match = LanguageRegex.Match(title); if (match.Groups["italian"].Captures.Cast().Any()) @@ -103,6 +106,9 @@ public static Language ParseLanguage(string title) if (match.Groups["hungarian"].Success) return Language.Hungarian; + if (match.Groups["hebrew"].Success) + return Language.Hebrew; + return Language.English; }