From 781e0c9d1c607ed35dd1595e929bf2a2e5009863 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 26 Oct 2024 14:32:33 +0300 Subject: [PATCH] Fixed: Optional square and round brackets for "{Release Year}" --- src/NzbDrone.Core/Organizer/FileNameBuilder.cs | 2 +- .../ApiTests/NamingConfigFixture.cs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index b499da390..1e865b543 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -41,7 +41,7 @@ public class FileNameBuilder : IBuildFileNames private static readonly Regex TitleRegex = new Regex(@"(?\{(?:imdb-|edition-))?\{(?[- ._\[(]*)(?(?:[a-z0-9]+)(?:(?[- ._]+)(?:[a-z0-9]+))?)(?::(?[ ,a-z0-9|+-]+(?[-} ._)\]]*)\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); - public static readonly Regex ReleaseYearRegex = new Regex(@"\{Release[- ._]Year\}", RegexOptions.Compiled | RegexOptions.IgnoreCase); + public static readonly Regex ReleaseYearRegex = new Regex(@"\{[\[\(]?Release[- ._]Year[\]\)]?\}", RegexOptions.Compiled | RegexOptions.IgnoreCase); public static readonly Regex MovieTitleRegex = new Regex(@"(?\{(?:Movie)(?[- ._])(?:Clean)?(?:OriginalTitle|Title(?:The)?)(?::(?[a-z0-9|-]+))?\})", RegexOptions.Compiled | RegexOptions.IgnoreCase); diff --git a/src/NzbDrone.Integration.Test/ApiTests/NamingConfigFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/NamingConfigFixture.cs index 47c0e8203..fb85bbacf 100644 --- a/src/NzbDrone.Integration.Test/ApiTests/NamingConfigFixture.cs +++ b/src/NzbDrone.Integration.Test/ApiTests/NamingConfigFixture.cs @@ -20,12 +20,14 @@ public void should_be_able_to_get_by_id() NamingConfig.Get(config.Id).Id.Should().Be(config.Id); } - [Test] - public void should_be_able_to_update() + [TestCase("{Movie Title} {Release Year}")] + [TestCase("{Movie Title} {(Release Year)}")] + [TestCase("{Movie Title} {[Release Year]}")] + public void should_be_able_to_update(string standardMovieFormat) { var config = NamingConfig.GetSingle(); config.RenameMovies = false; - config.StandardMovieFormat = "{Movie Title} {Release Year}"; + config.StandardMovieFormat = standardMovieFormat; var result = NamingConfig.Put(config); result.RenameMovies.Should().BeFalse();