From d37fac5343d847ca40d98b04ae484d4a5681b02b Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 20 Nov 2022 12:12:07 -0600 Subject: [PATCH] Add PreSubstitutionRegex Capabilities Fixes #7389 --- src/NzbDrone.Core/Parser/Parser.cs | 11 +++++++++++ src/NzbDrone.Core/Parser/RegexReplace.cs | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index d979c32ce..91d241649 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -18,6 +18,8 @@ namespace NzbDrone.Core.Parser private static readonly Regex ReportEditionRegex = new Regex(@"^.+?" + EditionRegex, RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly RegexReplace[] PreSubstitutionRegex = Array.Empty(); + private static readonly Regex[] ReportMovieTitleRegex = new[] { //Anime [Subgroup] and Year @@ -220,6 +222,15 @@ namespace NzbDrone.Core.Parser releaseTitle = releaseTitle.Replace("【", "[").Replace("】", "]"); + foreach (var replace in PreSubstitutionRegex) + { + if (replace.TryReplace(ref releaseTitle)) + { + Logger.Trace($"Replace regex: {replace}"); + Logger.Debug("Substituted with " + releaseTitle); + } + } + var simpleTitle = SimpleTitleRegex.Replace(releaseTitle); // TODO: Quick fix stripping [url] - prefixes. diff --git a/src/NzbDrone.Core/Parser/RegexReplace.cs b/src/NzbDrone.Core/Parser/RegexReplace.cs index 40ff075ce..456eefca0 100644 --- a/src/NzbDrone.Core/Parser/RegexReplace.cs +++ b/src/NzbDrone.Core/Parser/RegexReplace.cs @@ -1,4 +1,4 @@ -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; namespace NzbDrone.Core.Parser { @@ -46,5 +46,10 @@ namespace NzbDrone.Core.Parser return result; } + + public override string ToString() + { + return _regex.ToString(); + } } }