Made preferred file names for cover configurable. fixes #238
This commit is contained in:
@@ -71,5 +71,8 @@ cover-max-cache-size = 30;
|
|||||||
# JPEG quality for covers (range is 1-100)
|
# JPEG quality for covers (range is 1-100)
|
||||||
cover-jpeg-quality = 75;
|
cover-jpeg-quality = 75;
|
||||||
|
|
||||||
|
# Preferred file names for covers (order is important)
|
||||||
|
cover-preferred-file-names = ("cover", "front" );
|
||||||
|
|
||||||
# Set to true if you want to hide duplicate tracks
|
# Set to true if you want to hide duplicate tracks
|
||||||
scanner-skip-duplicate-recording-mbid = false;
|
scanner-skip-duplicate-recording-mbid = false;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include "utils/IConfig.hpp"
|
#include "utils/IConfig.hpp"
|
||||||
#include "utils/Logger.hpp"
|
#include "utils/Logger.hpp"
|
||||||
#include "utils/Random.hpp"
|
#include "utils/Random.hpp"
|
||||||
|
#include "utils/String.hpp"
|
||||||
#include "utils/Utils.hpp"
|
#include "utils/Utils.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -68,6 +69,19 @@ namespace
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> constructPreferredFileNames()
|
||||||
|
{
|
||||||
|
std::vector<std::string> res;
|
||||||
|
|
||||||
|
Service<IConfig>::get()->visitStrings("cover-preferred-file-names",
|
||||||
|
[&res](std::string_view fileName)
|
||||||
|
{
|
||||||
|
res.emplace_back(fileName);
|
||||||
|
}, {"cover", "front"});
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Cover {
|
namespace Cover {
|
||||||
@@ -94,6 +108,7 @@ CoverService::CoverService(Database::Db& db,
|
|||||||
, _defaultCoverPath {defaultCoverPath}
|
, _defaultCoverPath {defaultCoverPath}
|
||||||
, _maxCacheSize {Service<IConfig>::get()->getULong("cover-max-cache-size", 30) * 1000 * 1000}
|
, _maxCacheSize {Service<IConfig>::get()->getULong("cover-max-cache-size", 30) * 1000 * 1000}
|
||||||
, _maxFileSize {Service<IConfig>::get()->getULong("cover-max-file-size", 10) * 1000 * 1000}
|
, _maxFileSize {Service<IConfig>::get()->getULong("cover-max-file-size", 10) * 1000 * 1000}
|
||||||
|
, _preferredFileNames {constructPreferredFileNames()}
|
||||||
|
|
||||||
{
|
{
|
||||||
setJpegQuality(Service<IConfig>::get()->getULong("cover-jpeg-quality", 75));
|
setJpegQuality(Service<IConfig>::get()->getULong("cover-jpeg-quality", 75));
|
||||||
@@ -101,6 +116,7 @@ CoverService::CoverService(Database::Db& db,
|
|||||||
LMS_LOG(COVER, INFO) << "Default cover path = '" << _defaultCoverPath.string() << "'";
|
LMS_LOG(COVER, INFO) << "Default cover path = '" << _defaultCoverPath.string() << "'";
|
||||||
LMS_LOG(COVER, INFO) << "Max cache size = " << _maxCacheSize;
|
LMS_LOG(COVER, INFO) << "Max cache size = " << _maxCacheSize;
|
||||||
LMS_LOG(COVER, INFO) << "Max file size = " << _maxFileSize;
|
LMS_LOG(COVER, INFO) << "Max file size = " << _maxFileSize;
|
||||||
|
LMS_LOG(COVER, INFO) << "Preferred file names: " << StringUtils::joinStrings(_preferredFileNames, ",");
|
||||||
|
|
||||||
#if LMS_SUPPORT_IMAGE_GM
|
#if LMS_SUPPORT_IMAGE_GM
|
||||||
GraphicsMagick::init(execPath);
|
GraphicsMagick::init(execPath);
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ namespace Cover
|
|||||||
const std::size_t _maxCacheSize;
|
const std::size_t _maxCacheSize;
|
||||||
static inline const std::vector<std::filesystem::path> _fileExtensions {".jpg", ".jpeg", ".png", ".bmp"}; // TODO parametrize
|
static inline const std::vector<std::filesystem::path> _fileExtensions {".jpg", ".jpeg", ".png", ".bmp"}; // TODO parametrize
|
||||||
const std::size_t _maxFileSize;
|
const std::size_t _maxFileSize;
|
||||||
static inline const std::vector<std::string> _preferredFileNames {"cover", "front"}; // TODO parametrize
|
const std::vector<std::string> _preferredFileNames;
|
||||||
unsigned _jpegQuality;
|
unsigned _jpegQuality;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user