mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-22 22:14:44 -04:00
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:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user