mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-16 16:20:04 +00:00
Improve metadata matching algorithms
This commit is contained in:
@@ -54,10 +54,21 @@ class SteamPlugin(wrapper: PluginWrapper) : GameyfinPlugin(wrapper) {
|
||||
val searchResult: List<SteamGame> = runBlocking { searchStore(gameTitle) }
|
||||
if (searchResult.isEmpty()) return emptyList()
|
||||
|
||||
// Use fuzzy search to find the best matching game name
|
||||
val bestMatchingTitles = FuzzySearch.extractTop(gameTitle, searchResult.map { it.name }, maxResults)
|
||||
val bestMatches = bestMatchingTitles.mapNotNull { title -> searchResult.find { it.name == title.string } }
|
||||
val bestMatchingTitleStrings = bestMatchingTitles.map { it.string }
|
||||
val bestMatchesMap = bestMatchingTitles.associateBy({ it.string }, { it.score })
|
||||
|
||||
return runBlocking { bestMatches.map { getGameDetails(it.id) } }.filterNotNull()
|
||||
// Filter the games to only include those that match the best matching titles
|
||||
var bestMatches = searchResult.filter { it.name in bestMatchingTitleStrings }
|
||||
|
||||
// If we have more than maxResults, sort by the best match score and take the top results
|
||||
bestMatches = bestMatches.filter { it.name in bestMatchesMap.keys }
|
||||
.sortedByDescending { bestMatchesMap[it.name] }
|
||||
|
||||
return runBlocking { bestMatches.map { getGameDetails(it.id) } }
|
||||
.filterNotNull()
|
||||
.take(maxResults)
|
||||
}
|
||||
|
||||
override fun fetchById(id: String): GameMetadata? {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Plugin-Version: 1.0.0-alpha8
|
||||
Plugin-Version: 1.0.0-alpha9
|
||||
Plugin-Class: de.grimsi.gameyfinplugins.steam.SteamPlugin
|
||||
Plugin-Id: de.grimsi.gameyfin.steam
|
||||
Plugin-Name: Steam Metadata
|
||||
|
||||
Reference in New Issue
Block a user