mirror of https://github.com/Sonarr/Sonarr
New: Bulgarian Language
This commit is contained in:
parent
3bbec2ff5d
commit
57e3bd8b4d
|
@ -247,6 +247,15 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||||
result.Language.Id.Should().Be(Language.Hindi.Id);
|
result.Language.Id.Should().Be(Language.Hindi.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase("Title.the.Series.2009.S01E14.Bulgarian.HDTV.XviD-LOL")]
|
||||||
|
[TestCase("Title.the.Series.2009.S01E14.BGAUDIO.HDTV.XviD-LOL")]
|
||||||
|
[TestCase("Title.the.Series.2009.S01E14.BG.AUDIO.HDTV.XviD-LOL")]
|
||||||
|
public void should_parse_language_bulgarian(string postTitle)
|
||||||
|
{
|
||||||
|
var result = Parser.Parser.ParseTitle(postTitle);
|
||||||
|
result.Language.Id.Should().Be(Language.Bulgarian.Id);
|
||||||
|
}
|
||||||
|
|
||||||
[TestCase("Title.the.Russian.Series.S01E07.Cold.Action.HDTV.XviD-Droned")]
|
[TestCase("Title.the.Russian.Series.S01E07.Cold.Action.HDTV.XviD-Droned")]
|
||||||
[TestCase("Title.the.Russian.Series.S01E07E08.Cold.Action.HDTV.XviD-Droned")]
|
[TestCase("Title.the.Russian.Series.S01E07E08.Cold.Action.HDTV.XviD-Droned")]
|
||||||
[TestCase("Title.the.Russian.Series.S01.1080p.WEBRip.DDP5.1.x264-Drone")]
|
[TestCase("Title.the.Russian.Series.S01.1080p.WEBRip.DDP5.1.x264-Drone")]
|
||||||
|
|
|
@ -83,6 +83,7 @@ namespace NzbDrone.Core.Languages
|
||||||
public static Language Czech { get { return new Language(25, "Czech"); } }
|
public static Language Czech { get { return new Language(25, "Czech"); } }
|
||||||
public static Language Arabic { get { return new Language(26, "Arabic"); } }
|
public static Language Arabic { get { return new Language(26, "Arabic"); } }
|
||||||
public static Language Hindi { get { return new Language(27, "Hindi"); } }
|
public static Language Hindi { get { return new Language(27, "Hindi"); } }
|
||||||
|
public static Language Bulgarian { get { return new Language(28, "Bulgarian"); } }
|
||||||
|
|
||||||
|
|
||||||
public static List<Language> All
|
public static List<Language> All
|
||||||
|
@ -118,7 +119,8 @@ namespace NzbDrone.Core.Languages
|
||||||
Lithuanian,
|
Lithuanian,
|
||||||
Czech,
|
Czech,
|
||||||
Arabic,
|
Arabic,
|
||||||
Hindi
|
Hindi,
|
||||||
|
Bulgarian
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,4 +161,4 @@ namespace NzbDrone.Core.Languages
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,8 @@ namespace NzbDrone.Core.Parser
|
||||||
new IsoLanguage("lt", "lit", Language.Lithuanian),
|
new IsoLanguage("lt", "lit", Language.Lithuanian),
|
||||||
new IsoLanguage("cs", "ces", Language.Czech),
|
new IsoLanguage("cs", "ces", Language.Czech),
|
||||||
new IsoLanguage("ar", "ara", Language.Arabic),
|
new IsoLanguage("ar", "ara", Language.Arabic),
|
||||||
new IsoLanguage("hi", "hin", Language.Hindi)
|
new IsoLanguage("hi", "hin", Language.Hindi),
|
||||||
|
new IsoLanguage("bg", "bul", Language.Bulgarian)
|
||||||
};
|
};
|
||||||
|
|
||||||
public static IsoLanguage Find(string isoCode)
|
public static IsoLanguage Find(string isoCode)
|
||||||
|
|
|
@ -17,10 +17,10 @@ namespace NzbDrone.Core.Parser
|
||||||
new RegexReplace(@".*?[_. ](S\d{2}(?:E\d{2,4})*[_. ].*)", "$1", RegexOptions.Compiled | RegexOptions.IgnoreCase)
|
new RegexReplace(@".*?[_. ](S\d{2}(?:E\d{2,4})*[_. ].*)", "$1", RegexOptions.Compiled | RegexOptions.IgnoreCase)
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?<italian>\b(?:ita|italian)\b)|(?<german>german\b|videomann)|(?<flemish>flemish)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR)(?:\W|_))|(?<russian>\brus\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)|(?<german>german\b|videomann)|(?<flemish>flemish)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR)(?:\W|_))|(?<russian>\brus\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)\]|简|繁|字幕)|(?<bulgarian>\bbgaudio\b)",
|
||||||
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
|
|
||||||
private static readonly Regex CaseSensitiveLanguageRegex = new Regex(@"(?<lithuanian>\bLT\b)|(?<czech>\bCZ\b)|(?<polish>\bPL\b)",
|
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.Compiled);
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,6 +96,9 @@ namespace NzbDrone.Core.Parser
|
||||||
if (lowerTitle.Contains("hindi"))
|
if (lowerTitle.Contains("hindi"))
|
||||||
return Language.Hindi;
|
return Language.Hindi;
|
||||||
|
|
||||||
|
if (lowerTitle.Contains("bulgarian"))
|
||||||
|
return Language.Bulgarian;
|
||||||
|
|
||||||
var regexLanguage = RegexLanguage(title);
|
var regexLanguage = RegexLanguage(title);
|
||||||
|
|
||||||
if (regexLanguage != Language.Unknown)
|
if (regexLanguage != Language.Unknown)
|
||||||
|
@ -158,6 +161,9 @@ namespace NzbDrone.Core.Parser
|
||||||
if (caseSensitiveMatch.Groups["polish"].Captures.Cast<Capture>().Any())
|
if (caseSensitiveMatch.Groups["polish"].Captures.Cast<Capture>().Any())
|
||||||
return Language.Polish;
|
return Language.Polish;
|
||||||
|
|
||||||
|
if (caseSensitiveMatch.Groups["bulgarian"].Captures.Cast<Capture>().Any())
|
||||||
|
return Language.Bulgarian;
|
||||||
|
|
||||||
// Case insensitive
|
// Case insensitive
|
||||||
var match = LanguageRegex.Match(title);
|
var match = LanguageRegex.Match(title);
|
||||||
|
|
||||||
|
@ -194,6 +200,9 @@ namespace NzbDrone.Core.Parser
|
||||||
if (match.Groups["chinese"].Success)
|
if (match.Groups["chinese"].Success)
|
||||||
return Language.Chinese;
|
return Language.Chinese;
|
||||||
|
|
||||||
|
if (match.Groups["bulgarian"].Success)
|
||||||
|
return Language.Bulgarian;
|
||||||
|
|
||||||
return Language.Unknown;
|
return Language.Unknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue