1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

New: Better Polish language Release Parsing (#5592)

* Parse Polish language

* Tests for parsing Polish language
This commit is contained in:
tenshiak 2020-12-31 04:50:45 +01:00 committed by GitHub
parent 1c58e26183
commit 4bac44e893
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -158,6 +158,14 @@ public void should_parse_language_brazilian_portuguese(string postTitle)
} }
[TestCase("Pulp.Fiction.1994.Polish.1080p.XviD-LOL")] [TestCase("Pulp.Fiction.1994.Polish.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.PL.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.PLDUB.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.DUBPL.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.PL-DUB.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.DUB-PL.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.PLLEK.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.LEKPL.1080p.XviD-LOL")]
[TestCase("Pulp.Fiction.1994.PL-LEK.1080p.XviD-LOL")]
public void should_parse_language_polish(string postTitle) public void should_parse_language_polish(string postTitle)
{ {
var result = Parser.Parser.ParseMovieTitle(postTitle, true); var result = Parser.Parser.ParseMovieTitle(postTitle, true);

View File

@ -14,10 +14,10 @@ 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>\b(?:german|videomann|ger)\b)|(?<flemish>flemish)|(?<bulgarian>bgaudio)|(?<brazilian>dublado)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR|VO|VFF|VFQ|VFI|VF2|TRUEFRENCH)(?:\W|_))|(?<russian>\brus\b)|(?<english>\beng\b)|(?<hungarian>\b(?:HUNDUB|HUN)\b)|(?<hebrew>\bHebDub\b)|(?<chinese>\[(?:CH[ST]|BIG5|GB)\]|简|繁|字幕)", private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_|^)(?<italian>\b(?:ita|italian)\b)|(?<german>\b(?:german|videomann|ger)\b)|(?<flemish>flemish)|(?<bulgarian>bgaudio)|(?<brazilian>dublado)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR|VO|VFF|VFQ|VFI|VF2|TRUEFRENCH)(?:\W|_))|(?<russian>\brus\b)|(?<english>\beng\b)|(?<hungarian>\b(?:HUNDUB|HUN)\b)|(?<hebrew>\bHebDub\b)|(?<polish>\b(?:PL\W?DUB|DUB\W?PL|LEK\W?PL|PL\W?LEK)\b)|(?<chinese>\[(?:CH[ST]|BIG5|GB)\]|简|繁|字幕)",
RegexOptions.IgnoreCase | RegexOptions.Compiled); RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex CaseSensitiveLanguageRegex = new Regex(@"(?<lithuanian>\bLT\b)|(?<czech>\bCZ\b)", private static readonly Regex CaseSensitiveLanguageRegex = new Regex(@"(?<lithuanian>\bLT\b)|(?<czech>\bCZ\b)|(?<polish>\bPL\b)",
RegexOptions.Compiled); RegexOptions.Compiled);
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);
@ -155,6 +155,11 @@ public static List<Language> ParseLanguages(string title)
languages.Add(Language.Czech); languages.Add(Language.Czech);
} }
if (caseSensitiveMatch.Groups["polish"].Captures.Cast<Capture>().Any())
{
languages.Add(Language.Polish);
}
var matches = LanguageRegex.Matches(title); var matches = LanguageRegex.Matches(title);
foreach (Match match in matches) foreach (Match match in matches)
@ -219,6 +224,11 @@ public static List<Language> ParseLanguages(string title)
languages.Add(Language.Hebrew); languages.Add(Language.Hebrew);
} }
if (match.Groups["polish"].Success)
{
languages.Add(Language.Polish);
}
if (match.Groups["chinese"].Success) if (match.Groups["chinese"].Success)
{ {
languages.Add(Language.Chinese); languages.Add(Language.Chinese);