mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-17 00:30:04 +00:00
Use undocumented field release_date
Close client on Plugin.stop()
This commit is contained in:
+7
@@ -56,6 +56,11 @@ class SteamGridDbPlugin(wrapper: PluginWrapper) : ConfigurableGameyfinPlugin(wra
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun stop() {
|
||||||
|
client?.close()
|
||||||
|
client = null
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun authenticate(apiKey: String? = null) {
|
private suspend fun authenticate(apiKey: String? = null) {
|
||||||
log.debug("Authenticating on SteamGridDB API...")
|
log.debug("Authenticating on SteamGridDB API...")
|
||||||
|
|
||||||
@@ -83,6 +88,7 @@ class SteamGridDbPlugin(wrapper: PluginWrapper) : ConfigurableGameyfinPlugin(wra
|
|||||||
GameMetadata(
|
GameMetadata(
|
||||||
originalId = game.id.toString(),
|
originalId = game.id.toString(),
|
||||||
title = game.name,
|
title = game.name,
|
||||||
|
release = game.releaseDate,
|
||||||
coverUrls = grids?.map { URI(it.url) },
|
coverUrls = grids?.map { URI(it.url) },
|
||||||
headerUrls = heroes?.map { URI(it.url) }
|
headerUrls = heroes?.map { URI(it.url) }
|
||||||
)
|
)
|
||||||
@@ -101,6 +107,7 @@ class SteamGridDbPlugin(wrapper: PluginWrapper) : ConfigurableGameyfinPlugin(wra
|
|||||||
return@runBlocking GameMetadata(
|
return@runBlocking GameMetadata(
|
||||||
originalId = game.id.toString(),
|
originalId = game.id.toString(),
|
||||||
title = game.name,
|
title = game.name,
|
||||||
|
release = game.releaseDate,
|
||||||
coverUrls = grids?.map { URI(it.url) },
|
coverUrls = grids?.map { URI(it.url) },
|
||||||
headerUrls = heroes?.map { URI(it.url) }
|
headerUrls = heroes?.map { URI(it.url) }
|
||||||
)
|
)
|
||||||
|
|||||||
+6
-2
@@ -44,6 +44,10 @@ class SteamGridDbApiClient(private val apiKey: String) {
|
|||||||
return get("search/autocomplete/${term.encodeURLPath(encodeSlash = true, encodeEncoded = false)}", block).body()
|
return get("search/autocomplete/${term.encodeURLPath(encodeSlash = true, encodeEncoded = false)}", block).body()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun game(gameId: Int, block: HttpRequestBuilder.() -> Unit = {}): SteamGridDbGameResult {
|
||||||
|
return get("games/id/$gameId", block).body()
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun grids(gameId: Int, block: HttpRequestBuilder.() -> Unit = {}): SteamGridDbGridResult {
|
suspend fun grids(gameId: Int, block: HttpRequestBuilder.() -> Unit = {}): SteamGridDbGridResult {
|
||||||
return get("grids/game/$gameId") {
|
return get("grids/game/$gameId") {
|
||||||
url {
|
url {
|
||||||
@@ -59,8 +63,8 @@ class SteamGridDbApiClient(private val apiKey: String) {
|
|||||||
}.body()
|
}.body()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun game(gameId: Int, block: HttpRequestBuilder.() -> Unit = {}): SteamGridDbGameResult {
|
fun close() {
|
||||||
return get("games/id/$gameId", block).body()
|
client.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun get(endpoint: String, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse {
|
private suspend fun get(endpoint: String, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse {
|
||||||
|
|||||||
+7
-1
@@ -1,10 +1,16 @@
|
|||||||
package org.gameyfin.plugins.metadata.steamgriddb.dto
|
package org.gameyfin.plugins.metadata.steamgriddb.dto
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
import org.gameyfin.plugins.metadata.steamgriddb.util.InstantEpochSecondsSerializer
|
||||||
|
import java.time.Instant
|
||||||
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SteamGridDbGame(
|
data class SteamGridDbGame(
|
||||||
val id: Int,
|
val id: Int,
|
||||||
val name: String
|
val name: String,
|
||||||
|
@SerialName("release_date")
|
||||||
|
@Serializable(with = InstantEpochSecondsSerializer::class)
|
||||||
|
val releaseDate: Instant? = null
|
||||||
)
|
)
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
package org.gameyfin.plugins.metadata.steamgriddb.util
|
||||||
|
|
||||||
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
|
import kotlinx.serialization.KSerializer
|
||||||
|
import kotlinx.serialization.descriptors.PrimitiveKind
|
||||||
|
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
|
||||||
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
|
import kotlinx.serialization.encoding.Decoder
|
||||||
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
import java.time.Instant
|
||||||
|
|
||||||
|
@OptIn(ExperimentalSerializationApi::class)
|
||||||
|
object InstantEpochSecondsSerializer : KSerializer<Instant?> {
|
||||||
|
override val descriptor: SerialDescriptor =
|
||||||
|
PrimitiveSerialDescriptor("InstantEpochSeconds", PrimitiveKind.LONG)
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: Instant?) {
|
||||||
|
if (value == null) {
|
||||||
|
encoder.encodeNull()
|
||||||
|
} else {
|
||||||
|
encoder.encodeLong(value.epochSecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): Instant? {
|
||||||
|
return if (decoder.decodeNotNullMark()) {
|
||||||
|
Instant.ofEpochSecond(decoder.decodeLong())
|
||||||
|
} else {
|
||||||
|
decoder.decodeNull()
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user