mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-13 16:40:01 +00:00
Refactor GameyfinPlugin and ConfigurableGameyfinPlugin to fix SLF4J issue
This commit is contained in:
@@ -66,8 +66,7 @@ dependencies {
|
||||
implementation("ch.digitalfondue.mjml4j:mjml4j:1.0.3")
|
||||
|
||||
// Plugins
|
||||
implementation(project(":plugin-api"))
|
||||
ksp("care.better.pf4j:pf4j-kotlin-symbol-processing:${rootProject.extra["pf4jKspVersion"]}")
|
||||
compileOnly(project(":plugin-api"))
|
||||
|
||||
// Utils
|
||||
implementation("org.apache.tika:tika-core:3.1.0")
|
||||
|
||||
@@ -30,7 +30,7 @@ class DownloadEndpoint(
|
||||
return when (download) {
|
||||
is FileDownload -> {
|
||||
ResponseEntity.ok()
|
||||
.header("Content-Disposition", "attachment; filename=\"${game.title}.zip\"")
|
||||
.header("Content-Disposition", "attachment; filename=\"${game.title}.${download.fileExtension}\"")
|
||||
.body(StreamingResponseBody { outputStream ->
|
||||
download.data.copyTo(outputStream)
|
||||
})
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package de.grimsi.gameyfin.pluginapi.core
|
||||
|
||||
import org.pf4j.PluginWrapper
|
||||
|
||||
abstract class ConfigurableGameyfinPlugin(wrapper: PluginWrapper) : GameyfinPlugin(wrapper), Configurable {
|
||||
|
||||
companion object {
|
||||
lateinit var plugin: ConfigurableGameyfinPlugin
|
||||
private set
|
||||
}
|
||||
|
||||
init {
|
||||
plugin = this
|
||||
}
|
||||
|
||||
override var config: Map<String, String?> = emptyMap()
|
||||
}
|
||||
@@ -8,6 +8,13 @@ abstract class GameyfinPlugin(wrapper: PluginWrapper) : Plugin(wrapper) {
|
||||
companion object {
|
||||
const val LOGO_FILE_NAME: String = "logo"
|
||||
val SUPPORTED_LOGO_FORMATS: List<String> = listOf("png", "jpg", "jpeg", "gif", "svg", "webp")
|
||||
|
||||
lateinit var plugin: GameyfinPlugin
|
||||
private set
|
||||
}
|
||||
|
||||
init {
|
||||
plugin = this
|
||||
}
|
||||
|
||||
fun hasLogo(): Boolean {
|
||||
|
||||
+19
-33
@@ -1,15 +1,12 @@
|
||||
package de.grimsi.gameyfin.plugins.directdownload
|
||||
|
||||
import de.grimsi.gameyfin.pluginapi.core.Configurable
|
||||
import de.grimsi.gameyfin.pluginapi.core.GameyfinPlugin
|
||||
import de.grimsi.gameyfin.pluginapi.core.ConfigurableGameyfinPlugin
|
||||
import de.grimsi.gameyfin.pluginapi.core.PluginConfigElement
|
||||
import de.grimsi.gameyfin.pluginapi.download.Download
|
||||
import de.grimsi.gameyfin.pluginapi.download.DownloadProvider
|
||||
import de.grimsi.gameyfin.pluginapi.download.FileDownload
|
||||
import org.pf4j.Extension
|
||||
import org.pf4j.PluginWrapper
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.io.PipedInputStream
|
||||
@@ -24,33 +21,7 @@ import kotlin.io.path.extension
|
||||
import kotlin.io.path.fileSize
|
||||
import kotlin.io.path.isDirectory
|
||||
|
||||
class DirectDownloadPlugin(wrapper: PluginWrapper) : GameyfinPlugin(wrapper), Configurable {
|
||||
companion object {
|
||||
lateinit var plugin: DirectDownloadPlugin
|
||||
private set
|
||||
}
|
||||
|
||||
init {
|
||||
plugin = this
|
||||
}
|
||||
|
||||
val log: Logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
enum class CompressionMode {
|
||||
NONE,
|
||||
FAST,
|
||||
BEST;
|
||||
|
||||
companion object {
|
||||
fun toDeflaterLevel(mode: CompressionMode): Int {
|
||||
return when (mode) {
|
||||
NONE -> Deflater.NO_COMPRESSION
|
||||
FAST -> Deflater.BEST_SPEED
|
||||
BEST -> Deflater.BEST_COMPRESSION
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class DirectDownloadPlugin(wrapper: PluginWrapper) : ConfigurableGameyfinPlugin(wrapper) {
|
||||
|
||||
override val configMetadata: List<PluginConfigElement> = listOf(
|
||||
PluginConfigElement(
|
||||
@@ -60,8 +31,6 @@ class DirectDownloadPlugin(wrapper: PluginWrapper) : GameyfinPlugin(wrapper), Co
|
||||
)
|
||||
)
|
||||
|
||||
override var config: Map<String, String?> = emptyMap()
|
||||
|
||||
override fun validateConfig(config: Map<String, String?>): Boolean {
|
||||
return config["compressionMode"]?.let {
|
||||
try {
|
||||
@@ -149,4 +118,21 @@ class DirectDownloadPlugin(wrapper: PluginWrapper) : GameyfinPlugin(wrapper), Co
|
||||
return pipeIn
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum class CompressionMode {
|
||||
NONE,
|
||||
FAST,
|
||||
BEST;
|
||||
|
||||
companion object {
|
||||
fun toDeflaterLevel(mode: CompressionMode): Int {
|
||||
return when (mode) {
|
||||
NONE -> Deflater.NO_COMPRESSION
|
||||
FAST -> Deflater.BEST_SPEED
|
||||
BEST -> Deflater.BEST_COMPRESSION
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,18 @@ plugins {
|
||||
dependencies {
|
||||
ksp("care.better.pf4j:pf4j-kotlin-symbol-processing:${rootProject.extra["pf4jKspVersion"]}")
|
||||
|
||||
implementation("io.ktor:ktor-client-core:$ktor_version")
|
||||
implementation("io.ktor:ktor-client-cio:$ktor_version")
|
||||
implementation("io.ktor:ktor-client-content-negotiation:$ktor_version")
|
||||
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktor_version")
|
||||
implementation("io.ktor:ktor-client-core:$ktor_version") {
|
||||
exclude(group = "org.slf4j", module = "slf4j-api")
|
||||
}
|
||||
implementation("io.ktor:ktor-client-cio:$ktor_version") {
|
||||
exclude(group = "org.slf4j", module = "slf4j-api")
|
||||
}
|
||||
implementation("io.ktor:ktor-client-content-negotiation:$ktor_version") {
|
||||
exclude(group = "org.slf4j", module = "slf4j-api")
|
||||
}
|
||||
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktor_version") {
|
||||
exclude(group = "org.slf4j", module = "slf4j-api")
|
||||
}
|
||||
|
||||
implementation("me.xdrop:fuzzywuzzy:1.4.0")
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import kotlinx.serialization.json.Json
|
||||
import me.xdrop.fuzzywuzzy.FuzzySearch
|
||||
import org.pf4j.Extension
|
||||
import org.pf4j.PluginWrapper
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.net.URI
|
||||
import java.net.URLEncoder
|
||||
@@ -37,7 +36,7 @@ class SteamPlugin(wrapper: PluginWrapper) : GameyfinPlugin(wrapper) {
|
||||
|
||||
@Extension
|
||||
class SteamMetadataProvider : GameMetadataProvider {
|
||||
val log: Logger = LoggerFactory.getLogger(javaClass)
|
||||
private val log = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
val client = HttpClient(CIO) {
|
||||
install(ContentNegotiation) {
|
||||
|
||||
@@ -8,8 +8,16 @@ plugins {
|
||||
dependencies {
|
||||
ksp("care.better.pf4j:pf4j-kotlin-symbol-processing:${rootProject.extra["pf4jKspVersion"]}")
|
||||
|
||||
implementation("io.ktor:ktor-client-core:${ktor_version}")
|
||||
implementation("io.ktor:ktor-client-cio:${ktor_version}")
|
||||
implementation("io.ktor:ktor-client-content-negotiation:${ktor_version}")
|
||||
implementation("io.ktor:ktor-serialization-kotlinx-json:${ktor_version}")
|
||||
implementation("io.ktor:ktor-client-core:${ktor_version}") {
|
||||
exclude(group = "org.slf4j", module = "slf4j-api")
|
||||
}
|
||||
implementation("io.ktor:ktor-client-cio:${ktor_version}") {
|
||||
exclude(group = "org.slf4j", module = "slf4j-api")
|
||||
}
|
||||
implementation("io.ktor:ktor-client-content-negotiation:${ktor_version}") {
|
||||
exclude(group = "org.slf4j", module = "slf4j-api")
|
||||
}
|
||||
implementation("io.ktor:ktor-serialization-kotlinx-json:${ktor_version}") {
|
||||
exclude(group = "org.slf4j", module = "slf4j-api")
|
||||
}
|
||||
}
|
||||
+2
-8
@@ -1,7 +1,6 @@
|
||||
package de.grimsi.gameyfin.plugins.steamgriddb
|
||||
|
||||
import de.grimsi.gameyfin.pluginapi.core.Configurable
|
||||
import de.grimsi.gameyfin.pluginapi.core.GameyfinPlugin
|
||||
import de.grimsi.gameyfin.pluginapi.core.ConfigurableGameyfinPlugin
|
||||
import de.grimsi.gameyfin.pluginapi.core.PluginConfigElement
|
||||
import de.grimsi.gameyfin.pluginapi.core.PluginConfigError
|
||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.GameMetadata
|
||||
@@ -12,18 +11,14 @@ import de.grimsi.gameyfin.plugins.steamgriddb.dto.SteamGridDbGrid
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.pf4j.Extension
|
||||
import org.pf4j.PluginWrapper
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.net.URI
|
||||
|
||||
class SteamGridDbPlugin(wrapper: PluginWrapper) : GameyfinPlugin(wrapper), Configurable {
|
||||
class SteamGridDbPlugin(wrapper: PluginWrapper) : ConfigurableGameyfinPlugin(wrapper) {
|
||||
|
||||
companion object {
|
||||
private var client: SteamGridDbApiClient? = null
|
||||
}
|
||||
|
||||
val log: Logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
override val configMetadata: List<PluginConfigElement> = listOf(
|
||||
PluginConfigElement(
|
||||
key = "apiKey",
|
||||
@@ -32,7 +27,6 @@ class SteamGridDbPlugin(wrapper: PluginWrapper) : GameyfinPlugin(wrapper), Confi
|
||||
isSecret = true
|
||||
)
|
||||
)
|
||||
override var config: Map<String, String?> = emptyMap()
|
||||
|
||||
override fun validateConfig(config: Map<String, String?>): Boolean {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user