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 # SauceNaoAPI Changelog
## 0.5.0
* Versions updates
## 0.4.0 ## 0.4.0
* Update libraries versions * Update libraries versions

View File

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

View File

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

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists 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 package com.github.insanusmokrassar.SauceNaoAPI
import com.github.insanusmokrassar.SauceNaoAPI.utils.mimeType
import io.ktor.http.ContentType import io.ktor.http.ContentType
import io.ktor.utils.io.streams.asInput
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.io.core.readText
import kotlinx.io.streams.asInput
import java.io.File import java.io.File
import java.net.URLConnection
import java.nio.file.Files import java.nio.file.Files
suspend fun main(vararg args: String) { 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.features.ClientRequestException
import io.ktor.client.request.* import io.ktor.client.request.*
import io.ktor.client.request.forms.* 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.http.*
import io.ktor.utils.io.core.Input
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.Channel
import kotlinx.io.core.*
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import java.io.Closeable
import java.util.logging.Logger import java.util.logging.Logger
import kotlin.Result import kotlin.Result
import kotlin.coroutines.* import kotlin.coroutines.*
@ -134,8 +136,8 @@ data class SauceNaoAPI(
builder: HttpRequestBuilder builder: HttpRequestBuilder
): SauceNaoAnswer { ): SauceNaoAnswer {
return try { return try {
val call = client.call(builder) val call = client.request<HttpResponse>(builder)
val answerText = call.response.readText() val answerText = call.readText()
logger.info(answerText) logger.info(answerText)
timeManager.addTimeAndClear() timeManager.addTimeAndClear()
Json.nonstrict.parse( Json.nonstrict.parse(

View File

@ -1,7 +1,7 @@
package com.github.insanusmokrassar.SauceNaoAPI package com.github.insanusmokrassar.SauceNaoAPI
import io.ktor.http.ContentType import io.ktor.http.ContentType
import kotlinx.io.core.Input import io.ktor.utils.io.core.Input
internal sealed class SauceRequestSubject 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.github.insanusmokrassar.SauceNaoAPI.additional.SHORT_TIME_RECALCULATING_MILLIS
import com.soywiz.klock.TimeSpan import com.soywiz.klock.TimeSpan
import io.ktor.client.features.ClientRequestException 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 io.ktor.http.HttpStatusCode.Companion.TooManyRequests
import kotlinx.io.IOException import io.ktor.utils.io.errors.IOException
internal suspend fun ClientRequestException.sauceNaoAPIException(): Exception { internal suspend fun ClientRequestException.sauceNaoAPIException(): Exception {
return when (response.status) { return when (response.status) {

View File

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

View File

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

View File

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

View File

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

View File

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