More relaxed search for artist images, fixes #538
This commit is contained in:
@@ -108,27 +108,44 @@ namespace lms::scanner
|
|||||||
releasePaths.insert(directory->getAbsolutePath());
|
releasePaths.insert(directory->getAbsolutePath());
|
||||||
});
|
});
|
||||||
|
|
||||||
// Expect layout like this:
|
|
||||||
// ReleaseArtist/Release/Tracks'
|
|
||||||
// /artist.jpg
|
|
||||||
// /someOtherUserConfiguredArtistFile.jpg
|
|
||||||
if (!releasePaths.empty())
|
if (!releasePaths.empty())
|
||||||
{
|
|
||||||
const std::filesystem::path artistPath{ releasePaths.size() == 1 ? releasePaths.begin()->parent_path() : core::pathUtils::getLongestCommonPath(std::cbegin(releasePaths), std::cend(releasePaths)) };
|
|
||||||
image = findImageInDirectory(searchContext, artistPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!image)
|
|
||||||
{
|
{
|
||||||
// Expect layout like this:
|
// Expect layout like this:
|
||||||
// ReleaseArtist/Release/Tracks'
|
// ReleaseArtist/Release/Tracks'
|
||||||
// /artist.jpg
|
// /artist.jpg
|
||||||
// /someOtherUserConfiguredArtistFile.jpg
|
// /someOtherUserConfiguredArtistFile.jpg
|
||||||
for (const std::filesystem::path& releasePath : releasePaths)
|
//
|
||||||
|
// Or:
|
||||||
|
// ReleaseArtist/SomeGrouping/Release/Tracks'
|
||||||
|
// /artist.jpg
|
||||||
|
// /someOtherUserConfiguredArtistFile.jpg
|
||||||
|
//
|
||||||
|
std::filesystem::path directoryToInspect{ core::pathUtils::getLongestCommonPath(std::cbegin(releasePaths), std::cend(releasePaths)) };
|
||||||
|
while (true)
|
||||||
{
|
{
|
||||||
image = findImageInDirectory(searchContext, releasePath);
|
image = findImageInDirectory(searchContext, directoryToInspect);
|
||||||
if (image)
|
if (image)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
std::filesystem::path parentPath{ directoryToInspect.parent_path() };
|
||||||
|
if (parentPath == directoryToInspect)
|
||||||
|
break;
|
||||||
|
|
||||||
|
directoryToInspect = parentPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!image)
|
||||||
|
{
|
||||||
|
// Expect layout like this:
|
||||||
|
// ReleaseArtist/Release/Tracks'
|
||||||
|
// /artist.jpg
|
||||||
|
// /someOtherUserConfiguredArtistFile.jpg
|
||||||
|
for (const std::filesystem::path& releasePath : releasePaths)
|
||||||
|
{
|
||||||
|
image = findImageInDirectory(searchContext, releasePath);
|
||||||
|
if (image)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ namespace lms::scanner
|
|||||||
// and still belongs to a media directory
|
// and still belongs to a media directory
|
||||||
if (!std::filesystem::exists(p) || !std::filesystem::is_regular_file(p))
|
if (!std::filesystem::exists(p) || !std::filesystem::is_regular_file(p))
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, INFO, "Removing '" << p.string() << "': missing");
|
LMS_LOG(DBUPDATER, DEBUG, "Removing '" << p.string() << "': missing");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,13 +128,13 @@ namespace lms::scanner
|
|||||||
return core::pathUtils::isPathInRootPath(p, libraryInfo.rootDirectory, &excludeDirFileName);
|
return core::pathUtils::isPathInRootPath(p, libraryInfo.rootDirectory, &excludeDirFileName);
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, INFO, "Removing '" << p.string() << "': out of media directory");
|
LMS_LOG(DBUPDATER, DEBUG, "Removing '" << p.string() << "': out of media directory");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!core::pathUtils::hasFileAnyExtension(p, allowedExtensions))
|
if (!core::pathUtils::hasFileAnyExtension(p, allowedExtensions))
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, INFO, "Removing '" << p.string() << "': file format no longer handled");
|
LMS_LOG(DBUPDATER, DEBUG, "Removing '" << p.string() << "': file format no longer handled");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user