mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Fixed: Better language parsing of releases
#ND-120 fixed
This commit is contained in:
parent
2235b83809
commit
c738a32162
@ -319,6 +319,9 @@ public void parse_series_name(string postTitle, string title)
|
||||
[TestCase("Castle.2009.S01E14.Turkish.HDTV.XviD-LOL", LanguageType.Turkish)]
|
||||
[TestCase("Castle.2009.S01E14.Portuguese.HDTV.XviD-LOL", LanguageType.Portuguese)]
|
||||
[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)
|
||||
{
|
||||
var result = Parser.ParseLanguage(postTitle);
|
||||
|
@ -20,6 +20,8 @@ public enum LanguageType
|
||||
Norwegian = 15,
|
||||
Finnish = 16,
|
||||
Turkish = 17,
|
||||
Portuguese = 18
|
||||
Portuguese = 18,
|
||||
Flemish = 19,
|
||||
Greek = 20
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
@ -85,6 +85,8 @@ public static class Parser
|
||||
|
||||
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)
|
||||
{
|
||||
var fileInfo = new FileInfo(path);
|
||||
@ -388,16 +390,6 @@ internal static LanguageType ParseLanguage(string title)
|
||||
if (lowerTitle.Contains("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"))
|
||||
return LanguageType.Danish;
|
||||
|
||||
@ -440,6 +432,20 @@ internal static LanguageType ParseLanguage(string title)
|
||||
if (lowerTitle.Contains("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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user