mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-14 16:20:04 +00:00
Merge remote-tracking branch 'origin/v2' into v2
# Conflicts: # plugins/build.gradle.kts # plugins/igdb/build.gradle.kts # plugins/igdb/src/main/kotlin/de/grimsi/gameyfin/plugins/igdb/IgdbPlugin.kt
This commit is contained in:
@@ -2,7 +2,6 @@ package de.grimsi.gameyfin.plugins.igdb
|
||||
|
||||
import com.api.igdb.request.IGDBWrapper
|
||||
import com.api.igdb.request.TwitchAuthenticator
|
||||
import de.grimsi.gameyfin.pluginapi.core.PluginConfigError
|
||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.GameMetadata
|
||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.GameMetadataFetcher
|
||||
import org.pf4j.Extension
|
||||
@@ -12,39 +11,34 @@ import java.time.Instant
|
||||
|
||||
class IgdbPlugin(wrapper: PluginWrapper) : Plugin(wrapper) {
|
||||
|
||||
companion object {
|
||||
val config: IgdbPluginConfig = IgdbPluginConfig(null, null)
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
authenticate()
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
log.debug("IgdbPlugin.stop()")
|
||||
println("IgdbPlugin.stop()")
|
||||
}
|
||||
|
||||
private fun authenticate() {
|
||||
log.debug("Authenticating on Twitch API...")
|
||||
|
||||
// FIXME: This should be read from the config
|
||||
val clientId = "8nrnjn74x1oa7of2g8sg4voy2lapml"
|
||||
// FIXME: This should be read from the config
|
||||
val clientSecret = "pyrvg3sdduxjg4qxidra9237xj17yn"
|
||||
|
||||
// val clientId: String = config.clientId ?: throw PluginConfigError("Twitch Client ID not set")
|
||||
// val clientSecret: String = config.clientSecret ?: throw PluginConfigError("Twitch Client Secret not set")
|
||||
|
||||
val token = TwitchAuthenticator.requestTwitchToken(clientId, clientSecret)
|
||||
?: throw PluginConfigError("Failed to authenticate on Twitch API")
|
||||
|
||||
IGDBWrapper.setCredentials(clientId, token.access_token)
|
||||
|
||||
log.debug("Authentication successful")
|
||||
// Kotlin example
|
||||
val token = TwitchAuthenticator.requestTwitchToken("CLIENT_ID", "CLIENT_SECRET")
|
||||
if (token == null) {
|
||||
println("Failed to authenticate with Twitch")
|
||||
return
|
||||
}
|
||||
IGDBWrapper.setCredentials("client_id", token.access_token)
|
||||
}
|
||||
|
||||
@Extension
|
||||
class IgdbMetadataFetcher : GameMetadataFetcher {
|
||||
override fun getConfig(): Map<String, String> {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun setConfig(config: Map<String, String>) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun fetchMetadata(gameId: String): GameMetadata {
|
||||
return GameMetadata(
|
||||
title = "Test Game",
|
||||
|
||||
Reference in New Issue
Block a user