1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2025-02-23 22:40:54 +00:00

New: Album and Artist Genre Naming Tokens

This commit is contained in:
Qstick 2022-12-25 14:02:48 -06:00
parent f7548f9bb7
commit ec41951ea5
4 changed files with 33 additions and 4 deletions

View file

@ -47,7 +47,9 @@ const artistTokens = [
{ token: '{Artist CleanName}', example: 'Artist Name' },
{ token: '{Artist Disambiguation}', example: 'Disambiguation' }
{ token: '{Artist Disambiguation}', example: 'Disambiguation' },
{ token: '{Artist Genre}', example: 'Pop' }
];
const albumTokens = [
@ -59,7 +61,9 @@ const albumTokens = [
{ token: '{Album Type}', example: 'Album Type' },
{ token: '{Album Disambiguation}', example: 'Disambiguation' }
{ token: '{Album Disambiguation}', example: 'Disambiguation' },
{ token: '{Album Genre}', example: 'Rock' }
];
const mediumTokens = [

View file

@ -10,6 +10,7 @@
using NzbDrone.Core.Organizer;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
using TagLib;
namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
{
@ -37,7 +38,8 @@ public void Setup()
.With(s => s.Metadata = new ArtistMetadata
{
Disambiguation = "US Rock Band",
Name = "Linkin Park"
Name = "Linkin Park",
Genres = new List<string> { "Rock" }
})
.Build();
@ -66,6 +68,7 @@ public void Setup()
.With(s => s.Title = "Hybrid Theory")
.With(s => s.AlbumType = "Album")
.With(s => s.Disambiguation = "The Best Album")
.With(s => s.Genres = new List<string> { "Rock" })
.Build();
_mixAlbum = Builder<Album>
@ -205,6 +208,15 @@ public void should_replace_Artist_Disambiguation()
.Should().Be("US Rock Band");
}
[Test]
public void should_replace_artist_genre()
{
_namingConfig.StandardTrackFormat = "{Artist Genre}";
Subject.BuildTrackFileName(new List<Track> { _track1 }, _artist, _album, _trackFile)
.Should().Be("Rock");
}
[Test]
public void should_replace_Album_space_Title()
{
@ -232,6 +244,15 @@ public void should_replace_Album_Disambiguation()
.Should().Be("The Best Album");
}
[Test]
public void should_replace_album_genre()
{
_namingConfig.StandardTrackFormat = "{Album Genre}";
Subject.BuildTrackFileName(new List<Track> { _track1 }, _artist, _album, _trackFile)
.Should().Be("Rock");
}
[Test]
public void should_replace_Album_underscore_Title()
{

View file

@ -267,6 +267,7 @@ private void AddArtistTokens(Dictionary<string, Func<TokenMatch, string>> tokenH
tokenHandlers["{Artist Name}"] = m => artist.Name;
tokenHandlers["{Artist CleanName}"] = m => CleanTitle(artist.Name);
tokenHandlers["{Artist NameThe}"] = m => TitleThe(artist.Name);
tokenHandlers["{Artist Genre}"] = m => artist.Metadata.Value.Genres?.FirstOrDefault() ?? string.Empty;
tokenHandlers["{Artist NameFirstCharacter}"] = m => TitleThe(artist.Name).Substring(0, 1).FirstCharToUpper();
if (artist.Metadata.Value.Disambiguation != null)
@ -281,6 +282,7 @@ private void AddAlbumTokens(Dictionary<string, Func<TokenMatch, string>> tokenHa
tokenHandlers["{Album CleanTitle}"] = m => CleanTitle(album.Title);
tokenHandlers["{Album TitleThe}"] = m => TitleThe(album.Title);
tokenHandlers["{Album Type}"] = m => album.AlbumType;
tokenHandlers["{Album Genre}"] = m => album.Genres.FirstOrDefault() ?? string.Empty;
if (album.Disambiguation != null)
{

View file

@ -32,7 +32,8 @@ public FileNameSampleService(IBuildFileNames buildFileNames)
var artistMetadata = new ArtistMetadata
{
Name = "The Artist Name",
Disambiguation = "US Rock Band"
Disambiguation = "US Rock Band",
Genres = new List<string> { "Pop" }
};
_standardArtist = new Artist
@ -46,6 +47,7 @@ public FileNameSampleService(IBuildFileNames buildFileNames)
ReleaseDate = System.DateTime.Today,
AlbumType = "Album",
Disambiguation = "The Best Album",
Genres = new List<string> { "Rock" }
};
_singleRelease = new AlbumRelease