mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-15 08:15:37 +00:00
Finish plugin support implementation
Small refactoring
This commit is contained in:
@@ -9,11 +9,8 @@ import de.grimsi.gameyfin.pluginapi.core.PluginConfigElement
|
||||
import de.grimsi.gameyfin.pluginapi.core.PluginConfigError
|
||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.GameMetadata
|
||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.GameMetadataFetcher
|
||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.Genre
|
||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.Theme
|
||||
import org.pf4j.Extension
|
||||
import org.pf4j.PluginWrapper
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.time.Instant
|
||||
import kotlin.collections.filter
|
||||
|
||||
@@ -52,8 +49,6 @@ class IgdbPlugin(wrapper: PluginWrapper) : GameyfinPlugin(wrapper) {
|
||||
|
||||
@Extension
|
||||
class IgdbMetadataFetcher : GameMetadataFetcher {
|
||||
private val log = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
override fun fetchMetadata(gameId: String): GameMetadata {
|
||||
val findGameByName = APICalypse()
|
||||
.fields("*")
|
||||
@@ -71,76 +66,13 @@ class IgdbPlugin(wrapper: PluginWrapper) : GameyfinPlugin(wrapper) {
|
||||
criticRating = game.aggregatedRating.toInt(),
|
||||
developedBy = game.involvedCompaniesList.filter { it.developer }.map { it.company.name },
|
||||
publishedBy = game.involvedCompaniesList.filter { it.publisher }.map { it.company.name },
|
||||
genres = game.genresList.map { mapGenre(it) },
|
||||
themes = game.themesList.map { mapTheme(it) },
|
||||
genres = game.genresList.map { Mapper.genre(it) },
|
||||
themes = game.themesList.map { Mapper.theme(it) },
|
||||
screenshotUrls = listOf(),
|
||||
videoUrls = listOf(),
|
||||
features = listOf(),
|
||||
perspectives = listOf()
|
||||
)
|
||||
}
|
||||
|
||||
private fun mapGenre(genre: proto.Genre): Genre {
|
||||
return when (genre.slug) {
|
||||
"pinball" -> Genre.PINBALL
|
||||
"adventure" -> Genre.ADVENTURE
|
||||
"indie" -> Genre.INDIE
|
||||
"arcade" -> Genre.ARCADE
|
||||
"visual-novel" -> Genre.VISUAL_NOVEL
|
||||
"card-and-board-game" -> Genre.CARD_AND_BOARD_GAME
|
||||
"moba" -> Genre.MOBA
|
||||
"point-and-click" -> Genre.POINT_AND_CLICK
|
||||
"fighting" -> Genre.FIGHTING
|
||||
"shooter" -> Genre.SHOOTER
|
||||
"music" -> Genre.MUSIC
|
||||
"platform" -> Genre.PLATFORM
|
||||
"puzzle" -> Genre.PUZZLE
|
||||
"racing" -> Genre.RACING
|
||||
"real-time-strategy-rts" -> Genre.REAL_TIME_STRATEGY
|
||||
"role-playing-rpg" -> Genre.ROLE_PLAYING
|
||||
"simulator" -> Genre.SIMULATOR
|
||||
"sport" -> Genre.SPORT
|
||||
"strategy" -> Genre.STRATEGY
|
||||
"turn-based-strategy-tbs" -> Genre.TURN_BASED_STRATEGY
|
||||
"tactical" -> Genre.TACTICAL
|
||||
"hack-and-slash-beat-em-up" -> Genre.HACK_AND_SLASH_BEAT_EM_UP
|
||||
"quiz-trivia" -> Genre.QUIZ_TRIVIA
|
||||
else -> {
|
||||
log.warn("Unknown genre: {}", genre.slug)
|
||||
Genre.UNKNOWN
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun mapTheme(theme: proto.Theme): Theme {
|
||||
return when (theme.slug) {
|
||||
"action" -> Theme.ACTION
|
||||
"fantasy" -> Theme.FANTASY
|
||||
"horror" -> Theme.HORROR
|
||||
"sci-fi" -> Theme.SCIENCE_FICTION
|
||||
"mystery" -> Theme.MYSTERY
|
||||
"thriller" -> Theme.THRILLER
|
||||
"survival" -> Theme.SURVIVAL
|
||||
"historical" -> Theme.HISTORICAL
|
||||
"stealth" -> Theme.STEALTH
|
||||
"comedy" -> Theme.COMEDY
|
||||
"business" -> Theme.BUSINESS
|
||||
"drama" -> Theme.DRAMA
|
||||
"non-fiction" -> Theme.NON_FICTION
|
||||
"sandbox" -> Theme.SANDBOX
|
||||
"educational" -> Theme.EDUCATIONAL
|
||||
"kids" -> Theme.KIDS
|
||||
"open-world" -> Theme.OPEN_WORLD
|
||||
"warfare" -> Theme.WARFARE
|
||||
"party" -> Theme.PARTY
|
||||
"4x-explore-expand-exploit-and-exterminate" -> Theme.FOUR_X
|
||||
"erotic" -> Theme.EROTIC
|
||||
"romance" -> Theme.ROMANCE
|
||||
else -> {
|
||||
log.warn("Unknown theme: {}", theme.slug)
|
||||
Theme.UNKNOWN
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package de.grimsi.gameyfin.plugins.igdb
|
||||
|
||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.Genre
|
||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.Theme
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
class Mapper {
|
||||
companion object {
|
||||
private val log = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
fun genre(genre: proto.Genre): Genre {
|
||||
return when (genre.slug) {
|
||||
"pinball" -> Genre.PINBALL
|
||||
"adventure" -> Genre.ADVENTURE
|
||||
"indie" -> Genre.INDIE
|
||||
"arcade" -> Genre.ARCADE
|
||||
"visual-novel" -> Genre.VISUAL_NOVEL
|
||||
"card-and-board-game" -> Genre.CARD_AND_BOARD_GAME
|
||||
"moba" -> Genre.MOBA
|
||||
"point-and-click" -> Genre.POINT_AND_CLICK
|
||||
"fighting" -> Genre.FIGHTING
|
||||
"shooter" -> Genre.SHOOTER
|
||||
"music" -> Genre.MUSIC
|
||||
"platform" -> Genre.PLATFORM
|
||||
"puzzle" -> Genre.PUZZLE
|
||||
"racing" -> Genre.RACING
|
||||
"real-time-strategy-rts" -> Genre.REAL_TIME_STRATEGY
|
||||
"role-playing-rpg" -> Genre.ROLE_PLAYING
|
||||
"simulator" -> Genre.SIMULATOR
|
||||
"sport" -> Genre.SPORT
|
||||
"strategy" -> Genre.STRATEGY
|
||||
"turn-based-strategy-tbs" -> Genre.TURN_BASED_STRATEGY
|
||||
"tactical" -> Genre.TACTICAL
|
||||
"hack-and-slash-beat-em-up" -> Genre.HACK_AND_SLASH_BEAT_EM_UP
|
||||
"quiz-trivia" -> Genre.QUIZ_TRIVIA
|
||||
else -> {
|
||||
log.warn("Unknown genre: {}", genre.slug)
|
||||
Genre.UNKNOWN
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun theme(theme: proto.Theme): Theme {
|
||||
return when (theme.slug) {
|
||||
"action" -> Theme.ACTION
|
||||
"fantasy" -> Theme.FANTASY
|
||||
"horror" -> Theme.HORROR
|
||||
"sci-fi" -> Theme.SCIENCE_FICTION
|
||||
"mystery" -> Theme.MYSTERY
|
||||
"thriller" -> Theme.THRILLER
|
||||
"survival" -> Theme.SURVIVAL
|
||||
"historical" -> Theme.HISTORICAL
|
||||
"stealth" -> Theme.STEALTH
|
||||
"comedy" -> Theme.COMEDY
|
||||
"business" -> Theme.BUSINESS
|
||||
"drama" -> Theme.DRAMA
|
||||
"non-fiction" -> Theme.NON_FICTION
|
||||
"sandbox" -> Theme.SANDBOX
|
||||
"educational" -> Theme.EDUCATIONAL
|
||||
"kids" -> Theme.KIDS
|
||||
"open-world" -> Theme.OPEN_WORLD
|
||||
"warfare" -> Theme.WARFARE
|
||||
"party" -> Theme.PARTY
|
||||
"4x-explore-expand-exploit-and-exterminate" -> Theme.FOUR_X
|
||||
"erotic" -> Theme.EROTIC
|
||||
"romance" -> Theme.ROMANCE
|
||||
else -> {
|
||||
log.warn("Unknown theme: {}", theme.slug)
|
||||
Theme.UNKNOWN
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package de.grimsi.gameyfin.plugins.igdb.dto
|
||||
|
||||
data class TwitchOAuthTokenDto(
|
||||
val accessToken: String,
|
||||
val expiresIn: Int,
|
||||
val tokenType: String
|
||||
)
|
||||
@@ -1,5 +1,6 @@
|
||||
Manifest-Version: 1.0
|
||||
Plugin-Id: igdb
|
||||
Plugin-Class: de.grimsi.gameyfin.plugins.igdb.IgdbPlugin
|
||||
Plugin-Version: 1.0.0-SNAPSHOT
|
||||
Plugin-Id: igdb
|
||||
Plugin-Description: IGDB Plugin
|
||||
Plugin-Version: 1.0.0-alpha1
|
||||
Plugin-Provider: grimsi
|
||||
|
||||
Reference in New Issue
Block a user