diff --git a/frontend/src/Settings/MediaManagement/Naming/NamingModal.js b/frontend/src/Settings/MediaManagement/Naming/NamingModal.js index fee082fa1..d50df776a 100644 --- a/frontend/src/Settings/MediaManagement/Naming/NamingModal.js +++ b/frontend/src/Settings/MediaManagement/Naming/NamingModal.js @@ -43,6 +43,8 @@ const artistTokens = [ { token: '{Artist NameThe}', example: 'Artist Name, The' }, + { token: '{Artist NameFirstCharacter}', example: 'A' }, + { token: '{Artist CleanName}', example: 'Artist Name' }, { token: '{Artist Disambiguation}', example: 'Disambiguation' } diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/ArtistNameFirstCharacterFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/ArtistNameFirstCharacterFixture.cs new file mode 100644 index 000000000..35827fc42 --- /dev/null +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/ArtistNameFirstCharacterFixture.cs @@ -0,0 +1,56 @@ +using System.Linq; +using FizzWare.NBuilder; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Music; +using NzbDrone.Core.Organizer; +using NzbDrone.Core.Qualities; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests +{ + [TestFixture] + public class ArtistNameFirstCharacterFixture : CoreTest + { + private Artist _artist; + private NamingConfig _namingConfig; + + [SetUp] + public void Setup() + { + _artist = Builder + .CreateNew() + .Build(); + + _namingConfig = NamingConfig.Default; + _namingConfig.RenameTracks = true; + + Mocker.GetMock() + .Setup(c => c.GetConfig()).Returns(_namingConfig); + + Mocker.GetMock() + .Setup(v => v.Get(Moq.It.IsAny())) + .Returns(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) + { + _artist.Name = title; + _namingConfig.ArtistFolderFormat = "{Artist NameFirstCharacter}\\{Artist Name}"; + + Subject.GetArtistFolder(_artist).Should().Be(expected); + } + + [Test] + public void should_be_able_to_use_lower_case_first_character() + { + _artist.Name = "Westworld"; + _namingConfig.ArtistFolderFormat = "{artist namefirstcharacter}\\{artist name}"; + + Subject.GetArtistFolder(_artist).Should().Be("w\\westworld"); + } + } +} diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index a6646bdac..fa9d19708 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -267,6 +267,7 @@ namespace NzbDrone.Core.Organizer tokenHandlers["{Artist Name}"] = m => artist.Name; tokenHandlers["{Artist CleanName}"] = m => CleanTitle(artist.Name); tokenHandlers["{Artist NameThe}"] = m => TitleThe(artist.Name); + tokenHandlers["{Artist NameFirstCharacter}"] = m => TitleThe(artist.Name).Substring(0, 1).FirstCharToUpper(); if (artist.Metadata.Value.Disambiguation != null) {