musikr: fix broken fscovers impl

This commit is contained in:
Alexander Capehart 2025-03-18 13:27:37 -06:00
parent 93953aee8b
commit a3722acb5a
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -101,7 +101,7 @@ class MutableFSCovers(private val context: Context) : MutableCovers<FDCover> {
val bestCover = val bestCover =
parent.children parent.children
.filterIsInstance<DeviceFile>() .filterIsInstance<DeviceFile>()
.map { it to coverArtScore(file) } .map { it to coverArtScore(it) }
.maxBy { it.second } .maxBy { it.second }
if (bestCover.second > 0) { if (bestCover.second > 0) {
return CoverResult.Hit(FolderCoverImpl(context, bestCover.first.uri)) return CoverResult.Hit(FolderCoverImpl(context, bestCover.first.uri))
@ -136,9 +136,9 @@ class MutableFSCovers(private val context: Context) : MutableCovers<FDCover> {
// Multiply the score for preferred formats & extensions. Weirder formats are harder for // Multiply the score for preferred formats & extensions. Weirder formats are harder for
// android to decode, but not the end of the world. // android to decode, but not the end of the world.
score *= score *=
max(preferredFormats.indexOfFirst { file.mimeType.equals(it, ignoreCase = true) }, 0) max(preferredFormats.indexOfFirst { file.mimeType.equals(it, ignoreCase = true) }, 1)
score *= score *=
max(preferredExtensions.indexOfFirst { extension.equals(it, ignoreCase = true) }, 0) max(preferredExtensions.indexOfFirst { extension.equals(it, ignoreCase = true) }, 1)
return score return score
} }