|
|
@ -14,11 +14,27 @@ namespace NzbDrone.Core.Parser
|
|
|
|
{
|
|
|
|
{
|
|
|
|
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|ger[. ]dub)|(?<flemish>flemish)|(?<bulgarian>bgaudio)|(?<brazilian>dublado)|(?<greek>greek)|(?<french>\b(?:FR|VO|VFF|VFQ|VFI|VF2|TRUEFRENCH|FRE|FRA)\b)|(?<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)\]|简|繁|字幕)",
|
|
|
|
private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_|^)(?<italian>\b(?:ita|italian)\b)|
|
|
|
|
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
|
|
|
(?<german>german\b|videomann|ger[. ]dub)|
|
|
|
|
|
|
|
|
(?<flemish>flemish)|
|
|
|
|
private static readonly Regex CaseSensitiveLanguageRegex = new Regex(@"(?:(?i)(?<!SUB[\W|_|^]))(?:(?<lithuanian>\bLT\b)|(?<czech>\bCZ\b)|(?<polish>\bPL\b))(?:(?i)(?![\W|_|^]SUB))",
|
|
|
|
(?<bulgarian>bgaudio)|
|
|
|
|
RegexOptions.Compiled);
|
|
|
|
(?<brazilian>dublado)|
|
|
|
|
|
|
|
|
(?<greek>greek)|
|
|
|
|
|
|
|
|
(?<french>\b(?:FR|VO|VFF|VFQ|VFI|VF2|TRUEFRENCH|FRE|FRA)\b)|
|
|
|
|
|
|
|
|
(?<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)\]|简|繁|字幕)|
|
|
|
|
|
|
|
|
(?<ukrainian>(?:(?:\dx)?UKR))",
|
|
|
|
|
|
|
|
RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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))",
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
@ -147,6 +163,21 @@ namespace NzbDrone.Core.Parser
|
|
|
|
languages.Add(Language.Hebrew);
|
|
|
|
languages.Add(Language.Hebrew);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (lowerTitle.Contains("ukrainian"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
languages.Add(Language.Ukrainian);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (lowerTitle.Contains("persian"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
languages.Add(Language.Persian);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (lowerTitle.Contains("bengali"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
languages.Add(Language.Bengali);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Case sensitive
|
|
|
|
// Case sensitive
|
|
|
|
var caseSensitiveMatch = CaseSensitiveLanguageRegex.Match(title);
|
|
|
|
var caseSensitiveMatch = CaseSensitiveLanguageRegex.Match(title);
|
|
|
|
|
|
|
|
|
|
|
@ -165,6 +196,11 @@ namespace NzbDrone.Core.Parser
|
|
|
|
languages.Add(Language.Polish);
|
|
|
|
languages.Add(Language.Polish);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (caseSensitiveMatch.Groups["bulgarian"].Captures.Cast<Capture>().Any())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
languages.Add(Language.Bulgarian);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var matches = LanguageRegex.Matches(title);
|
|
|
|
var matches = LanguageRegex.Matches(title);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (Match match in matches)
|
|
|
|
foreach (Match match in matches)
|
|
|
@ -238,6 +274,11 @@ namespace NzbDrone.Core.Parser
|
|
|
|
{
|
|
|
|
{
|
|
|
|
languages.Add(Language.Chinese);
|
|
|
|
languages.Add(Language.Chinese);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (match.Groups["ukrainian"].Success)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
languages.Add(Language.Ukrainian);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (title.ToLower().Contains("multi"))
|
|
|
|
if (title.ToLower().Contains("multi"))
|
|
|
|