Fixed: series/season folders will have leading/trailing periods removed when they are created
This commit is contained in:
parent
17aac81a4d
commit
b9ff97fe9f
|
@ -222,6 +222,7 @@
|
|||
<Compile Include="NotificationTests\Xbmc\Json\UpdateFixture.cs" />
|
||||
<Compile Include="NotificationTests\Xbmc\OnDownloadFixture.cs" />
|
||||
<Compile Include="OrganizerTests\BuildFilePathFixture.cs" />
|
||||
<Compile Include="OrganizerTests\GetSeasonFolderFixture.cs" />
|
||||
<Compile Include="OrganizerTests\FileNameBuilderFixture.cs" />
|
||||
<Compile Include="OrganizerTests\GetSeriesFolderFixture.cs" />
|
||||
<Compile Include="ParserTests\AbsoluteEpisodeNumberParserFixture.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<Episode> { _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<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("Venture.Bros.15x06");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<FileNameBuilder>
|
||||
{
|
||||
private NamingConfig namingConfig;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
namingConfig = new NamingConfig();
|
||||
|
||||
Mocker.GetMock<INamingConfigService>()
|
||||
.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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<string, Func<TokenMatch, String>>(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<String, Func<TokenMatch, String>> tokenHandlers, Series series)
|
||||
{
|
||||
tokenHandlers["{Series Title}"] = m => series.Title;
|
||||
|
|
Loading…
Reference in New Issue