mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-16 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:
@@ -1,5 +1,3 @@
|
|||||||
val pluginDir: File by rootProject.extra
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm")
|
kotlin("jvm")
|
||||||
}
|
}
|
||||||
@@ -8,13 +6,14 @@ subprojects {
|
|||||||
apply(plugin = "org.jetbrains.kotlin.jvm")
|
apply(plugin = "org.jetbrains.kotlin.jvm")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":plugin-api"))
|
compileOnly(project(":plugin-api"))
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.jar {
|
tasks.jar {
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
isZip64 = true
|
isZip64 = true
|
||||||
archiveBaseName.set("plugin-${project.name}")
|
archiveBaseName.set("plugin-${project.name}")
|
||||||
|
|
||||||
manifest {
|
manifest {
|
||||||
from("./src/main/resources/MANIFEST.MF")
|
from("./src/main/resources/MANIFEST.MF")
|
||||||
}
|
}
|
||||||
@@ -27,19 +26,4 @@ subprojects {
|
|||||||
from(sourceSets["main"].output.classesDirs)
|
from(sourceSets["main"].output.classesDirs)
|
||||||
from(sourceSets["main"].resources)
|
from(sourceSets["main"].resources)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register<Copy>("assemblePlugin") {
|
|
||||||
from(project.tasks.jar)
|
|
||||||
into(pluginDir)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register<Copy>("assemblePlugins") {
|
|
||||||
dependsOn(subprojects.map { it.tasks.named("assemblePlugin") })
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
"build" {
|
|
||||||
dependsOn(named("assemblePlugins"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -3,13 +3,10 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Kotlin annotation processor
|
|
||||||
ksp("care.better.pf4j:pf4j-kotlin-symbol-processing:2.0.20-1.0.1")
|
ksp("care.better.pf4j:pf4j-kotlin-symbol-processing:2.0.20-1.0.1")
|
||||||
|
|
||||||
// IGDB API client
|
// IGDB API client
|
||||||
implementation("io.github.husnjak:igdb-api-jvm:1.2.0")
|
implementation("io.github.husnjak:igdb-api-jvm:1.2.0")
|
||||||
|
|
||||||
compileOnly("org.slf4j:slf4j-api:2.0.16")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register<Copy>("copyDependencyClasses") {
|
tasks.register<Copy>("copyDependencyClasses") {
|
||||||
@@ -20,9 +17,6 @@ tasks.register<Copy>("copyDependencyClasses") {
|
|||||||
from(configurations.runtimeClasspath.get().map { project.zipTree(it) }) {
|
from(configurations.runtimeClasspath.get().map { project.zipTree(it) }) {
|
||||||
include("**/*.class")
|
include("**/*.class")
|
||||||
}
|
}
|
||||||
from("src/main/resources/MANIFEST.MF") {
|
|
||||||
into("META-INF")
|
|
||||||
}
|
|
||||||
into(layout.buildDirectory.get().asFile.resolve("classes/kotlin/main"))
|
into(layout.buildDirectory.get().asFile.resolve("classes/kotlin/main"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package de.grimsi.gameyfin.plugins.igdb
|
|||||||
|
|
||||||
import com.api.igdb.request.IGDBWrapper
|
import com.api.igdb.request.IGDBWrapper
|
||||||
import com.api.igdb.request.TwitchAuthenticator
|
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.GameMetadata
|
||||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.GameMetadataFetcher
|
import de.grimsi.gameyfin.pluginapi.gamemetadata.GameMetadataFetcher
|
||||||
import org.pf4j.Extension
|
import org.pf4j.Extension
|
||||||
@@ -12,39 +11,34 @@ import java.time.Instant
|
|||||||
|
|
||||||
class IgdbPlugin(wrapper: PluginWrapper) : Plugin(wrapper) {
|
class IgdbPlugin(wrapper: PluginWrapper) : Plugin(wrapper) {
|
||||||
|
|
||||||
companion object {
|
|
||||||
val config: IgdbPluginConfig = IgdbPluginConfig(null, null)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun start() {
|
override fun start() {
|
||||||
authenticate()
|
authenticate()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun stop() {
|
override fun stop() {
|
||||||
log.debug("IgdbPlugin.stop()")
|
println("IgdbPlugin.stop()")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun authenticate() {
|
private fun authenticate() {
|
||||||
log.debug("Authenticating on Twitch API...")
|
// Kotlin example
|
||||||
|
val token = TwitchAuthenticator.requestTwitchToken("CLIENT_ID", "CLIENT_SECRET")
|
||||||
// FIXME: This should be read from the config
|
if (token == null) {
|
||||||
val clientId = "8nrnjn74x1oa7of2g8sg4voy2lapml"
|
println("Failed to authenticate with Twitch")
|
||||||
// FIXME: This should be read from the config
|
return
|
||||||
val clientSecret = "pyrvg3sdduxjg4qxidra9237xj17yn"
|
}
|
||||||
|
IGDBWrapper.setCredentials("client_id", token.access_token)
|
||||||
// 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")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Extension
|
@Extension
|
||||||
class IgdbMetadataFetcher : GameMetadataFetcher {
|
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 {
|
override fun fetchMetadata(gameId: String): GameMetadata {
|
||||||
return GameMetadata(
|
return GameMetadata(
|
||||||
title = "Test Game",
|
title = "Test Game",
|
||||||
|
|||||||
Reference in New Issue
Block a user