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