mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-24 16:51:58 +00:00
parent
25493654ff
commit
4faf7ed959
3 changed files with 12 additions and 2 deletions
|
@ -43,6 +43,9 @@ public class LanguageParserFixture : CoreTest
|
|||
[TestCase("Constantine.2014.S01E01.WEBRiP.H264.AAC.5.1-NL.SUBS", Language.Dutch)]
|
||||
[TestCase("Elementary - S02E16 - Kampfhaehne - mkv - by Videomann", Language.German)]
|
||||
[TestCase("Two.Greedy.Italians.S01E01.The.Family.720p.HDTV.x264-FTP", Language.English)]
|
||||
[TestCase("Castle.2009.S01E14.HDTV.XviD.HUNDUB-LOL", Language.Hungarian)]
|
||||
[TestCase("Castle.2009.S01E14.HDTV.XviD.ENG.HUN-LOL", Language.Hungarian)]
|
||||
[TestCase("Castle.2009.S01E14.HDTV.XviD.HUN-LOL", Language.Hungarian)]
|
||||
public void should_parse_language(string postTitle, Language language)
|
||||
{
|
||||
var result = Parser.Parser.ParseTitle(postTitle);
|
||||
|
|
|
@ -23,6 +23,7 @@ public enum Language
|
|||
Portuguese = 18,
|
||||
Flemish = 19,
|
||||
Greek = 20,
|
||||
Korean = 21
|
||||
Korean = 21,
|
||||
Hungarian = 22
|
||||
}
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ public static class Parser
|
|||
private static readonly Regex AnimeReleaseGroupRegex = new Regex(@"^(?:\[(?<subgroup>(?!\s).+?(?<!\s))\](?:_|-|\s|\.)?)",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?<italian>\b(?:ita|italian)\b)|(?<german>german\b|videomann)|(?<flemish>flemish)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR|VOSTFR)(?:\W|_))|(?<russian>\brus\b)|(?<dutch>nl\W?subs?)",
|
||||
private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?<italian>\b(?:ita|italian)\b)|(?<german>german\b|videomann)|(?<flemish>flemish)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR|VOSTFR)(?:\W|_))|(?<russian>\brus\b)|(?<dutch>nl\W?subs?)|(?<hungarian>\b(?:HUNDUB|HUN)\b)",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
private static readonly Regex YearInTitleRegex = new Regex(@"^(?<title>.+?)(?:\W|_)?(?<year>\d{4})",
|
||||
|
@ -498,6 +498,9 @@ public static Language ParseLanguage(string title)
|
|||
if (lowerTitle.Contains("portuguese"))
|
||||
return Language.Portuguese;
|
||||
|
||||
if (lowerTitle.Contains("hungarian"))
|
||||
return Language.Hungarian;
|
||||
|
||||
var match = LanguageRegex.Match(title);
|
||||
|
||||
if (match.Groups["italian"].Captures.Cast<Capture>().Any())
|
||||
|
@ -521,6 +524,9 @@ public static Language ParseLanguage(string title)
|
|||
if (match.Groups["dutch"].Success)
|
||||
return Language.Dutch;
|
||||
|
||||
if (match.Groups["hungarian"].Success)
|
||||
return Language.Hungarian;
|
||||
|
||||
return Language.English;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue