mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-22 22:15:17 -04:00
New: Correctly parse German DL and ML tags in releases
This commit is contained in:
committed by
Qstick
parent
213c55c7af
commit
74cfc94b4c
@@ -42,6 +42,9 @@ namespace NzbDrone.Core.Parser
|
||||
(?<slovak>\bSK\b)",
|
||||
RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace);
|
||||
|
||||
private static readonly Regex GermanDualLanguageRegex = new (@"(?<!WEB[-_. ]?)\bDL\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex GermanMultiLanguageRegex = new (@"\bML\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
private static readonly Regex SubtitleLanguageRegex = new Regex(".+?[-_. ](?<iso_code>[a-z]{2,3})([-_. ](?<tags>full|forced|foreign|default|cc|psdh|sdh))*$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
public static List<Language> ParseLanguages(string title)
|
||||
@@ -220,31 +223,31 @@ namespace NzbDrone.Core.Parser
|
||||
}
|
||||
|
||||
// Case sensitive
|
||||
var caseSensitiveMatchs = CaseSensitiveLanguageRegex.Matches(title);
|
||||
var caseSensitiveMatches = CaseSensitiveLanguageRegex.Matches(title);
|
||||
|
||||
foreach (Match match in caseSensitiveMatchs)
|
||||
foreach (Match match in caseSensitiveMatches)
|
||||
{
|
||||
if (match.Groups["lithuanian"].Captures.Cast<Capture>().Any())
|
||||
if (match.Groups["lithuanian"].Captures.Any())
|
||||
{
|
||||
languages.Add(Language.Lithuanian);
|
||||
}
|
||||
|
||||
if (match.Groups["czech"].Captures.Cast<Capture>().Any())
|
||||
if (match.Groups["czech"].Captures.Any())
|
||||
{
|
||||
languages.Add(Language.Czech);
|
||||
}
|
||||
|
||||
if (match.Groups["polish"].Captures.Cast<Capture>().Any())
|
||||
if (match.Groups["polish"].Captures.Any())
|
||||
{
|
||||
languages.Add(Language.Polish);
|
||||
}
|
||||
|
||||
if (match.Groups["bulgarian"].Captures.Cast<Capture>().Any())
|
||||
if (match.Groups["bulgarian"].Captures.Any())
|
||||
{
|
||||
languages.Add(Language.Bulgarian);
|
||||
}
|
||||
|
||||
if (match.Groups["slovak"].Captures.Cast<Capture>().Any())
|
||||
if (match.Groups["slovak"].Captures.Any())
|
||||
{
|
||||
languages.Add(Language.Slovak);
|
||||
}
|
||||
@@ -254,22 +257,22 @@ namespace NzbDrone.Core.Parser
|
||||
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
if (match.Groups["italian"].Captures.Cast<Capture>().Any())
|
||||
if (match.Groups["italian"].Captures.Any())
|
||||
{
|
||||
languages.Add(Language.Italian);
|
||||
}
|
||||
|
||||
if (match.Groups["german"].Captures.Cast<Capture>().Any())
|
||||
if (match.Groups["german"].Captures.Any())
|
||||
{
|
||||
languages.Add(Language.German);
|
||||
}
|
||||
|
||||
if (match.Groups["flemish"].Captures.Cast<Capture>().Any())
|
||||
if (match.Groups["flemish"].Captures.Any())
|
||||
{
|
||||
languages.Add(Language.Flemish);
|
||||
}
|
||||
|
||||
if (match.Groups["greek"].Captures.Cast<Capture>().Any())
|
||||
if (match.Groups["greek"].Captures.Any())
|
||||
{
|
||||
languages.Add(Language.Greek);
|
||||
}
|
||||
@@ -360,6 +363,21 @@ namespace NzbDrone.Core.Parser
|
||||
languages.Add(Language.Unknown);
|
||||
}
|
||||
|
||||
if (languages.Count == 1 && languages.Single() == Language.German)
|
||||
{
|
||||
if (GermanDualLanguageRegex.IsMatch(title))
|
||||
{
|
||||
Logger.Trace("Adding original language because the release title contains German DL tag");
|
||||
languages.Add(Language.Original);
|
||||
}
|
||||
else if (GermanMultiLanguageRegex.IsMatch(title))
|
||||
{
|
||||
Logger.Trace("Adding original language and English because the release title contains German ML tag");
|
||||
languages.Add(Language.Original);
|
||||
languages.Add(Language.English);
|
||||
}
|
||||
}
|
||||
|
||||
return languages.DistinctBy(l => (int)l).ToList();
|
||||
}
|
||||
|
||||
@@ -369,7 +387,7 @@ namespace NzbDrone.Core.Parser
|
||||
{
|
||||
var simpleFilename = Path.GetFileNameWithoutExtension(fileName);
|
||||
var match = SubtitleLanguageRegex.Match(simpleFilename);
|
||||
var languageTags = match.Groups["tags"].Captures.Cast<Capture>()
|
||||
var languageTags = match.Groups["tags"].Captures
|
||||
.Where(tag => !tag.Value.Empty())
|
||||
.Select(tag => tag.Value.ToLower());
|
||||
return languageTags.ToList();
|
||||
|
||||
Reference in New Issue
Block a user