From ceef661b70a42d7a1269a96d8e35cc51443e597c Mon Sep 17 00:00:00 2001 From: emeric Date: Mon, 15 Sep 2025 20:50:02 +0200 Subject: [PATCH] Added a new setting 'artist-info-image-file-names' to specify the artist image files to lookup alongside artist.nfo files, fixes #750 --- conf/lms.conf | 9 ++++++- .../steps/ScanStepAssociateArtistImages.cpp | 26 ++++++++++++++++--- .../steps/ScanStepAssociateArtistImages.hpp | 1 + 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/conf/lms.conf b/conf/lms.conf index 231fb777..1084f5dd 100644 --- a/conf/lms.conf +++ b/conf/lms.conf @@ -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"); diff --git a/src/libs/services/scanner/impl/steps/ScanStepAssociateArtistImages.cpp b/src/libs/services/scanner/impl/steps/ScanStepAssociateArtistImages.cpp index e2fa7aea..885ad2d9 100644 --- a/src/libs/services/scanner/impl/steps/ScanStepAssociateArtistImages.cpp +++ b/src/libs/services/scanner/impl/steps/ScanStepAssociateArtistImages.cpp @@ -59,6 +59,7 @@ namespace lms::scanner struct SearchArtistArtworkParams { std::span artistFileNames; + std::span 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{ "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 constructArtistInfoFileNames() + { + std::vector res; + + core::Service::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& 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 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, }; diff --git a/src/libs/services/scanner/impl/steps/ScanStepAssociateArtistImages.hpp b/src/libs/services/scanner/impl/steps/ScanStepAssociateArtistImages.hpp index f57bcee2..3cfb1d9c 100644 --- a/src/libs/services/scanner/impl/steps/ScanStepAssociateArtistImages.hpp +++ b/src/libs/services/scanner/impl/steps/ScanStepAssociateArtistImages.hpp @@ -41,5 +41,6 @@ namespace lms::scanner void process(ScanContext& context) override; const std::vector _artistFileNames; + const std::vector _artistInfoFileNames; }; } // namespace lms::scanner