Support embedded covers in flac files. fixes #18

This commit is contained in:
emeric
2020-01-21 13:22:54 +01:00
parent cce5d35ca2
commit efe73e0491
2 changed files with 22 additions and 9 deletions
+9 -3
View File
@@ -39,7 +39,7 @@
namespace Database {
#define LMS_DATABASE_VERSION 8
#define LMS_DATABASE_VERSION 9
using Version = std::size_t;
@@ -119,6 +119,12 @@ Session::doDatabaseMigrationIfNeeded()
_session.execute("DROP TABLE similarity_settings_feature");
_session.execute("ALTER TABLE scan_settings ADD similarity_engine_type INTEGER NOT NULL DEFAULT(" + std::to_string(static_cast<int>(ScanSettings::SimilarityEngineType::Clusters)) + ")");
}
else if (version == 8)
{
// Better cover handling, need to rescan the whole files
// Just increment the scan version of the settings to make the next scheduled scan rescan everything
ScanSettings::get(*this).modify()->incScanVersion();
}
else
{
LMS_LOG(DB, ERROR) << "Database version " << version << " cannot be handled using migration";
@@ -126,9 +132,9 @@ Session::doDatabaseMigrationIfNeeded()
}
++version;
}
VersionInfo::get(*this).modify()->setVersion(LMS_DATABASE_VERSION);
VersionInfo::get(*this).modify()->setVersion(LMS_DATABASE_VERSION);
}
}
Session::Session(Db& db)
+13 -6
View File
@@ -19,12 +19,13 @@
#include "TagLibParser.hpp"
#include <taglib/asffile.h>
#include <taglib/id3v2tag.h>
#include <taglib/fileref.h>
#include <taglib/flacfile.h>
#include <taglib/mpegfile.h>
#include <taglib/tag.h>
#include <taglib/tpropertymap.h>
#include <taglib/asffile.h>
#include <taglib/mpegfile.h>
#include <taglib/id3v2tag.h>
#include "utils/Logger.hpp"
#include "utils/Utils.hpp"
@@ -179,14 +180,14 @@ TagLibParser::parse(const std::filesystem::path& p, bool debug)
// Not that good embedded pictures handling
// WMA
if (TagLib::ASF::File *asfFile {dynamic_cast<TagLib::ASF::File*>(f.file())})
if (TagLib::ASF::File* asfFile {dynamic_cast<TagLib::ASF::File*>(f.file())})
{
const TagLib::ASF::Tag* tag {static_cast<TagLib::ASF::Tag*>(asfFile->tag())};
const TagLib::ASF::Tag* tag {asfFile->tag()};
if (tag && tag->attributeListMap().contains("WM/Picture"))
track.hasCover = true;
}
// MP3
else if (TagLib::MPEG::File *mp3File {dynamic_cast<TagLib::MPEG::File*>(f.file())})
else if (TagLib::MPEG::File* mp3File {dynamic_cast<TagLib::MPEG::File*>(f.file())})
{
if (mp3File->ID3v2Tag())
{
@@ -194,6 +195,12 @@ TagLibParser::parse(const std::filesystem::path& p, bool debug)
track.hasCover = true;
}
}
// FLAC
else if (TagLib::FLAC::File* flacFile {dynamic_cast<TagLib::FLAC::File*>(f.file())})
{
if (!flacFile->pictureList().isEmpty())
track.hasCover = true;
}
if (f.tag())
{