Commit e952972d authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

MetadataParser: Don't use dates to discriminate compilation albums

parent cb430c29
...@@ -472,11 +472,11 @@ std::shared_ptr<Album> MetadataParser::findAlbum( parser::Task& task, std::share ...@@ -472,11 +472,11 @@ std::shared_ptr<Album> MetadataParser::findAlbum( parser::Task& task, std::share
for ( auto it = begin( albums ); it != end( albums ); ) for ( auto it = begin( albums ); it != end( albums ); )
{ {
auto a = (*it).get(); auto a = (*it).get();
auto candidateAlbumArtist = a->albumArtist();
if ( albumArtist != nullptr ) if ( albumArtist != nullptr )
{ {
// We assume that an album without album artist is a positive match. // We assume that an album without album artist is a positive match.
// At the end of the day, without proper tags, there's only so much we can do. // At the end of the day, without proper tags, there's only so much we can do.
auto candidateAlbumArtist = a->albumArtist();
if ( candidateAlbumArtist != nullptr && candidateAlbumArtist->id() != albumArtist->id() ) if ( candidateAlbumArtist != nullptr && candidateAlbumArtist->id() != albumArtist->id() )
{ {
it = albums.erase( it ); it = albums.erase( it );
...@@ -520,22 +520,31 @@ std::shared_ptr<Album> MetadataParser::findAlbum( parser::Task& task, std::share ...@@ -520,22 +520,31 @@ std::shared_ptr<Album> MetadataParser::findAlbum( parser::Task& task, std::share
continue; continue;
} }
// Attempt to discriminate by date // Attempt to discriminate by date, but only for the same artists.
auto candidateDate = task.vlcMedia.meta( libvlc_meta_Date ); // Not taking the artist in consideration would cause compilation to
if ( candidateDate.empty() == false ) // create multiple albums, especially when track are only partially
// tagged with a year.
if ( ( albumArtist != nullptr && candidateAlbumArtist != nullptr &&
albumArtist->id() == candidateAlbumArtist->id() ) ||
( trackArtist != nullptr && candidateAlbumArtist != nullptr &&
trackArtist->id() == candidateAlbumArtist->id() ) )
{ {
try auto candidateDate = task.vlcMedia.meta( libvlc_meta_Date );
if ( candidateDate.empty() == false )
{ {
unsigned int year = std::stoi( candidateDate ); try
if ( year != a->releaseYear() ) {
it = albums.erase( it ); unsigned int year = std::stoi( candidateDate );
else if ( year != a->releaseYear() )
++it; it = albums.erase( it );
continue; else
} ++it;
catch (...) continue;
{ }
// Date wasn't helpful, simply ignore the error and continue catch (...)
{
// Date wasn't helpful, simply ignore the error and continue
}
} }
} }
......
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