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:
grimsi
2024-10-30 16:07:00 +01:00
3 changed files with 18 additions and 46 deletions
+2 -18
View File
@@ -1,5 +1,3 @@
val pluginDir: File by rootProject.extra
plugins {
kotlin("jvm")
}
@@ -8,13 +6,14 @@ subprojects {
apply(plugin = "org.jetbrains.kotlin.jvm")
dependencies {
implementation(project(":plugin-api"))
compileOnly(project(":plugin-api"))
}
tasks.jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
isZip64 = true
archiveBaseName.set("plugin-${project.name}")
manifest {
from("./src/main/resources/MANIFEST.MF")
}
@@ -27,19 +26,4 @@ subprojects {
from(sourceSets["main"].output.classesDirs)
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"))
}
}
-6
View File
@@ -3,13 +3,10 @@ plugins {
}
dependencies {
// Kotlin annotation processor
ksp("care.better.pf4j:pf4j-kotlin-symbol-processing:2.0.20-1.0.1")
// IGDB API client
implementation("io.github.husnjak:igdb-api-jvm:1.2.0")
compileOnly("org.slf4j:slf4j-api:2.0.16")
}
tasks.register<Copy>("copyDependencyClasses") {
@@ -20,9 +17,6 @@ tasks.register<Copy>("copyDependencyClasses") {
from(configurations.runtimeClasspath.get().map { project.zipTree(it) }) {
include("**/*.class")
}
from("src/main/resources/MANIFEST.MF") {
into("META-INF")
}
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.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",