mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-13 16:40:01 +00:00
Improve metadata matching algorithms
This commit is contained in:
@@ -142,7 +142,16 @@ class IgdbPlugin(wrapper: PluginWrapper) : ConfigurableGameyfinPlugin(wrapper) {
|
||||
|
||||
// Use fuzzy search to find the best matching game name
|
||||
val bestMatchingTitles = FuzzySearch.extractTop(gameTitle, games.map { it.name }, maxResults)
|
||||
games = bestMatchingTitles.mapNotNull { title -> games.find { it.name == title.string } }
|
||||
val bestMatchingTitleStrings = bestMatchingTitles.map { it.string }
|
||||
val bestMatchesMap = bestMatchingTitles.associateBy({ it.string }, { it.score })
|
||||
|
||||
// Filter the games to only include those that match the best matching titles
|
||||
games = games.filter { it.name in bestMatchingTitleStrings }
|
||||
|
||||
// If we have more than maxResults, sort by the best match score and take the top results
|
||||
games = games.filter { it.name in bestMatchesMap.keys }
|
||||
.sortedByDescending { bestMatchesMap[it.name] }
|
||||
.take(maxResults)
|
||||
|
||||
return games.map { toGameMetadata(it) }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Plugin-Version: 1.0.0-alpha8
|
||||
Plugin-Version: 1.0.0-alpha9
|
||||
Plugin-Class: de.grimsi.gameyfinplugins.igdb.IgdbPlugin
|
||||
Plugin-Id: de.grimsi.gameyfin.igdb
|
||||
Plugin-Name: IGDB Metadata
|
||||
|
||||
@@ -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
|
||||
|
||||
+16
-11
@@ -74,20 +74,25 @@ class SteamGridDbPlugin(wrapper: PluginWrapper) : ConfigurableGameyfinPlugin(wra
|
||||
|
||||
override fun fetchByTitle(gameTitle: String, maxResults: Int): List<GameMetadata> {
|
||||
return runBlocking {
|
||||
var searchResults = searchSteamGridDb(gameTitle)
|
||||
val covers = mutableListOf<GameMetadata>()
|
||||
val games = searchSteamGridDb(gameTitle)
|
||||
|
||||
if (searchResults.isEmpty()) return@runBlocking emptyList()
|
||||
if (searchResults.size > maxResults) searchResults = searchResults.slice(0 until maxResults)
|
||||
|
||||
return@runBlocking searchResults
|
||||
.map { game ->
|
||||
GameMetadata(
|
||||
originalId = game.id.toString(),
|
||||
title = game.name,
|
||||
coverUrl = getGridForGame(game.id)?.let { grid -> URI(grid.url) }
|
||||
for (game in games) {
|
||||
val gameDetails = client?.grids(game.id)
|
||||
val grids = gameDetails?.data.orEmpty()
|
||||
for (grid in grids) {
|
||||
covers.add(
|
||||
GameMetadata(
|
||||
originalId = game.id.toString(),
|
||||
title = game.name,
|
||||
coverUrl = URI(grid.url)
|
||||
)
|
||||
)
|
||||
if (covers.size >= maxResults) break
|
||||
}
|
||||
.filter { it.coverUrl != null }
|
||||
if (covers.size >= maxResults) break
|
||||
}
|
||||
covers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Plugin-Version: 1.0.0-alpha5
|
||||
Plugin-Version: 1.0.0-alpha6
|
||||
Plugin-Class: de.grimsi.gameyfinplugins.steamgriddb.SteamGridDbPlugin
|
||||
Plugin-Id: de.grimsi.gameyfin.steamgriddb
|
||||
Plugin-Name: SteamGridDB Covers
|
||||
|
||||
Reference in New Issue
Block a user