Skip to content

New: Token for track artist (as opposed to album artist) #1910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 16, 2021

Conversation

Daniel15
Copy link
Contributor

@Daniel15 Daniel15 commented Jan 16, 2021

Database Migration

NO

Description

Adds a new {Track ArtistName} token that contains the track's artist name, not the album's artist name. This is primarily useful with "Various Artists" albums.

I originally tried calling it {Track Artist Name} but the TitleRegex only allows a single space in the token name, so I went with {Track ArtistName} instead. Let me know if you'd prefer some other token.

Before:
image

After:
image

Todos

  • Tests
  • Wiki Updates

Issues Fixed or Closed by this PR

@@ -279,6 +280,16 @@ private void AddArtistTokens(Dictionary<string, Func<TokenMatch, string>> tokenH
}
}

private void AddTrackArtistTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, List<Track> tracks)
{
var artists = tracks.Select(t => t.ArtistMetadata.Value)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between Artist and ArtistMetadata in the data model? It looks like Artist is still "Various Artists" for these tracks, but ArtistMetadata is the correct artist.

Copy link
Contributor

@Qstick Qstick Jan 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Artist is the actual record that we follow in the db (monitored or not, profiles are attached to, etc...) ArtistMetadata is basically the data record for a given artist, it can be attached to an artist object or a track object.

@@ -122,6 +122,7 @@ public string BuildTrackFileName(List<Track> tracks, Artist artist, Album album,
AddAlbumTokens(tokenHandlers, album);
AddMediumTokens(tokenHandlers, tracks.First().AlbumRelease.Value.Media.SingleOrDefault(m => m.Number == tracks.First().MediumNumber));
AddTrackTokens(tokenHandlers, tracks);
AddTrackArtistTokens(tokenHandlers, tracks);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic can be added to AddTrackTokens instead of making a new module given this is track metadata

.DistinctBy(a => a.Name)
.ToList();

tokenHandlers["{Track ArtistName}"] = m => string.Join("+", artists.Select(a => a.Name));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to list these all and join by "+" or do we just want the first? should we have different tokens? @ta264 thoughts?

Copy link
Contributor Author

@Daniel15 Daniel15 Jan 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Qstick What does it mean if there's multiple tracks in the list? I copied the + joining based on what {Track Title} does but I didn't quite understand why it takes a List instead of just one Track..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lidarr is like Sonarr in that it supports 1 file = multiple tracks. So a particular file can be associated with multiple tracks.. Ex. Single file album.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update it to just use the first one.

@Qstick Qstick added this to the v0.8.0 milestone Jan 19, 2021
@Daniel15
Copy link
Contributor Author

I can fix the broken tests once I get some confirmation that my approach is reasonable. cc @ta264

@Qstick
Copy link
Contributor

Qstick commented Apr 2, 2021

@Daniel15 Can you rebase, @ta264 thoughts on the above comment? Would be good to have this before 0.8 is pushed

@Daniel15
Copy link
Contributor Author

Daniel15 commented Apr 2, 2021

Sure, I'll try to rebase and update the tests over the weekend if I get some free time :)

@Daniel15
Copy link
Contributor Author

Daniel15 commented Apr 3, 2021

@Qstick I think this is ready for review now. I rebased and fixed a few issues.

@Qstick Qstick merged commit 187672b into Lidarr:develop Apr 16, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

{Artist Name} is actually {Album Artist Name}
2 participants