Skip to content

Commit

Permalink
#879 Improve Compilations handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mherger committed Oct 9, 2023
1 parent c681652 commit d63c8f8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Changelog8.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ <h2><a name="v8.4.0" id="v8.4.0"></a>Version 8.4.0</h2>
<ul>
<li>New "Advanced Tag View" plugin allows you to show more information in the Track Info menu, without the need to drill down to "View Tags"</li>
<li>Add plugins for ClassicRadio.com, DI.fm, JazzRadio.com, RadioTunes.com, RockRadio.com, ZenRadio.com.</li>
<li>Add an optional artist albums view which groups albums by release type and contribution.</li>
<li>Add an option to import playlists from online music services.</li>
</ul>
<br />

<li>Server Changes:</li>
<ul>
<li><a href="https://github.com/Logitech/slimserver/issues/879">#879</a> - Add support for Release Types (see eg. on <a href="https://musicbrainz.org/doc/Release_Group/Type">MusicBrainz</a>).</li>
<li>Improve integration of the external image resizing helper daemon.</li>
<li>Improve built-in imageproxy: don't proxy image if original size is requested, re-direct instead; add support for custom headers when using external image proxy.</li>
<li>Updated Dutch translation - thanks blackfiction!</li>
Expand Down
28 changes: 20 additions & 8 deletions Slim/Menu/BrowseLibrary/Releases.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use Slim::Utils::Log;
use Slim::Utils::Strings qw(cstring);

use constant MAX_ALBUMS => 500;
use constant PRIMARY_ARTIST_ROLES => 'ARTIST,ALBUMARTIST';
use constant PRIMARY_ARTIST_ROLES => 'ALBUMARTIST';

my $log = logger('database.info');

Expand All @@ -15,7 +15,7 @@ sub _releases {
my ($client, $callback, $args, $pt) = @_;
my @searchTags = $pt->{'searchTags'} ? @{$pt->{'searchTags'}} : ();
my $wantMeta = $pt->{'wantMetadata'};
my $tags = 'lWR';
my $tags = 'lWRw';
my $library_id = $args->{'library_id'} || $pt->{'library_id'};

my %primaryArtistIds = map { Slim::Schema::Contributor->typeToRole($_) => 1 } split(/,/, PRIMARY_ARTIST_ROLES);
Expand Down Expand Up @@ -54,18 +54,28 @@ sub _releases {
# compile list of release types and contributions
my %releaseTypes;
my %contributions;
my %isPrimaryArtist;
foreach (@$albums) {
my @roleIds = split(',', $_->{role_ids} || '');

# Release Types if main artist
if (grep { $primaryArtistIds{$_} } @roleIds) {
$releaseTypes{$_->{release_type}}++;
$isPrimaryArtist{$_->{id}}++;
}
elsif ($_->{compilation}) {
$releaseTypes{COMPILATION}++;
# don't list as track artist on a compilation
next if $_->{role_ids} =~ /[156]/;
}

# Roles on other releases
foreach my $roleId (@roleIds) {
next if $primaryArtistIds{$roleId};

# don't list as trackartist, if the artist is albumartist, too
next if $roleId == 6 && $isPrimaryArtist{$_->{id}};

my $role = Slim::Schema::Contributor->roleToType($roleId);
$contributions{$role} = $roleId if $role;
}
Expand All @@ -78,13 +88,13 @@ sub _releases {
"library_id:" . $library_id,
];

my %primaryReleaseTypes = map { { uc($_) => 1 } } @{Slim::Schema::Album->primaryReleaseTypes};
$primaryReleaseTypes{COMPILATION} = 1; # not in the above list but we still want to ignore it here
my @primaryReleaseTypes = map { uc($_) } @{Slim::Schema::Album->primaryReleaseTypes};
push @primaryReleaseTypes, 'COMPILATION'; # we handle compilations differently, it's not part of the primaryReleaseTypes

my @sortedReleaseTypes = @{Slim::Schema::Album->primaryReleaseTypes}, sort {
my @sortedReleaseTypes = @primaryReleaseTypes, sort {
$a cmp $b
} grep {
!$primaryReleaseTypes{$_}
!grep /$_/, @primaryReleaseTypes;
} keys %releaseTypes;

foreach my $releaseType (@sortedReleaseTypes) {
Expand All @@ -102,8 +112,10 @@ sub _releases {
type => 'playlist',
playlist => \&_tracks,
url => \&_albums,
passthrough => [ { searchTags => [@$searchTags, "release_type:$releaseType"] } ],
}
passthrough => $releaseType eq 'COMPILATION'
? [ { searchTags => [@$searchTags, 'compilation:1'] } ]
: [ { searchTags => [@$searchTags, "compilation:0", "release_type:$releaseType"] } ],
};
}
}

Expand Down
4 changes: 2 additions & 2 deletions strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9252,8 +9252,8 @@ SETUP_RELEASE_TYPES_INCLUDE
EN Release types to include in Albums list

SETUP_RELEASE_TYPES_DESC
DE Sie können angeben, welche Veröffentlichungstypen (siehe <a href="https://beta.musicbrainz.org/doc/Release_Group/Type">MusicBrainz</a>) in der Albenliste mit aufgeführt werden sollen. Falls für eine Veröffentlichung kein Typ definiert wurde, so wird "Album" angenommen. Diese können nicht ausgeschlossen werden.
EN You can specify what release types you want to include in the albums list (see <a href="https://beta.musicbrainz.org/doc/Release_Group/Type">MusicBrainz</a>). If a release doesn't have a type defined, "Album" is assumed. Albums can't be excluded from that list.
DE Sie können angeben, welche Veröffentlichungstypen (siehe <a href="https://musicbrainz.org/doc/Release_Group/Type">MusicBrainz</a>) in der Albenliste mit aufgeführt werden sollen. Falls für eine Veröffentlichung kein Typ definiert wurde, so wird "Album" angenommen. Diese können nicht ausgeschlossen werden.
EN You can specify what release types you want to include in the albums list (see <a href="https://musicbrainz.org/doc/Release_Group/Type">MusicBrainz</a>). If a release doesn't have a type defined, "Album" is assumed. Albums can't be excluded from that list.

SETUP_IGNORE_RELEASE_TYPES_0
DE Unterstützung für Veröffentlichungstypen von Alben aktivieren
Expand Down

0 comments on commit d63c8f8

Please sign in to comment.