1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

Added Hebrew lanugage

New: Added Hebrew language
Closes #2115
This commit is contained in:
ECB\rotem.shoshan 2017-08-11 13:16:47 +03:00 committed by Mark McDowall
parent 51d08fd8e8
commit 7d21585f50
No known key found for this signature in database
GPG Key ID: D4CEFA9A718052E0
4 changed files with 12 additions and 3 deletions

View File

@ -46,6 +46,7 @@ public class LanguageParserFixture : CoreTest
[TestCase("Castle.2009.S01E14.HDTV.XviD.HUNDUB-LOL", Language.Hungarian)] [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.ENG.HUN-LOL", Language.Hungarian)]
[TestCase("Castle.2009.S01E14.HDTV.XviD.HUN-LOL", Language.Hungarian)] [TestCase("Castle.2009.S01E14.HDTV.XviD.HUN-LOL", Language.Hungarian)]
[TestCase("Avatar.The.Last.Airbender.S01-03.DVDRip.HebDub",Language.Hebrew)]
public void should_parse_language(string postTitle, Language language) public void should_parse_language(string postTitle, Language language)
{ {
var result = LanguageParser.ParseLanguage(postTitle); var result = LanguageParser.ParseLanguage(postTitle);

View File

@ -28,7 +28,8 @@ public static class IsoLanguages
// new IsoLanguage("nl", "nld", Language.Flemish), // new IsoLanguage("nl", "nld", Language.Flemish),
new IsoLanguage("el", "ell", Language.Greek), new IsoLanguage("el", "ell", Language.Greek),
new IsoLanguage("ko", "kor", Language.Korean), 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) public static IsoLanguage Find(string isoCode)

View File

@ -24,6 +24,7 @@ public enum Language
Flemish = 19, Flemish = 19,
Greek = 20, Greek = 20,
Korean = 21, Korean = 21,
Hungarian = 22 Hungarian = 22,
Hebrew = 23
} }
} }

View File

@ -11,7 +11,7 @@ public static class LanguageParser
{ {
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(LanguageParser)); private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(LanguageParser));
private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?<italian>\b(?:ita|italian)\b)|(?<german>german\b|videomann)|(?<flemish>flemish)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR|VOSTFR)(?:\W|_))|(?<russian>\brus\b)|(?<dutch>nl\W?subs?)|(?<hungarian>\b(?:HUNDUB|HUN)\b)", private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?<italian>\b(?:ita|italian)\b)|(?<german>german\b|videomann)|(?<flemish>flemish)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR|VOSTFR)(?:\W|_))|(?<russian>\brus\b)|(?<dutch>nl\W?subs?)|(?<hungarian>\b(?:HUNDUB|HUN)\b)|(?<hebrew>\bHebDub\b)",
RegexOptions.IgnoreCase | RegexOptions.Compiled); RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex SubtitleLanguageRegex = new Regex(".+?[-_. ](?<iso_code>[a-z]{2,3})$", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex SubtitleLanguageRegex = new Regex(".+?[-_. ](?<iso_code>[a-z]{2,3})$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
@ -77,6 +77,9 @@ public static Language ParseLanguage(string title)
if (lowerTitle.Contains("hungarian")) if (lowerTitle.Contains("hungarian"))
return Language.Hungarian; return Language.Hungarian;
if (lowerTitle.Contains("hebrew"))
return Language.Hebrew;
var match = LanguageRegex.Match(title); var match = LanguageRegex.Match(title);
if (match.Groups["italian"].Captures.Cast<Capture>().Any()) if (match.Groups["italian"].Captures.Cast<Capture>().Any())
@ -103,6 +106,9 @@ public static Language ParseLanguage(string title)
if (match.Groups["hungarian"].Success) if (match.Groups["hungarian"].Success)
return Language.Hungarian; return Language.Hungarian;
if (match.Groups["hebrew"].Success)
return Language.Hebrew;
return Language.English; return Language.English;
} }