From b597312a0ce023a0042394559933cf1dc38c8080 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 13 Aug 2020 11:17:11 +0600 Subject: [PATCH] updates fixes --- CHANGELOG.md | 4 ++++ build.gradle | 2 +- gradle.properties | 10 +++++----- gradle/wrapper/gradle-wrapper.properties | 2 +- .../github/insanusmokrassar/SauceNaoAPI/Launcher.kt | 5 +---- .../github/insanusmokrassar/SauceNaoAPI/SauceNaoAPI.kt | 10 ++++++---- .../SauceNaoAPI/SauceRequestSubject.kt | 2 +- .../SauceNaoAPI/exceptions/TooManyRequestsException.kt | 4 ++-- .../SauceNaoAPI/models/SauceNaoAnswer.kt | 4 ++-- .../utils/CommonMultivariantStringSerializer.kt | 10 +++++----- .../SauceNaoAPI/utils/MimeTypeDecoder.kt | 2 +- .../SauceNaoAPI/utils/RequestQuotaManager.kt | 2 +- .../insanusmokrassar/SauceNaoAPI/utils/TimeManager.kt | 2 +- 13 files changed, 31 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9777d9..b4fbddb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # SauceNaoAPI Changelog +## 0.5.0 + +* Versions updates + ## 0.4.0 * Update libraries versions diff --git a/build.gradle b/build.gradle index 90af049..250f5b6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -project.version = "0.4.4" +project.version = "0.5.0" project.group = "com.github.insanusmokrassar" buildscript { diff --git a/gradle.properties b/gradle.properties index e5203c2..2cf7165 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 31fe8ba..3d7bd11 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/Launcher.kt b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/Launcher.kt index 4fc576a..0de3855 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/Launcher.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/Launcher.kt @@ -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) { diff --git a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/SauceNaoAPI.kt b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/SauceNaoAPI.kt index 250ca17..2ff1e3b 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/SauceNaoAPI.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/SauceNaoAPI.kt @@ -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(builder) + val answerText = call.readText() logger.info(answerText) timeManager.addTimeAndClear() Json.nonstrict.parse( diff --git a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/SauceRequestSubject.kt b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/SauceRequestSubject.kt index 14039f4..573473e 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/SauceRequestSubject.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/SauceRequestSubject.kt @@ -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 diff --git a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/exceptions/TooManyRequestsException.kt b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/exceptions/TooManyRequestsException.kt index 4e213a6..6e450d8 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/exceptions/TooManyRequestsException.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/exceptions/TooManyRequestsException.kt @@ -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) { diff --git a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/models/SauceNaoAnswer.kt b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/models/SauceNaoAnswer.kt index f04ad16..bb36673 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/models/SauceNaoAnswer.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/models/SauceNaoAnswer.kt @@ -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 { - 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 diff --git a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/CommonMultivariantStringSerializer.kt b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/CommonMultivariantStringSerializer.kt index 0176fc8..2a48ce0 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/CommonMultivariantStringSerializer.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/CommonMultivariantStringSerializer.kt @@ -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 by StringSerializer { - private val stringArraySerializer = ArrayListSerializer(StringSerializer) +object CommonMultivariantStringSerializer : KSerializer 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() } diff --git a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/MimeTypeDecoder.kt b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/MimeTypeDecoder.kt index 988c17d..415909a 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/MimeTypeDecoder.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/MimeTypeDecoder.kt @@ -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 diff --git a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/RequestQuotaManager.kt b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/RequestQuotaManager.kt index 538ad86..5ce190b 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/RequestQuotaManager.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/RequestQuotaManager.kt @@ -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 diff --git a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/TimeManager.kt b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/TimeManager.kt index 40b2ed8..2b1d327 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/TimeManager.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/SauceNaoAPI/utils/TimeManager.kt @@ -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