All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.in.shabinder.soundbound.matcher.QueryParamsMatching.kt Maven / Gradle / Ivy

package `in`.shabinder.soundbound.matcher

import `in`.shabinder.soundbound.models.Artist
import `in`.shabinder.soundbound.models.QueryParams
import `in`.shabinder.soundbound.zipline.FuzzySearch

fun  orderResults(
    matchFor: QueryParams,
    allMatches: List,
    searcher: FuzzySearch
): Map {
    val songModelWithMatchProps = allMatches.map { WrapperWithMatcherProps(it, it) }
    return orderResults(
        WrapperWithMatcherProps(matchFor, matchFor.asMatchProps()),
        songModelWithMatchProps,
        searcher
    ).mapKeys { it.key.model }
}

fun QueryParams.asMatchProps(): MatchProps {
    val queryParams = this
    return object : MatchProps {
        override val title: String = queryParams.trackName
        override val artists: List = queryParams.trackArtists
        override val albumName: String? = queryParams.albumName
        override val durationSec: Long = queryParams.trackDurationSec
        override val isrc: String? = queryParams.isrc
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy