Simplify release titles before applying scene naming exception regex filter

This commit is contained in:
Taloth Saldono 2021-05-07 20:17:05 +02:00
parent 87f10bf7bb
commit bcdbadbede
2 changed files with 29 additions and 1 deletions

View File

@ -231,7 +231,9 @@ namespace NzbDrone.Core.DataAugmentation.Scene
return normalCandidates; return normalCandidates;
} }
filteredCandidates = filteredCandidates.Where(v => Regex.IsMatch(releaseTitle, v.FilterRegex)).ToList(); var simpleTitle = Parser.Parser.SimplifyTitle(releaseTitle);
filteredCandidates = filteredCandidates.Where(v => Regex.IsMatch(simpleTitle, v.FilterRegex)).ToList();
if (filteredCandidates.Any()) if (filteredCandidates.Any())
{ {

View File

@ -469,6 +469,32 @@ namespace NzbDrone.Core.Parser
return result; return result;
} }
public static string SimplifyTitle(string title)
{
if (!ValidateBeforeParsing(title)) return title;
Logger.Debug("Parsing string '{0}'", title);
if (ReversedTitleRegex.IsMatch(title))
{
var titleWithoutExtension = RemoveFileExtension(title).ToCharArray();
Array.Reverse(titleWithoutExtension);
title = new string(titleWithoutExtension) + title.Substring(titleWithoutExtension.Length);
Logger.Debug("Reversed name detected. Converted to '{0}'", title);
}
var simpleTitle = title;
simpleTitle = WebsitePrefixRegex.Replace(simpleTitle);
simpleTitle = WebsitePostfixRegex.Replace(simpleTitle);
simpleTitle = CleanTorrentSuffixRegex.Replace(simpleTitle);
return simpleTitle;
}
public static ParsedEpisodeInfo ParseTitle(string title) public static ParsedEpisodeInfo ParseTitle(string title)
{ {
try try