1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00

New: Series Year Renaming token

Closes #4407
This commit is contained in:
Mark McDowall 2021-03-27 18:15:09 -07:00
parent 0210b5c5c1
commit 2da2420415
3 changed files with 51 additions and 1 deletions

View File

@ -49,7 +49,8 @@ const seriesTokens = [
{ token: '{Series TitleThe}', example: 'Series Title, The' },
{ token: '{Series TitleTheYear}', example: 'Series Title, The (2010)' },
{ token: '{Series TitleYear}', example: 'Series Title (2010)' },
{ token: '{Series TitleFirstCharacter}', example: 'S' }
{ token: '{Series TitleFirstCharacter}', example: 'S' },
{ token: '{Series Year}', example: '2010' }
];
const seriesIdTokens = [

View File

@ -0,0 +1,48 @@
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 SeriesYearFixture : 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", 2017, "2017\\The Mist")]
[TestCase("A", 2021, "2021\\A")]
[TestCase("30 Rock", 2006, "2006\\30 Rock")]
public void should_get_expected_folder_name_back(string title, int year, string expected)
{
_series.Title = title;
_series.Year = year;
_namingConfig.SeriesFolderFormat = "{Series Year}\\{Series Title}";
Subject.GetSeriesFolder(_series).Should().Be(expected);
}
}
}

View File

@ -419,6 +419,7 @@ private void AddSeriesTokens(Dictionary<string, Func<TokenMatch, string>> tokenH
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();
tokenHandlers["{Series Year}"] = m => series.Year.ToString();
}
private string AddSeasonEpisodeNumberingTokens(string pattern, Dictionary<string, Func<TokenMatch, string>> tokenHandlers, List<Episode> episodes, NamingConfig namingConfig)