Index: Schema.pm =================================================================== --- Schema.pm (revision 25035) +++ Schema.pm (working copy) @@ -2045,7 +2045,6 @@ } else { $log->debug(".. $tag : $value") if defined $value; } - } $log->debug("* Deferred Attributes *"); @@ -2209,13 +2208,20 @@ my $album = $attributes->{'ALBUM'}; my $disc = $attributes->{'DISC'}; my $discc = $attributes->{'DISCC'}; + # Bug 10583 - Also check for MusicBrainz Album Id + my $albumid = $attributes->{'MUSICBRAINZ_ALBUM_ID'}; # Bug 4361, Some programs (iTunes) tag things as Disc 1/1, but # we want to ignore that or the group discs logic below gets confused - if ( $discc && $discc == 1 ) { - $log->debug( '-- Ignoring useless DISCC tag value of 1' ); - $disc = $discc = undef; - } + # Bug 10583 - Revert disc 1/1 change. + # "Minimal tags" don't help for the "Greatest Hits" problem, + # either main contributor (ALBUMARTIST) or MB Album Id should be used. + # In the contrary, "disc 1/1" helps aggregating compilation tracks in different directories. + # At least, visible presentation is now the same for compilations: disc 1/1 behaves like x/x. + #if ( $discc && $discc == 1 ) { + # $log->debug( '-- Ignoring useless DISCC tag value of 1' ); + # $disc = $discc = undef; + #} # we may have an album object already.. # But mark it undef first - bug 3685 @@ -2273,8 +2279,9 @@ # if we have a disc, provided we're not in the iTunes situation (disc == discc == 1) my $checkDisc = 0; + # Bug 10583 - Revert disc 1/1 change. Use MB Album Id in addition (unique id per disc, not per set!) if (!$prefs->get('groupdiscs') && - (($disc && $discc && $discc > 1) || ($disc && !$discc))) { + (($disc && $discc) || ($disc && !$discc) || $albumid)) { $checkDisc = 1; } @@ -2324,8 +2331,15 @@ $search->{'me.disc'} = $disc; - } elsif ($discc && $discc > 1) { + # Bug 10583 - Also check musicbrainz_id if defined. + # Can't be used in groupdiscs mode since id is unique per disc, not per set. + if (defined $albumid) { + $search->{'me.musicbrainz_id'} = $albumid; + $log->debug(sprintf("-- Checking for MusicBrainz Album Id: %s", $albumid)); + } + } elsif ($discc) { + # If we're not checking discs - ie: we're in # groupdiscs mode, check discc if it exists, # in the case where there are multiple albums @@ -2383,8 +2397,14 @@ 'group_by' => 'me.id', }; + # Bug 10583 - If we had the MUSICBRAINZ_ALBUM_ID in the tracks table, + # we could join on it here ... + # TODO: Join on MUSICBRAINZ_ALBUM_ID if it ever makes it into the tracks table. + # Join on tracks with the same basename to determine a unique album. - if (!defined $disc && !defined $discc) { + # Bug 10583 - Only try to aggregate from basename + # if no MUSICBRAINZ_ALBUM_ID and no DISC and no DISCC available. + if (!defined $albumid && !defined $disc && !defined $discc) { $search->{'tracks.url'} = { 'like' => "$basename%" };