Skip to content

Commit

Permalink
New: Parse ES as Spanish
Browse files Browse the repository at this point in the history
  • Loading branch information
mynameisbogdan committed Oct 12, 2024
1 parent 4f47bb3 commit 0761e27
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/NzbDrone.Core.Test/ParserTests/LanguageParserFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public void should_parse_language_french_english(string postTitle)
[TestCase("Movie Title (2016) [UHDRemux 2160p SDR] [Castellano DD 5.1 - Inglés DTS-HD MA 5.1 Subs]")]
[TestCase("Movie Title 2022 [HDTV 720p][Cap.101][AC3 5.1 Castellano][www.pctnew.ORG]")]
[TestCase("Movie Title 2022 [HDTV 720p][Cap.206][AC3 5.1 Español Castellano]")]
[TestCase("Movie Title 2022 [Remux-1080p 8-bit h264 DTS-HD MA 2.0][ES.EN]-HiFi")]
[TestCase("Movie Title 2022 [BDRemux 1080p AVC ES DTS-HD MA 5.1 Subs][HDO].mkv")]
[TestCase("Movie.Name.2022.BluRay.1080p.H264.DTS[EN+ES].[EN+ES+IT]")]
public void should_parse_language_spanish(string postTitle)
{
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
Expand Down
1 change: 1 addition & 0 deletions src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ public void should_parse_tmdb_id(string postTitle, int tmdbId)
[TestCase("The.Good.German.2006.720p.HDTV.x264-TVP", Description = "The Good German is hardcoded not to match")]
[TestCase("German.Lancers.2019.720p.BluRay.x264-UNiVERSUM", Description = "German at the beginning is never matched")]
[TestCase("The.German.2019.720p.BluRay.x264-UNiVERSUM", Description = "The German is hardcoded not to match")]
[TestCase("Movie Name (2016) BluRay 1080p DTS-ES AC3 x264-3Li", Description = "DTS-ES should not match ES (Spanish)")]
public void should_not_parse_wrong_language_in_title(string postTitle)
{
var parsed = Parser.Parser.ParseMovieTitle(postTitle, true);
Expand Down
10 changes: 8 additions & 2 deletions src/NzbDrone.Core/Parser/LanguageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ public static class LanguageParser
private static readonly Regex CaseSensitiveLanguageRegex = new Regex(@"(?:(?i)(?<!SUB[\W|_|^]))(?:(?<lithuanian>\bLT\b)|
(?<czech>\bCZ\b)|
(?<polish>\bPL\b)|
(?<bulgarian>\bBG\b))(?:(?i)(?![\W|_|^]SUB))|
(?<slovak>\bSK\b)",
(?<bulgarian>\bBG\b)|
(?<slovak>\bSK\b)|
(?<spanish>\b(?<!DTS[._ -])ES\b))(?:(?i)(?![\W|_|^]SUB))",
RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace);

private static readonly Regex GermanDualLanguageRegex = new (@"(?<!WEB[-_. ]?)\bDL\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
Expand Down Expand Up @@ -261,6 +262,11 @@ public static List<Language> ParseLanguages(string title)
{
languages.Add(Language.Slovak);
}

if (match.Groups["spanish"].Captures.Any())
{
languages.Add(Language.Spanish);
}
}

var matches = LanguageRegex.Matches(title);
Expand Down

0 comments on commit 0761e27

Please sign in to comment.