musikr: consider parent dir name as cover file

This commit is contained in:
Alexander Capehart 2025-03-18 12:54:00 -06:00
parent 132b689b0c
commit 5825ec3ebc
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -117,7 +117,7 @@ class MutableFSCovers(private val context: Context) : MutableCovers<FDCover> {
// that should not be managed by the app // that should not be managed by the app
} }
private fun coverArtScore(file: DeviceFile): Int { private suspend fun coverArtScore(file: DeviceFile): Int {
if (!file.mimeType.startsWith("image/", ignoreCase = true)) { if (!file.mimeType.startsWith("image/", ignoreCase = true)) {
// Not an image file. You lose! // Not an image file. You lose!
return 0 return 0
@ -127,9 +127,9 @@ class MutableFSCovers(private val context: Context) : MutableCovers<FDCover> {
val name = filename.substringBeforeLast('.') val name = filename.substringBeforeLast('.')
val extension = filename.substringAfterLast('.', "") val extension = filename.substringAfterLast('.', "")
// See if the name contains any of the preferred cover names. This helps weed out // See if the name contains any of the preferred cover names. This helps weed out
// images that are not actually cover art and are just there. // images that are not actually cover art and are just there.,
var score = var score =
preferredCoverNames (preferredCoverNames + requireNotNull(file.parent.await().path.name))
.withIndex() .withIndex()
.filter { name.contains(it.value, ignoreCase = true) } .filter { name.contains(it.value, ignoreCase = true) }
.sumOf { it.index + 1 } .sumOf { it.index + 1 }