updates fixes

This commit is contained in:
InsanusMokrassar 2020-08-13 11:17:11 +06:00
parent 541134d8a7
commit b597312a0c
13 changed files with 31 additions and 28 deletions

View File

@ -1,5 +1,9 @@
# SauceNaoAPI Changelog
## 0.5.0
* Versions updates
## 0.4.0
* Update libraries versions

View File

@ -1,4 +1,4 @@
project.version = "0.4.4"
project.version = "0.5.0"
project.group = "com.github.insanusmokrassar"
buildscript {

View File

@ -1,9 +1,9 @@
kotlin.code.style=official
kotlin_version=1.3.61
kotlin_coroutines_version=1.3.2
kotlin_serialisation_runtime_version=0.14.0
klock_version=1.8.3
ktor_version=1.2.6
kotlin_version=1.3.72
kotlin_coroutines_version=1.3.8
kotlin_serialisation_runtime_version=0.20.0
klock_version=1.11.14
ktor_version=1.3.2
project_public_name=SauceNao API
project_public_description=SauceNao API library

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip

View File

@ -1,12 +1,9 @@
package com.github.insanusmokrassar.SauceNaoAPI
import com.github.insanusmokrassar.SauceNaoAPI.utils.mimeType
import io.ktor.http.ContentType
import io.ktor.utils.io.streams.asInput
import kotlinx.coroutines.*
import kotlinx.io.core.readText
import kotlinx.io.streams.asInput
import java.io.File
import java.net.URLConnection
import java.nio.file.Files
suspend fun main(vararg args: String) {

View File

@ -10,12 +10,14 @@ import io.ktor.client.engine.okhttp.OkHttp
import io.ktor.client.features.ClientRequestException
import io.ktor.client.request.*
import io.ktor.client.request.forms.*
import io.ktor.client.response.readText
import io.ktor.client.statement.HttpResponse
import io.ktor.client.statement.readText
import io.ktor.http.*
import io.ktor.utils.io.core.Input
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import kotlinx.io.core.*
import kotlinx.serialization.json.Json
import java.io.Closeable
import java.util.logging.Logger
import kotlin.Result
import kotlin.coroutines.*
@ -134,8 +136,8 @@ data class SauceNaoAPI(
builder: HttpRequestBuilder
): SauceNaoAnswer {
return try {
val call = client.call(builder)
val answerText = call.response.readText()
val call = client.request<HttpResponse>(builder)
val answerText = call.readText()
logger.info(answerText)
timeManager.addTimeAndClear()
Json.nonstrict.parse(

View File

@ -1,7 +1,7 @@
package com.github.insanusmokrassar.SauceNaoAPI
import io.ktor.http.ContentType
import kotlinx.io.core.Input
import io.ktor.utils.io.core.Input
internal sealed class SauceRequestSubject

View File

@ -4,9 +4,9 @@ import com.github.insanusmokrassar.SauceNaoAPI.additional.LONG_TIME_RECALCULATIN
import com.github.insanusmokrassar.SauceNaoAPI.additional.SHORT_TIME_RECALCULATING_MILLIS
import com.soywiz.klock.TimeSpan
import io.ktor.client.features.ClientRequestException
import io.ktor.client.response.readText
import io.ktor.client.statement.readText
import io.ktor.http.HttpStatusCode.Companion.TooManyRequests
import kotlinx.io.IOException
import io.ktor.utils.io.errors.IOException
internal suspend fun ClientRequestException.sauceNaoAPIException(): Exception {
return when (response.status) {

View File

@ -1,7 +1,7 @@
package com.github.insanusmokrassar.SauceNaoAPI.models
import kotlinx.serialization.*
import kotlinx.serialization.internal.ArrayListSerializer
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.json.*
@Serializable
@ -13,7 +13,7 @@ data class SauceNaoAnswer internal constructor(
@Serializer(SauceNaoAnswer::class)
object SauceNaoAnswerSerializer : KSerializer<SauceNaoAnswer> {
private val resultsSerializer = ArrayListSerializer(Result.serializer())
private val resultsSerializer = ListSerializer(Result.serializer())
private const val headerField = "header"
private const val resultsField = "results"
private val serializer = Json.nonstrict

View File

@ -1,17 +1,17 @@
package com.github.insanusmokrassar.SauceNaoAPI.utils
import kotlinx.serialization.*
import kotlinx.serialization.internal.ArrayListSerializer
import kotlinx.serialization.internal.StringSerializer
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.builtins.serializer
@Serializer(String::class)
object CommonMultivariantStringSerializer : KSerializer<String> by StringSerializer {
private val stringArraySerializer = ArrayListSerializer(StringSerializer)
object CommonMultivariantStringSerializer : KSerializer<String> by String.serializer() {
private val stringArraySerializer = ListSerializer(String.serializer())
override fun deserialize(decoder: Decoder): String {
return try {
decoder.decodeSerializableValue(StringSerializer)
decoder.decodeSerializableValue(String.serializer())
} catch (e: Exception) {
decoder.decodeSerializableValue(stringArraySerializer).joinToString()
}

View File

@ -2,7 +2,7 @@ package com.github.insanusmokrassar.SauceNaoAPI.utils
import io.ktor.http.ContentType
import io.ktor.util.asStream
import kotlinx.io.core.Input
import io.ktor.utils.io.core.Input
import java.io.InputStream
import java.net.URLConnection

View File

@ -9,7 +9,7 @@ import com.github.insanusmokrassar.SauceNaoAPI.models.LimitsState
import com.soywiz.klock.DateTime
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import kotlinx.io.core.Closeable
import java.io.Closeable
import kotlin.coroutines.suspendCoroutine
import kotlin.math.max
import kotlin.math.min

View File

@ -7,7 +7,7 @@ import com.soywiz.klock.TimeSpan
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.launch
import kotlinx.io.core.Closeable
import java.io.Closeable
import kotlin.coroutines.Continuation
import kotlin.coroutines.suspendCoroutine