From 35396ea44edd10d96915f9c31d1537bef9705406 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 21 Oct 2014 07:14:51 -0700 Subject: [PATCH] Fixed: Duplicate multi-episode style with trailing brackets Only dashes, underscores, periods and spaces will be considered separators --- .../OrganizerTests/FileNameBuilderFixture.cs | 11 +++++++++++ src/NzbDrone.Core/Organizer/FileNameBuilder.cs | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderFixture.cs index f12f3808b..58ee85c4a 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderFixture.cs @@ -628,5 +628,16 @@ namespace NzbDrone.Core.Test.OrganizerTests Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) .Should().Be(String.Empty); } + + [Test] + public void should_get_proper_filename_when_multi_episode_is_duplicated_and_bracket_follows_pattern() + { + _namingConfig.StandardEpisodeFormat = + "{Series Title} - S{season:00}E{episode:00} - ({Quality Title}, {MediaInfo Full}, {Release Group}) - {Episode Title}"; + _namingConfig.MultiEpisodeStyle = (int) MultiEpisodeStyle.Duplicate; + + Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) + .Should().Be("South Park - S15E06 - S15E07 - (HDTV-720p, , DRONE) - City Sushi"); + } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index 1229267cf..a94fe43f0 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -42,15 +42,15 @@ namespace NzbDrone.Core.Organizer private static readonly Regex AbsoluteEpisodeRegex = new Regex(@"(?\{absolute(?:\:0+)?})", RegexOptions.Compiled | RegexOptions.IgnoreCase); - public static readonly Regex SeasonEpisodePatternRegex = new Regex(@"(?(?<=}).+?)?(?s?{season(?:\:0+)?}(?e|x)(?{episode(?:\:0+)?}))(?.+?(?={))?", + public static readonly Regex SeasonEpisodePatternRegex = new Regex(@"(?(?<=})[- ._]+?)?(?s?{season(?:\:0+)?}(?e|x)(?{episode(?:\:0+)?}))(?[- ._]+?(?={))?", RegexOptions.Compiled | RegexOptions.IgnoreCase); - public static readonly Regex AbsoluteEpisodePatternRegex = new Regex(@"(?(?<=}).+?)?(?{absolute(?:\:0+)?})(?.+?(?={))?", + public static readonly Regex AbsoluteEpisodePatternRegex = new Regex(@"(?(?<=})[- ._]+?)?(?{absolute(?:\:0+)?})(?[- ._]+?(?={))?", RegexOptions.Compiled | RegexOptions.IgnoreCase); public static readonly Regex AirDateRegex = new Regex(@"\{Air(\s|\W|_)Date\}", RegexOptions.Compiled | RegexOptions.IgnoreCase); - public static readonly Regex SeriesTitleRegex = new Regex(@"(?\{(?:Series)(?\s|\.|-|_)(Clean)?Title\})", + public static readonly Regex SeriesTitleRegex = new Regex(@"(?\{(?:Series)(?[- ._])(Clean)?Title\})", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex FileNameCleanupRegex = new Regex(@"\.{2,}", RegexOptions.Compiled);