Merge branch 'special-episode-search' of https://github.com/iaddis/NzbDrone into special-episode-search

Conflicts:
	src/NzbDrone.Core/Indexers/Omgwtfnzbs/Omgwtfnzbs.cs
This commit is contained in:
Mark McDowall
2014-02-19 23:23:20 -08:00
17 changed files with 258 additions and 4 deletions
+17
View File
@@ -114,6 +114,14 @@ namespace NzbDrone.Core.Parser
private static readonly Regex YearInTitleRegex = new Regex(@"^(?<title>.+?)(?:\W|_)?(?<year>\d{4})",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex WordDelimiterRegex = new Regex(@"(\s|\.|,|_|-|=|\|)+", RegexOptions.Compiled);
private static readonly Regex PunctuationRegex = new Regex(@"[^\w\s]", RegexOptions.Compiled);
private static readonly Regex CommonWordRegex = new Regex(@"\b(a|an|the|and|or|of)\b\s?",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex SpecialEpisodeWordRegex = new Regex(@"\b(part|special|edition)\b\s?",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
public static ParsedEpisodeInfo ParsePath(string path)
{
var fileInfo = new FileInfo(path);
@@ -219,6 +227,15 @@ namespace NzbDrone.Core.Parser
return MultiPartCleanupRegex.Replace(title, string.Empty).Trim();
}
public static string NormalizeEpisodeTitle(string title)
{
string singleSpaces = WordDelimiterRegex.Replace(title, " ");
string noPunctuation = PunctuationRegex.Replace(singleSpaces, String.Empty);
string noCommonWords = CommonWordRegex.Replace(noPunctuation, String.Empty);
string normalized = SpecialEpisodeWordRegex.Replace(noCommonWords, String.Empty);
return normalized.Trim().ToLower();
}
public static string ParseReleaseGroup(string title)
{
const string defaultReleaseGroup = "DRONE";