New: Add Slovak Language

pull/7481/head
Gylesie 3 years ago committed by Qstick
parent c1f538ed97
commit b549fddf95

@ -342,6 +342,16 @@ namespace NzbDrone.Core.Test.ParserTests
result.Languages.Should().BeEquivalentTo(Language.Bengali); result.Languages.Should().BeEquivalentTo(Language.Bengali);
} }
[TestCase("Movie.Title.1994.HDTV.x264.SK-iCZi")]
[TestCase("Movie.Title.2019.1080p.HDTV.x265.iNTERNAL.SK-iCZi")]
[TestCase("Movie.Title.2018.SLOVAK.DUAL.2160p.UHD.BluRay.x265-iCZi")]
[TestCase("Movie.Title.1990.SLOVAK.HDTV.x264-iCZi")]
public void should_parse_language_slovak(string postTitle)
{
var result = Parser.Parser.ParseMovieTitle(postTitle);
result.Languages.Should().BeEquivalentTo(Language.Slovak);
}
[TestCase("Movie.Title.en.sub")] [TestCase("Movie.Title.en.sub")]
[TestCase("Movie Title.eng.sub")] [TestCase("Movie Title.eng.sub")]
[TestCase("Movie.Title.eng.forced.sub")] [TestCase("Movie.Title.eng.forced.sub")]

@ -105,6 +105,7 @@ namespace NzbDrone.Core.Languages
public static Language Ukrainian => new Language(32, "Ukrainian"); public static Language Ukrainian => new Language(32, "Ukrainian");
public static Language Persian => new Language(33, "Persian"); public static Language Persian => new Language(33, "Persian");
public static Language Bengali => new Language(34, "Bengali"); public static Language Bengali => new Language(34, "Bengali");
public static Language Slovak => new Language(35, "Slovak");
public static Language Any => new Language(-1, "Any"); public static Language Any => new Language(-1, "Any");
public static Language Original => new Language(-2, "Original"); public static Language Original => new Language(-2, "Original");
@ -149,6 +150,7 @@ namespace NzbDrone.Core.Languages
Ukrainian, Ukrainian,
Persian, Persian,
Bengali, Bengali,
Slovak,
Any, Any,
Original Original
}; };

@ -42,7 +42,8 @@ namespace NzbDrone.Core.Parser
new IsoLanguage("uk", "", "ukr", "Ukrainian", Language.Ukrainian), new IsoLanguage("uk", "", "ukr", "Ukrainian", Language.Ukrainian),
new IsoLanguage("fa", "", "fas", "Persian", Language.Persian), new IsoLanguage("fa", "", "fas", "Persian", Language.Persian),
new IsoLanguage("be", "", "ben", "Bengali", Language.Bengali), new IsoLanguage("be", "", "ben", "Bengali", Language.Bengali),
new IsoLanguage("lt", "", "lit", "Lithuanian", Language.Lithuanian) new IsoLanguage("lt", "", "lit", "Lithuanian", Language.Lithuanian),
new IsoLanguage("sk", "", "slk", "Slovak", Language.Slovak)
}; };
public static IsoLanguage Find(string isoCode) public static IsoLanguage Find(string isoCode)

@ -32,7 +32,8 @@ namespace NzbDrone.Core.Parser
private static readonly Regex CaseSensitiveLanguageRegex = new Regex(@"(?:(?i)(?<!SUB[\W|_|^]))(?:(?<lithuanian>\bLT\b)| private static readonly Regex CaseSensitiveLanguageRegex = new Regex(@"(?:(?i)(?<!SUB[\W|_|^]))(?:(?<lithuanian>\bLT\b)|
(?<czech>\bCZ\b)| (?<czech>\bCZ\b)|
(?<polish>\bPL\b)| (?<polish>\bPL\b)|
(?<bulgarian>\bBG\b))(?:(?i)(?![\W|_|^]SUB))", (?<bulgarian>\bBG\b))(?:(?i)(?![\W|_|^]SUB))|
(?<slovak>\bSK\b)",
RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace); RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace);
private static readonly Regex SubtitleLanguageRegex = new Regex(".+?[-_. ](?<iso_code>[a-z]{2,3})(?:[-_. ]forced)?$", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex SubtitleLanguageRegex = new Regex(".+?[-_. ](?<iso_code>[a-z]{2,3})(?:[-_. ]forced)?$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
@ -182,6 +183,11 @@ namespace NzbDrone.Core.Parser
languages.Add(Language.Bengali); languages.Add(Language.Bengali);
} }
if (lowerTitle.Contains("slovak"))
{
languages.Add(Language.Slovak);
}
// Case sensitive // Case sensitive
var caseSensitiveMatch = CaseSensitiveLanguageRegex.Match(title); var caseSensitiveMatch = CaseSensitiveLanguageRegex.Match(title);
@ -205,6 +211,11 @@ namespace NzbDrone.Core.Parser
languages.Add(Language.Bulgarian); languages.Add(Language.Bulgarian);
} }
if (caseSensitiveMatch.Groups["slovak"].Captures.Cast<Capture>().Any())
{
languages.Add(Language.Slovak);
}
var matches = LanguageRegex.Matches(title); var matches = LanguageRegex.Matches(title);
foreach (Match match in matches) foreach (Match match in matches)

Loading…
Cancel
Save