Added a new setting 'artist-info-image-file-names' to specify the artist image files to lookup alongside artist.nfo files, fixes #750
This commit is contained in:
+8
-1
@@ -101,10 +101,17 @@ cover-jpeg-quality = 75;
|
||||
# Preferred file names for covers (order is important, accept wildcards)
|
||||
cover-preferred-file-names = ("cover", "front", "folder", "default");
|
||||
|
||||
# Image file names searched alongside the artist info file (artist.nfo)
|
||||
# Note: files whose name is the artist's MBID are always searched first. You can place the MBID files anywhere in your libraries.
|
||||
artist-info-image-file-names = ("thumb", "folder", "fanart");
|
||||
|
||||
# File names for artist images (order is important, accept wildcards)
|
||||
# Note: files whose name is the artist's MBID are always searched before the names in this list. You can place the MBID files anywhere in your libraries.
|
||||
# Note: files next to artist info files are searched first.
|
||||
artist-image-file-names = ("artist");
|
||||
|
||||
# File names for artist.nfo files
|
||||
XXX = ("thumb", "folder", "fanart");
|
||||
|
||||
# File names for medium images (order is important, accept wildcards)
|
||||
# Note: files named after the disc itself are always searched before the names in this list.
|
||||
medium-image-file-names = ("discsubtitle");
|
||||
|
||||
@@ -59,6 +59,7 @@ namespace lms::scanner
|
||||
struct SearchArtistArtworkParams
|
||||
{
|
||||
std::span<const std::string> artistFileNames;
|
||||
std::span<const std::string> artistInfoFileNames;
|
||||
const ScannerSettings& settings;
|
||||
};
|
||||
|
||||
@@ -101,7 +102,7 @@ namespace lms::scanner
|
||||
return image;
|
||||
}
|
||||
|
||||
db::Image::pointer searchImageInArtistInfoDirectory(db::Session& session, db::ArtistId artistId)
|
||||
db::Image::pointer searchImageInArtistInfoDirectory(db::Session& session, const SearchArtistArtworkParams& searchParams, db::ArtistId artistId)
|
||||
{
|
||||
db::Image::pointer image;
|
||||
|
||||
@@ -109,9 +110,8 @@ namespace lms::scanner
|
||||
db::ArtistInfo::find(session, artistId, [&](const db::ArtistInfo::pointer& artistInfo) {
|
||||
fileInfoPaths.push_back(artistInfo->getAbsoluteFilePath());
|
||||
|
||||
// TODO make these names configurable
|
||||
if (!image)
|
||||
image = findImageInDirectory(session, artistInfo->getDirectory()->getAbsolutePath(), std::array<std::string, 3>{ "thumb", "folder", "fanart" });
|
||||
image = findImageInDirectory(session, artistInfo->getDirectory()->getAbsolutePath(), searchParams.artistInfoFileNames);
|
||||
});
|
||||
|
||||
if (fileInfoPaths.size() > 1)
|
||||
@@ -199,7 +199,7 @@ namespace lms::scanner
|
||||
}
|
||||
|
||||
{
|
||||
const db::Image::pointer image{ searchImageInArtistInfoDirectory(session, artist->getId()) };
|
||||
const db::Image::pointer image{ searchImageInArtistInfoDirectory(session, searchParams, artist->getId()) };
|
||||
if (image)
|
||||
return db::Artwork::find(session, image->getId());
|
||||
}
|
||||
@@ -254,6 +254,19 @@ namespace lms::scanner
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<std::string> constructArtistInfoFileNames()
|
||||
{
|
||||
std::vector<std::string> res;
|
||||
|
||||
core::Service<core::IConfig>::get()->visitStrings("artist-info-image-file-names",
|
||||
[&res](std::string_view fileName) {
|
||||
res.emplace_back(fileName);
|
||||
},
|
||||
{ "thumb", "folder", "fanart" });
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool fetchNextArtistIdRange(db::Session& session, db::ArtistId& lastRetrievedId, db::IdRange<db::ArtistId>& idRange)
|
||||
{
|
||||
constexpr std::size_t readBatchSize{ 100 };
|
||||
@@ -275,6 +288,9 @@ namespace lms::scanner
|
||||
, _artistIdRange{ artistIdRange }
|
||||
{
|
||||
}
|
||||
~ComputeArtistArtworkAssociationsJob() override = default;
|
||||
ComputeArtistArtworkAssociationsJob(const ComputeArtistArtworkAssociationsJob&) = delete;
|
||||
ComputeArtistArtworkAssociationsJob& operator=(const ComputeArtistArtworkAssociationsJob&) = delete;
|
||||
|
||||
std::span<const ArtistArtworkAssociation> getAssociations() const { return _associations; }
|
||||
std::size_t getProcessedArtistCount() const { return _processedArtistCount; }
|
||||
@@ -315,6 +331,7 @@ namespace lms::scanner
|
||||
ScanStepAssociateArtistImages::ScanStepAssociateArtistImages(InitParams& initParams)
|
||||
: ScanStepBase{ initParams }
|
||||
, _artistFileNames{ constructArtistFileNames() }
|
||||
, _artistInfoFileNames{ constructArtistInfoFileNames() }
|
||||
{
|
||||
}
|
||||
|
||||
@@ -340,6 +357,7 @@ namespace lms::scanner
|
||||
|
||||
const SearchArtistArtworkParams searchParams{
|
||||
.artistFileNames = _artistFileNames,
|
||||
.artistInfoFileNames = _artistInfoFileNames,
|
||||
.settings = _settings,
|
||||
};
|
||||
|
||||
|
||||
@@ -41,5 +41,6 @@ namespace lms::scanner
|
||||
void process(ScanContext& context) override;
|
||||
|
||||
const std::vector<std::string> _artistFileNames;
|
||||
const std::vector<std::string> _artistInfoFileNames;
|
||||
};
|
||||
} // namespace lms::scanner
|
||||
|
||||
Reference in New Issue
Block a user