mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 07:22:35 +01:00
New: Series title first character renaming token
This commit is contained in:
parent
3b9ed49d0f
commit
ded0caee39
@ -338,6 +338,7 @@
|
||||
<Compile Include="OrganizerTests\FileNameBuilderTests\MultiEpisodeFixture.cs" />
|
||||
<Compile Include="OrganizerTests\FileNameBuilderTests\CleanTitleYearFixture.cs" />
|
||||
<Compile Include="OrganizerTests\FileNameBuilderTests\IdFixture.cs" />
|
||||
<Compile Include="OrganizerTests\FileNameBuilderTests\SeriesTitleFirstCharcterFixture.cs" />
|
||||
<Compile Include="OrganizerTests\FileNameBuilderTests\TitleYearFixture.cs" />
|
||||
<Compile Include="OrganizerTests\FileNameBuilderTests\TitleTheYearFixture.cs" />
|
||||
<Compile Include="OrganizerTests\FileNameBuilderTests\TitleTheFixture.cs" />
|
||||
|
@ -1,11 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
|
@ -0,0 +1,56 @@
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class SeriesTitleFirstCharcterFixture : CoreTest<FileNameBuilder>
|
||||
{
|
||||
private Series _series;
|
||||
private NamingConfig _namingConfig;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>
|
||||
.CreateNew()
|
||||
.Build();
|
||||
|
||||
_namingConfig = NamingConfig.Default;
|
||||
_namingConfig.RenameEpisodes = true;
|
||||
|
||||
Mocker.GetMock<INamingConfigService>()
|
||||
.Setup(c => c.GetConfig()).Returns(_namingConfig);
|
||||
|
||||
Mocker.GetMock<IQualityDefinitionService>()
|
||||
.Setup(v => v.Get(Moq.It.IsAny<Quality>()))
|
||||
.Returns<Quality>(v => Quality.DefaultQualityDefinitions.First(c => c.Quality == v));
|
||||
}
|
||||
|
||||
[TestCase("The Mist", "M\\The Mist")]
|
||||
[TestCase("A", "A\\A")]
|
||||
[TestCase("30 Rock", "3\\30 Rock")]
|
||||
public void should_get_expected_folder_name_back(string title, string expected)
|
||||
{
|
||||
_series.Title = title;
|
||||
_namingConfig.SeriesFolderFormat = "{Series TitleFirstCharacter}\\{Series Title}";
|
||||
|
||||
Subject.GetSeriesFolder(_series).Should().Be(expected);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_use_lower_case_first_character()
|
||||
{
|
||||
_series.Title = "Westworld";
|
||||
_namingConfig.SeriesFolderFormat = "{series titlefirstcharacter}\\{series title}";
|
||||
|
||||
Subject.GetSeriesFolder(_series).Should().Be("w\\westworld");
|
||||
}
|
||||
}
|
||||
}
|
@ -235,7 +235,8 @@ namespace NzbDrone.Core.Organizer
|
||||
AddSeriesTokens(tokenHandlers, series);
|
||||
AddIdTokens(tokenHandlers, series);
|
||||
|
||||
return CleanFolderName(ReplaceTokens(namingConfig.SeriesFolderFormat, tokenHandlers, namingConfig));
|
||||
var folderName = ReplaceTokens(namingConfig.SeriesFolderFormat, tokenHandlers, namingConfig);
|
||||
return CleanFolderName(folderName);
|
||||
}
|
||||
|
||||
public string GetSeasonFolder(Series series, int seasonNumber, NamingConfig namingConfig = null)
|
||||
@ -251,7 +252,8 @@ namespace NzbDrone.Core.Organizer
|
||||
AddIdTokens(tokenHandlers, series);
|
||||
AddSeasonTokens(tokenHandlers, seasonNumber);
|
||||
|
||||
return CleanFolderName(ReplaceTokens(namingConfig.SeasonFolderFormat, tokenHandlers, namingConfig));
|
||||
var folderName = ReplaceTokens(namingConfig.SeasonFolderFormat, tokenHandlers, namingConfig);
|
||||
return CleanFolderName(folderName);
|
||||
}
|
||||
|
||||
public static string CleanTitle(string title)
|
||||
@ -341,6 +343,7 @@ namespace NzbDrone.Core.Organizer
|
||||
tokenHandlers["{Series TitleThe}"] = m => TitleThe(series.Title);
|
||||
tokenHandlers["{Series TitleYear}"] = m => TitleYear(series.Title, series.Year);
|
||||
tokenHandlers["{Series TitleTheYear}"] = m => TitleYear(TitleThe(series.Title), series.Year);
|
||||
tokenHandlers["{Series TitleFirstCharacter}"] = m => TitleThe(series.Title).Substring(0, 1).FirstCharToUpper();
|
||||
}
|
||||
|
||||
private string AddSeasonEpisodeNumberingTokens(string pattern, Dictionary<string, Func<TokenMatch, string>> tokenHandlers, List<Episode> episodes, NamingConfig namingConfig)
|
||||
|
Loading…
Reference in New Issue
Block a user