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

MetadataParser: Use year to discriminate album candidates

If it's not available, fall back to previous subfolder rule
Fix https://trac.videolan.org/vlc/ticket/19189
parent 511d10fe
......@@ -519,6 +519,25 @@ std::shared_ptr<Album> MetadataParser::findAlbum( parser::Task& task, std::share
continue;
}
// Attempt to discriminate by date
auto candidateDate = task.vlcMedia.meta( libvlc_meta_Date );
if ( candidateDate.empty() == false )
{
try
{
unsigned int year = std::stoi( candidateDate );
if ( year != a->releaseYear() )
it = albums.erase( it );
else
++it;
continue;
}
catch (...)
{
// Date wasn't helpful, simply ignore the error and continue
}
}
// Assume album files will be in the same folder.
auto newFileFolder = utils::file::directory( task.file->mrl() );
auto trackFiles = tracks[0]->files();
......
......@@ -50,6 +50,7 @@ static const char* testCases[] = {
"playlist_external_media",
"playlist_external_folder",
"playlist_same_folder",
"same_album_with_subfolder",
};
class TestEnv : public ::testing::Environment
......
Subproject commit 6c12082071f2db2b65e98bcfe7fbe05ea8ea17bf
Subproject commit c24cb056e5c0d0b2ce90dcf9b30034ae568249ce
{
"input": [
"music/same_album_with_subfolder"
],
"expected": {
"nbAudios": 3,
"albums": [{
"title": "Album",
"releaseYear": 2000,
"nbTracks": 3
}]
}
}
Supports Markdown
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