Commit 0d71cf26 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

MetadataParser: Fix erroneous creation of duplicated albums

We were wrongfuly creating multiple albums for compilations that were
properly tagged with an AlbumArtist & a year.
This fixes the detection of compilation so that per-year discrimination
doesn't kick in.

Fix https://trac.videolan.org/vlc/ticket/19585
parent ca7e923c
......@@ -516,15 +516,22 @@ std::shared_ptr<Album> MetadataParser::findAlbum( parser::Task& task, std::share
}
auto multiDisc = false;
auto multipleArtists = false;
int64_t previousArtistId = trackArtist != nullptr ? trackArtist->id() : 0;
for ( auto& t : tracks )
{
auto at = t->albumTrack();
assert( at != nullptr );
if ( at != nullptr && at->discNumber() > 1 )
{
if ( at == nullptr )
continue;
if ( at->discNumber() > 1 )
multiDisc = true;
if ( previousArtistId != 0 && previousArtistId != at->artist()->id() )
multipleArtists = true;
previousArtistId = at->artist()->id();
// We now know enough about the album, we can stop looking at its tracks
if ( multiDisc == true && multipleArtists == true )
break;
}
}
if ( multiDisc )
{
......@@ -536,8 +543,9 @@ std::shared_ptr<Album> MetadataParser::findAlbum( parser::Task& task, std::share
// Not taking the artist in consideration would cause compilation to
// create multiple albums, especially when track are only partially
// tagged with a year.
if ( ( albumArtist != nullptr && albumArtist->id() == candidateAlbumArtist->id() ) ||
( trackArtist != nullptr && trackArtist->id() == candidateAlbumArtist->id() ) )
if ( ( ( albumArtist != nullptr && albumArtist->id() == candidateAlbumArtist->id() ) ||
( trackArtist != nullptr && trackArtist->id() == candidateAlbumArtist->id() ) ) &&
multipleArtists == false )
{
auto candidateDate = task.vlcMedia.meta( libvlc_meta_Date );
if ( candidateDate.empty() == false )
......
......@@ -51,6 +51,7 @@ static const char* testCases[] = {
"playlist_external_folder",
"playlist_same_folder",
"same_album_with_subfolder",
"compilation_different_years"
};
class TestEnv : public ::testing::Environment
......
Subproject commit c24cb056e5c0d0b2ce90dcf9b30034ae568249ce
Subproject commit 576f26c8ecd87caa530910ae526a75ce97a5d5c4
{
"input": [
"music/compilation_different_years"
],
"expected": {
"nbAudios": 3,
"albums": [{
"title": "Compilation",
"artist": "CommonArtist",
"tracks": [
{
"title": "Track 1",
"artist": "Artist 1"
},
{
"title": "Track 2",
"artist": "Artist 2"
},
{
"title": "Track 3",
"artist": "Artist 3"
}]
}],
"artists": [
{
"name": "Artist 1",
"nbAlbums": 0,
"nbTracks": 1
},
{
"name": "Artist 2",
"nbAlbums": 0,
"nbTracks": 1
},
{
"name": "Artist 3",
"nbAlbums": 0,
"nbTracks": 1
},
{
"name": "CommonArtist",
"nbAlbums": 1,
"nbTracks": 3
}
]
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment