update ktor to version 2.0.3
This commit is contained in:
@ -24,11 +24,12 @@ package org.mosad.teapod.util.metadb
|
||||
|
||||
import android.util.Log
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.features.*
|
||||
import io.ktor.client.features.json.*
|
||||
import io.ktor.client.features.json.serializer.*
|
||||
import io.ktor.client.call.*
|
||||
import io.ktor.client.plugins.*
|
||||
import io.ktor.client.plugins.contentnegotiation.*
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.http.*
|
||||
import io.ktor.serialization.kotlinx.json.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.decodeFromString
|
||||
@ -40,8 +41,8 @@ object MetaDBController {
|
||||
private const val repoUrl = "https://gitlab.com/Seil0/teapodmetadb/-/raw/main/crunchy/"
|
||||
|
||||
private val client = HttpClient {
|
||||
install(JsonFeature) {
|
||||
serializer = KotlinxSerializer(Json)
|
||||
install(ContentNegotiation) {
|
||||
json()
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +50,7 @@ object MetaDBController {
|
||||
private var metaCacheList = arrayListOf<Meta>()
|
||||
|
||||
suspend fun list() = withContext(Dispatchers.IO) {
|
||||
val raw: String = client.get("$repoUrl/list.json")
|
||||
val raw: String = client.get("$repoUrl/list.json").body()
|
||||
mediaList = Json.decodeFromString(raw)
|
||||
}
|
||||
|
||||
@ -70,7 +71,7 @@ object MetaDBController {
|
||||
|
||||
private suspend fun getTVShowMetadataFromDB(crSeriesId: String): TVShowMeta? = withContext(Dispatchers.IO) {
|
||||
return@withContext try {
|
||||
val raw: String = client.get("$repoUrl/tv/$crSeriesId/media.json")
|
||||
val raw: String = client.get("$repoUrl/tv/$crSeriesId/media.json").body()
|
||||
val meta: TVShowMeta = Json.decodeFromString(raw)
|
||||
metaCacheList.add(meta)
|
||||
|
||||
|
@ -25,10 +25,10 @@ package org.mosad.teapod.util.tmdb
|
||||
import android.util.Log
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.call.*
|
||||
import io.ktor.client.features.json.*
|
||||
import io.ktor.client.features.json.serializer.*
|
||||
import io.ktor.client.plugins.contentnegotiation.*
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.statement.*
|
||||
import io.ktor.serialization.kotlinx.json.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.invoke
|
||||
@ -46,10 +46,11 @@ import org.mosad.teapod.util.concatenate
|
||||
class TMDBApiController {
|
||||
private val classTag = javaClass.name
|
||||
|
||||
private val json = Json { ignoreUnknownKeys = true }
|
||||
private val client = HttpClient {
|
||||
install(JsonFeature) {
|
||||
serializer = KotlinxSerializer(json)
|
||||
install(ContentNegotiation) {
|
||||
json(Json {
|
||||
ignoreUnknownKeys = true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +79,7 @@ class TMDBApiController {
|
||||
}
|
||||
}
|
||||
|
||||
response.receive<T>()
|
||||
response.body<T>()
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user