mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
Fixed: Better language parsing of releases
#ND-120 fixed
This commit is contained in:
parent
2235b83809
commit
c738a32162
3 changed files with 23 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
@ -85,6 +85,8 @@ namespace NzbDrone.Core
|
|||
|
||||
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 @@ namespace NzbDrone.Core
|
|||
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 @@ namespace NzbDrone.Core
|
|||
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…
Add table
Add a link
Reference in a new issue