Adding Artist Id, Album Id, and Track Artist Id as file name options.

pull/3594/head
Scott Fridlund 2 years ago committed by Qstick
parent 8ea54b6a94
commit 8a685be882

@ -49,7 +49,9 @@ const artistTokens = [
{ token: '{Artist Disambiguation}', example: 'Disambiguation' },
{ token: '{Artist Genre}', example: 'Pop' }
{ token: '{Artist Genre}', example: 'Pop' },
{ token: '{Artist MbId}', example: 'db92a151-1ac2-438b-bc43-b82e149ddd50' }
];
const albumTokens = [
@ -63,7 +65,9 @@ const albumTokens = [
{ token: '{Album Disambiguation}', example: 'Disambiguation' },
{ token: '{Album Genre}', example: 'Rock' }
{ token: '{Album Genre}', example: 'Rock' },
{ token: '{Album MbId}', example: '082c6aff-a7cc-36e0-a960-35a578ecd937' }
];
const mediumTokens = [
@ -92,7 +96,8 @@ const trackTitleTokens = [
const trackArtistTokens = [
{ token: '{Track ArtistName}', example: 'Artist Name' },
{ token: '{Track ArtistNameThe}', example: 'Artist Name, The' },
{ token: '{Track ArtistCleanName}', example: 'Artist Name' }
{ token: '{Track ArtistCleanName}', example: 'Artist Name' },
{ token: '{Track ArtistMbId}', example: 'db92a151-1ac2-438b-bc43-b82e149ddd50' }
];
const qualityTokens = [

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -26,6 +27,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
private AlbumRelease _release;
private Track _track1;
private Track _mixTrack1;
private Track _unknownTrack;
private TrackFile _trackFile;
private NamingConfig _namingConfig;
@ -41,6 +43,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
Name = "Linkin Park",
Genres = new List<string> { "Rock" }
})
.With(s => s.ForeignArtistId = Guid.NewGuid().ToString())
.Build();
_variousArtists = Builder<Artist>
@ -50,6 +53,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
{
Name = "Various Artists"
})
.With(s => s.ForeignArtistId = null)
.Build();
_medium = Builder<Medium>
@ -69,12 +73,14 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
.With(s => s.AlbumType = "Album")
.With(s => s.Disambiguation = "The Best Album")
.With(s => s.Genres = new List<string> { "Rock" })
.With(s => s.ForeignAlbumId = Guid.NewGuid().ToString())
.Build();
_mixAlbum = Builder<Album>
.CreateNew()
.With(s => s.Title = "Cool Music")
.With(s => s.AlbumType = "Album")
.With(s => s.ForeignAlbumId = null)
.Build();
_namingConfig = NamingConfig.Default;
@ -99,6 +105,13 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
.With(e => e.ArtistMetadata = _artist.Metadata)
.Build();
_unknownTrack = Builder<Track>.CreateNew()
.With(e => e.Title = "(Intermission)")
.With(e => e.AbsoluteTrackNumber = 3)
.With(e => e.AlbumRelease = _release)
.With(e => e.MediumNumber = _medium.Number)
.Build();
_trackFile = Builder<TrackFile>.CreateNew()
.With(e => e.Quality = new QualityModel(Quality.MP3_256))
.With(e => e.ReleaseGroup = "LidarrTest")
@ -221,6 +234,24 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
.Should().Be("Rock");
}
[Test]
public void should_replace_Artist_space_MbId()
{
_namingConfig.StandardTrackFormat = "{Artist MbId}";
Subject.BuildTrackFileName(new List<Track> { _track1 }, _artist, _album, _trackFile)
.Should().Be(_artist.ForeignArtistId);
}
[Test]
public void should_replace_Artist_MbId_null()
{
_namingConfig.StandardTrackFormat = "{Artist MbId}";
Subject.BuildTrackFileName(new List<Track> { _track1 }, _variousArtists, _mixAlbum, _trackFile)
.Should().Be(string.Empty);
}
[Test]
public void should_replace_Album_space_Title()
{
@ -321,6 +352,24 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
.Should().Be("Hybrid.Theory.2000");
}
[Test]
public void should_replace_Album_space_MbId()
{
_namingConfig.StandardTrackFormat = "{Album MbId}";
Subject.BuildTrackFileName(new List<Track> { _track1 }, _artist, _album, _trackFile)
.Should().Be(_album.ForeignAlbumId);
}
[Test]
public void should_replace_Album_MbId_null()
{
_namingConfig.StandardTrackFormat = "{Album MbId}";
Subject.BuildTrackFileName(new List<Track> { _track1 }, _variousArtists, _mixAlbum, _trackFile)
.Should().Be(string.Empty);
}
[Test]
public void should_replace_track_title()
{
@ -359,6 +408,24 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
.Should().Be("01");
}
[Test]
public void should_replace_Track_space_Artist_MbId()
{
_namingConfig.StandardTrackFormat = "{Track ArtistMbId}";
Subject.BuildTrackFileName(new List<Track> { _track1 }, _artist, _album, _trackFile)
.Should().Be(_track1.ArtistMetadata?.Value?.ForeignArtistId);
}
[Test]
public void should_replace_Track_Artist_MbId_null()
{
_namingConfig.StandardTrackFormat = "{Track ArtistMbId}";
Subject.BuildTrackFileName(new List<Track> { _unknownTrack }, _variousArtists, _mixAlbum, _trackFile)
.Should().Be(string.Empty);
}
[Test]
public void should_replace_medium_number_with_single_digit()
{

@ -276,6 +276,7 @@ namespace NzbDrone.Core.Organizer
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();
tokenHandlers["{Artist MbId}"] = m => artist.ForeignArtistId ?? string.Empty;
if (artist.Metadata.Value.Disambiguation != null)
{
@ -290,6 +291,7 @@ namespace NzbDrone.Core.Organizer
tokenHandlers["{Album TitleThe}"] = m => TitleThe(album.Title);
tokenHandlers["{Album Type}"] = m => album.AlbumType;
tokenHandlers["{Album Genre}"] = m => album.Genres.FirstOrDefault() ?? string.Empty;
tokenHandlers["{Album MbId}"] = m => album.ForeignAlbumId ?? string.Empty;
if (album.Disambiguation != null)
{
@ -325,6 +327,7 @@ namespace NzbDrone.Core.Organizer
tokenHandlers["{Track ArtistName}"] = m => firstArtist.Name;
tokenHandlers["{Track ArtistCleanName}"] = m => CleanTitle(firstArtist.Name);
tokenHandlers["{Track ArtistNameThe}"] = m => TitleThe(firstArtist.Name);
tokenHandlers["{Track ArtistMbId}"] = m => firstArtist.ForeignArtistId ?? string.Empty;
}
}

@ -34,12 +34,14 @@ namespace NzbDrone.Core.Organizer
{
Name = "The Artist Name",
Disambiguation = "US Rock Band",
Genres = new List<string> { "Pop" }
Genres = new List<string> { "Pop" },
ForeignArtistId = "db92a151-1ac2-438b-bc43-b82e149ddd50"
};
_standardArtist = new Artist
{
Metadata = artistMetadata
Metadata = artistMetadata,
ForeignArtistId = artistMetadata.ForeignArtistId,
};
_standardAlbum = new Album
@ -48,7 +50,8 @@ namespace NzbDrone.Core.Organizer
ReleaseDate = System.DateTime.Today,
AlbumType = "Album",
Disambiguation = "The Best Album",
Genres = new List<string> { "Rock" }
Genres = new List<string> { "Rock" },
ForeignAlbumId = "082c6aff-a7cc-36e0-a960-35a578ecd937"
};
_singleRelease = new AlbumRelease

Loading…
Cancel
Save