Fixed: Better language parsing of releases

#ND-120 fixed
pull/6/head
Mark McDowall 12 years ago
parent 2235b83809
commit c738a32162

@ -319,6 +319,9 @@ namespace NzbDrone.Core.Test.ParserFixture
[TestCase("Castle.2009.S01E14.Turkish.HDTV.XviD-LOL", LanguageType.Turkish)] [TestCase("Castle.2009.S01E14.Turkish.HDTV.XviD-LOL", LanguageType.Turkish)]
[TestCase("Castle.2009.S01E14.Portuguese.HDTV.XviD-LOL", LanguageType.Portuguese)] [TestCase("Castle.2009.S01E14.Portuguese.HDTV.XviD-LOL", LanguageType.Portuguese)]
[TestCase("Castle.2009.S01E14.HDTV.XviD-LOL", LanguageType.English)] [TestCase("Castle.2009.S01E14.HDTV.XviD-LOL", LanguageType.English)]
[TestCase("person.of.interest.1x19.ita.720p.bdmux.x264-novarip", LanguageType.Italian)]
[TestCase("Salamander.S01E01.FLEMISH.HDTV.x264-BRiGAND", LanguageType.Flemish)]
[TestCase("H.Polukatoikia.S03E13.Greek.PDTV.XviD-Ouzo", LanguageType.Greek)]
public void parse_language(string postTitle, LanguageType language) public void parse_language(string postTitle, LanguageType language)
{ {
var result = Parser.ParseLanguage(postTitle); var result = Parser.ParseLanguage(postTitle);

@ -20,6 +20,8 @@
Norwegian = 15, Norwegian = 15,
Finnish = 16, Finnish = 16,
Turkish = 17, Turkish = 17,
Portuguese = 18 Portuguese = 18,
Flemish = 19,
Greek = 20
} }
} }

@ -1,4 +1,4 @@
using System;  using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
@ -85,6 +85,8 @@ namespace NzbDrone.Core
private static readonly Regex MultiPartCleanupRegex = new Regex(@"\(\d+\)$", RegexOptions.Compiled); private static readonly Regex MultiPartCleanupRegex = new Regex(@"\(\d+\)$", RegexOptions.Compiled);
private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?<italian>ita|italian)|(?<german>german\b)|(?<flemish>flemish)|(?<greek>greek)(?:\W|_)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
internal static EpisodeParseResult ParsePath(string path) internal static EpisodeParseResult ParsePath(string path)
{ {
var fileInfo = new FileInfo(path); var fileInfo = new FileInfo(path);
@ -388,16 +390,6 @@ namespace NzbDrone.Core
if (lowerTitle.Contains("spanish")) if (lowerTitle.Contains("spanish"))
return LanguageType.Spanish; return LanguageType.Spanish;
if (lowerTitle.Contains("german"))
{
//Make sure it doesn't contain Germany (Since we're not using REGEX for all this)
if (!lowerTitle.Contains("germany"))
return LanguageType.German;
}
if (lowerTitle.Contains("italian"))
return LanguageType.Italian;
if (lowerTitle.Contains("danish")) if (lowerTitle.Contains("danish"))
return LanguageType.Danish; return LanguageType.Danish;
@ -440,6 +432,20 @@ namespace NzbDrone.Core
if (lowerTitle.Contains("portuguese")) if (lowerTitle.Contains("portuguese"))
return LanguageType.Portuguese; return LanguageType.Portuguese;
var match = LanguageRegex.Match(title);
if (match.Groups["italian"].Captures.Cast<Capture>().Any())
return LanguageType.Italian;
if (match.Groups["german"].Captures.Cast<Capture>().Any())
return LanguageType.German;
if (match.Groups["flemish"].Captures.Cast<Capture>().Any())
return LanguageType.Flemish;
if (match.Groups["greek"].Captures.Cast<Capture>().Any())
return LanguageType.Greek;
return LanguageType.English; return LanguageType.English;
} }

Loading…
Cancel
Save