diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index 137a49fba..cb7e43706 100644
--- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -222,6 +222,7 @@
+
diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderFixture.cs
index d532c3541..ebe3edfd1 100644
--- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderFixture.cs
+++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderFixture.cs
@@ -64,8 +64,6 @@ namespace NzbDrone.Core.Test.OrganizerTests
_episodeFile.Quality.Proper = true;
}
-
-
[Test]
public void should_replace_Series_space_Title()
{
@@ -576,5 +574,15 @@ namespace NzbDrone.Core.Test.OrganizerTests
Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile)
.Should().Be("South.Park.S15E06.City.Sushi.X264.DTS.[EN+ES+IT]");
}
+
+ [Test]
+ public void should_remove_duplicate_non_word_characters()
+ {
+ _series.Title = "Venture Bros.";
+ _namingConfig.StandardEpisodeFormat = "{Series.Title}.{season}x{episode:00}";
+
+ Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile)
+ .Should().Be("Venture.Bros.15x06");
+ }
}
}
\ No newline at end of file
diff --git a/src/NzbDrone.Core.Test/OrganizerTests/GetSeasonFolderFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/GetSeasonFolderFixture.cs
new file mode 100644
index 000000000..24e7a7b2d
--- /dev/null
+++ b/src/NzbDrone.Core.Test/OrganizerTests/GetSeasonFolderFixture.cs
@@ -0,0 +1,35 @@
+using System;
+using FluentAssertions;
+using NUnit.Framework;
+using NzbDrone.Core.Organizer;
+using NzbDrone.Core.Test.Framework;
+using NzbDrone.Core.Tv;
+
+namespace NzbDrone.Core.Test.OrganizerTests
+{
+ [TestFixture]
+ public class GetSeasonFolderFixture : CoreTest
+ {
+ private NamingConfig namingConfig;
+
+ [SetUp]
+ public void Setup()
+ {
+ namingConfig = new NamingConfig();
+
+ Mocker.GetMock()
+ .Setup(c => c.GetConfig()).Returns(namingConfig);
+ }
+
+ [TestCase("Venture Bros.", 1, "{Series.Title}.{season:00}", "Venture.Bros.01")]
+ [TestCase("Venture Bros.", 1, "{Series Title} Season {season:00}", "Venture Bros. Season 01")]
+ public void should_use_seriesFolderFormat_to_build_folder_name(String seriesTitle, Int32 seasonNumber, String format, String expected)
+ {
+ namingConfig.SeasonFolderFormat = format;
+
+ var series = new Series { Title = seriesTitle };
+
+ Subject.GetSeasonFolder(series, seasonNumber, namingConfig).Should().Be(expected);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/NzbDrone.Core.Test/OrganizerTests/GetSeriesFolderFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/GetSeriesFolderFixture.cs
index 8757da319..0700f37b0 100644
--- a/src/NzbDrone.Core.Test/OrganizerTests/GetSeriesFolderFixture.cs
+++ b/src/NzbDrone.Core.Test/OrganizerTests/GetSeriesFolderFixture.cs
@@ -1,7 +1,9 @@
+using System;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.Test.Framework;
+using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.OrganizerTests
{
@@ -23,11 +25,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
[TestCase("30 Rock", "{Series Title}", "30 Rock")]
[TestCase("30 Rock", "{Series.Title}", "30.Rock")]
[TestCase("24/7 Road to the NHL Winter Classic", "{Series Title}", "24+7 Road to the NHL Winter Classic")]
- public void should_use_seriesFolderFormat_to_build_folder_name(string seriesTitle, string format, string expected)
+ [TestCase("Venture Bros.", "{Series.Title}", "Venture.Bros")]
+ public void should_use_seriesFolderFormat_to_build_folder_name(String seriesTitle, String format, String expected)
{
namingConfig.SeriesFolderFormat = format;
- var series = new NzbDrone.Core.Tv.Series { Title = seriesTitle };
+ var series = new Series { Title = seriesTitle };
Subject.GetSeriesFolder(series).Should().Be(expected);
}
diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs
index 6cb9be82a..43ec242ca 100644
--- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs
+++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs
@@ -289,7 +289,7 @@ namespace NzbDrone.Core.Organizer
AddSeriesTokens(tokenHandlers, series);
- return ReplaceTokens(namingConfig.SeriesFolderFormat, tokenHandlers);
+ return CleanFolderName(ReplaceTokens(namingConfig.SeriesFolderFormat, tokenHandlers));
}
public string GetSeasonFolder(Series series, Int32 seasonNumber, NamingConfig namingConfig = null)
@@ -302,10 +302,9 @@ namespace NzbDrone.Core.Organizer
var tokenHandlers = new Dictionary>(FileNameBuilderTokenEqualityComparer.Instance);
AddSeriesTokens(tokenHandlers, series);
-
AddSeasonTokens(tokenHandlers, seasonNumber);
- return ReplaceTokens(namingConfig.SeasonFolderFormat, tokenHandlers);
+ return CleanFolderName(ReplaceTokens(namingConfig.SeasonFolderFormat, tokenHandlers));
}
public static string CleanTitle(string name)
@@ -336,6 +335,12 @@ namespace NzbDrone.Core.Organizer
return result.Trim();
}
+ public static string CleanFolderName(string name)
+ {
+ name = FileNameCleanupRegex.Replace(name, match => match.Captures[0].Value[0].ToString());
+ return name.Trim(' ', '.');
+ }
+
private void AddSeriesTokens(Dictionary> tokenHandlers, Series series)
{
tokenHandlers["{Series Title}"] = m => series.Title;