From 453f216e0d5d1d51b8c6ae32987b52026546746b Mon Sep 17 00:00:00 2001 From: Bogdan Date: Thu, 29 Aug 2024 09:02:36 +0300 Subject: [PATCH] New: Add Malayalam and Kannada languages --- .../Languages/LanguageFixture.cs | 8 ++++++-- .../ParserTests/LanguageParserFixture.cs | 17 +++++++++++++++++ .../ImportLists/TMDb/TMDbLanguageCodes.cs | 6 +++++- src/NzbDrone.Core/Languages/Language.cs | 4 ++++ src/NzbDrone.Core/Parser/IsoLanguages.cs | 2 ++ src/NzbDrone.Core/Parser/LanguageParser.cs | 10 ++++++++++ 6 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core.Test/Languages/LanguageFixture.cs b/src/NzbDrone.Core.Test/Languages/LanguageFixture.cs index da77d5f42..11d381383 100644 --- a/src/NzbDrone.Core.Test/Languages/LanguageFixture.cs +++ b/src/NzbDrone.Core.Test/Languages/LanguageFixture.cs @@ -59,7 +59,9 @@ namespace NzbDrone.Core.Test.Languages new object[] { 44, Language.Indonesian }, new object[] { 45, Language.Telugu }, new object[] { 46, Language.Macedonian }, - new object[] { 47, Language.Slovenian } + new object[] { 47, Language.Slovenian }, + new object[] { 48, Language.Malayalam }, + new object[] { 49, Language.Kannada } }; public static object[] ToIntCases = @@ -113,7 +115,9 @@ namespace NzbDrone.Core.Test.Languages new object[] { Language.Indonesian, 44 }, new object[] { Language.Telugu, 45 }, new object[] { Language.Macedonian, 46 }, - new object[] { Language.Slovenian, 47 } + new object[] { Language.Slovenian, 47 }, + new object[] { Language.Malayalam, 48 }, + new object[] { Language.Kannada, 49 } }; [Test] diff --git a/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs index d4996761e..33c2cf53c 100644 --- a/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs @@ -419,6 +419,23 @@ namespace NzbDrone.Core.Test.ParserTests result.Languages.Should().Contain(Language.Catalan); } + [TestCase("Movie Title (2024) Malayalam BRRip 1080p x264 DTS 5.1 E-subs-MBRHDRG")] + [TestCase("Movie.Title.2024.Malayalam.1080p.AMZN.WEB-DL.DD+5.1.H.264-Shadow.BonsaiHD")] + [TestCase("Movie.Title.2024.2160p.Malayalam.WEB-DL.H.265.SDR.DDP5.1-NbT")] + public void should_parse_language_malayalam(string postTitle) + { + var result = LanguageParser.ParseLanguages(postTitle); + result.Should().Contain(Language.Malayalam); + } + + [TestCase("Movie Title (2024) Kannada 1080p HD AVC MP4 x264 .9.8GB TEAMTR")] + [TestCase("Movie.Title.2024.Kannada.1080p.AMZN.WEB-DL.DD+2.0.x264-Telly")] + public void should_parse_language_kannada(string postTitle) + { + var result = LanguageParser.ParseLanguages(postTitle); + result.Should().Contain(Language.Kannada); + } + [TestCase("Movie.Title.en.sub")] [TestCase("Movie Title.eng.sub")] [TestCase("Movie.Title.eng.forced.sub")] diff --git a/src/NzbDrone.Core/ImportLists/TMDb/TMDbLanguageCodes.cs b/src/NzbDrone.Core/ImportLists/TMDb/TMDbLanguageCodes.cs index ee3eca6c1..596d1cf57 100644 --- a/src/NzbDrone.Core/ImportLists/TMDb/TMDbLanguageCodes.cs +++ b/src/NzbDrone.Core/ImportLists/TMDb/TMDbLanguageCodes.cs @@ -57,6 +57,10 @@ namespace NzbDrone.Core.ImportLists.TMDb [FieldOption(Hint = "Macedonian")] mk, [FieldOption(Hint = "Slovenian")] - sl + sl, + [FieldOption(Hint = "Malayalam")] + ml, + [FieldOption(Hint = "Kannada")] + kn } } diff --git a/src/NzbDrone.Core/Languages/Language.cs b/src/NzbDrone.Core/Languages/Language.cs index 0684a7391..9aa5d034d 100644 --- a/src/NzbDrone.Core/Languages/Language.cs +++ b/src/NzbDrone.Core/Languages/Language.cs @@ -118,6 +118,8 @@ namespace NzbDrone.Core.Languages public static Language Telugu => new Language(45, "Telugu"); public static Language Macedonian => new Language(46, "Macedonian"); public static Language Slovenian => new Language(47, "Slovenian"); + public static Language Malayalam => new Language(48, "Malayalam"); + public static Language Kannada => new Language(49, "Kannada"); public static Language Any => new Language(-1, "Any"); public static Language Original => new Language(-2, "Original"); @@ -175,6 +177,8 @@ namespace NzbDrone.Core.Languages Telugu, Macedonian, Slovenian, + Malayalam, + Kannada, Any, Original }; diff --git a/src/NzbDrone.Core/Parser/IsoLanguages.cs b/src/NzbDrone.Core/Parser/IsoLanguages.cs index a3b40d48b..b16c3cb39 100644 --- a/src/NzbDrone.Core/Parser/IsoLanguages.cs +++ b/src/NzbDrone.Core/Parser/IsoLanguages.cs @@ -57,6 +57,8 @@ namespace NzbDrone.Core.Parser new IsoLanguage("te", "", "tel", "Telugu", Language.Telugu), new IsoLanguage("mk", "", "mkd", "Macedonian", Language.Macedonian), new IsoLanguage("sl", "", "slv", "Slovenian", Language.Slovenian), + new IsoLanguage("ml", "", "mal", "Malayalam", Language.Malayalam), + new IsoLanguage("kn", "", "kan", "Kannada", Language.Kannada), }; private static readonly Dictionary AlternateIsoCodeMappings = new () diff --git a/src/NzbDrone.Core/Parser/LanguageParser.cs b/src/NzbDrone.Core/Parser/LanguageParser.cs index e1574805e..5609067ad 100644 --- a/src/NzbDrone.Core/Parser/LanguageParser.cs +++ b/src/NzbDrone.Core/Parser/LanguageParser.cs @@ -217,6 +217,16 @@ namespace NzbDrone.Core.Parser languages.Add(Language.Telugu); } + if (lowerTitle.Contains("malayalam")) + { + languages.Add(Language.Malayalam); + } + + if (lowerTitle.Contains("kannada")) + { + languages.Add(Language.Kannada); + } + // Case sensitive var caseSensitiveMatches = CaseSensitiveLanguageRegex.Matches(title);