Merge pull request #48 from InsanusMokrassar/0.7.0

0.7.0
This commit is contained in:
InsanusMokrassar 2020-12-02 14:46:36 +06:00 committed by GitHub
commit c231b956b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 113 additions and 122 deletions

View File

@ -1,5 +1,15 @@
# SauceNaoAPI Changelog
## 0.7.0
**BREAKING CHANGES: PACKAGE HAS BEEN CHANGED FROM `com.insanusmokrassar` to `dev.inmo`**
Migration:
* Packages in the whole project were changed `com.insanusmokrassar.SauceNaoAPI` -> `dev.inmo.saucenaoapi`
* Change implementation in your gradle files: `implementation "com.insanusmokrassar:SauceNaoAPI:*"` ->
`implementation "dev.inmo:saucenaoapi:*"`
## 0.6.2
* Versions updates:

View File

@ -18,7 +18,7 @@ plugins {
}
project.version = "$library_version"
project.group = "com.insanusmokrassar"
project.group = "dev.inmo"
apply from: "publish.gradle"
apply from: "github_release.gradle"

View File

@ -7,4 +7,4 @@ ktor_version=1.4.3
gradle_github_release_plugin_version=2.2.12
library_version=0.6.2
library_version=0.7.0

View File

@ -1 +1 @@
{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}-mpp","packageVcs":"https://github.com/InsanusMokrassar/${project.name}","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"SauceNao API","description":"SauceNao API library","url":"https://insanusmokrassar.github.io/${project.name}","vcsUrl":"https://github.com/insanusmokrassar/${project.name}.git","developers":[{"id":"InsanusMokrassar","name":"Ovsyannikov Alexey","eMail":"ovsyannikov.alexey95@gmail.com"}]}}
{"bintrayConfig":{"repo":"SauceNaoAPI","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/${project.name}","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"SauceNao API","description":"SauceNao API library","url":"https://insanusmokrassar.github.io/${project.name}","vcsUrl":"https://github.com/insanusmokrassar/${project.name}.git","developers":[{"id":"InsanusMokrassar","name":"Ovsyannikov Alexey","eMail":"ovsyannikov.alexey95@gmail.com"}]}}

View File

@ -57,7 +57,7 @@ publishing {
repositories {
maven {
name = "bintray"
url = uri("https://api.bintray.com/maven/${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}/InsanusMokrassar/${project.name}-mpp/;publish=1;override=1")
url = uri("https://api.bintray.com/maven/${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}/SauceNaoAPI/${project.name}/;publish=1;override=1")
credentials {
username = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')
password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')

View File

@ -1 +1 @@
rootProject.name = 'SauceNaoAPI'
rootProject.name = 'saucenaoapi'

View File

@ -1,17 +0,0 @@
package com.insanusmokrassar.SauceNaoAPI
sealed class OutputType {
abstract val typeCode: Int
}
object HtmlOutputType : OutputType() {
override val typeCode: Int = 0
}
object XmlOutputType : OutputType() {
override val typeCode: Int = 1
}
object JsonOutputType : OutputType() {
override val typeCode: Int = 2
}

View File

@ -1,23 +0,0 @@
package com.insanusmokrassar.SauceNaoAPI.additional
import com.insanusmokrassar.SauceNaoAPI.additional.header.ResultMetaInfo
import com.insanusmokrassar.SauceNaoAPI.additional.header.adapted
import com.insanusmokrassar.SauceNaoAPI.additional.results.AdaptedResult
import com.insanusmokrassar.SauceNaoAPI.additional.results.adapted
import com.insanusmokrassar.SauceNaoAPI.models.SauceNaoAnswer
val SauceNaoAnswer.adapted: AdaptedAnswer
get() = header.adapted.let { resultMetainfo ->
val adaptedResults = results.map {
it.adapted(resultMetainfo)
}
AdaptedAnswer(
resultMetainfo,
adaptedResults
)
}
data class AdaptedAnswer(
val resultMetaInfo: ResultMetaInfo,
val results: List<AdaptedResult>
)

View File

@ -1,9 +0,0 @@
package com.insanusmokrassar.SauceNaoAPI.additional.results
import com.insanusmokrassar.SauceNaoAPI.additional.header.IndexInfo
data class ResultHeader(
val similarity: Float,
val thumbnail: String,
val index: IndexInfo
)

View File

@ -1,18 +0,0 @@
package com.insanusmokrassar.SauceNaoAPI.utils
import com.insanusmokrassar.SauceNaoAPI.additional.LONG_TIME_RECALCULATING_MILLIS
import com.insanusmokrassar.SauceNaoAPI.additional.SHORT_TIME_RECALCULATING_MILLIS
import com.insanusmokrassar.SauceNaoAPI.models.Header
import com.soywiz.klock.DateTime
internal suspend fun calculateSleepTime(
header: Header,
mostOldestInShortPeriodGetter: suspend () -> DateTime?,
mostOldestInLongPeriodGetter: suspend () -> DateTime?
): DateTime? {
return when {
header.longRemaining < 1 -> mostOldestInLongPeriodGetter() ?.plus(LONG_TIME_RECALCULATING_MILLIS)
header.shortRemaining < 1 -> mostOldestInShortPeriodGetter() ?.plus(SHORT_TIME_RECALCULATING_MILLIS)
else -> null
}
}

View File

@ -0,0 +1,17 @@
package dev.inmo.saucenaoapi
sealed class OutputType {
abstract val typeCode: Int
}
object HtmlOutputType : dev.inmo.saucenaoapi.OutputType() {
override val typeCode: Int = 0
}
object XmlOutputType : dev.inmo.saucenaoapi.OutputType() {
override val typeCode: Int = 1
}
object JsonOutputType : dev.inmo.saucenaoapi.OutputType() {
override val typeCode: Int = 2
}

View File

@ -1,9 +1,9 @@
package com.insanusmokrassar.SauceNaoAPI
package dev.inmo.saucenaoapi
import com.insanusmokrassar.SauceNaoAPI.exceptions.TooManyRequestsException
import com.insanusmokrassar.SauceNaoAPI.exceptions.sauceNaoAPIException
import com.insanusmokrassar.SauceNaoAPI.models.*
import com.insanusmokrassar.SauceNaoAPI.utils.*
import dev.inmo.saucenaoapi.exceptions.TooManyRequestsException
import dev.inmo.saucenaoapi.exceptions.sauceNaoAPIException
import dev.inmo.saucenaoapi.models.*
import dev.inmo.saucenaoapi.utils.*
import io.ktor.client.HttpClient
import io.ktor.client.features.ClientRequestException
import io.ktor.client.request.*
@ -40,7 +40,7 @@ val defaultSauceNaoParser = Json {
data class SauceNaoAPI(
private val apiToken: String? = null,
private val outputType: OutputType = JsonOutputType,
private val outputType: dev.inmo.saucenaoapi.OutputType = dev.inmo.saucenaoapi.JsonOutputType,
private val client: HttpClient = HttpClient(),
private val searchUrl: String = SEARCH_URL,
private val scope: CoroutineScope = CoroutineScope(Dispatchers.Default),

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.SauceNaoAPI
package dev.inmo.saucenaoapi
import io.ktor.http.ContentType
import io.ktor.utils.io.core.Input

View File

@ -0,0 +1,23 @@
package dev.inmo.saucenaoapi.additional
import dev.inmo.saucenaoapi.additional.header.ResultMetaInfo
import dev.inmo.saucenaoapi.additional.header.adapted
import dev.inmo.saucenaoapi.additional.results.AdaptedResult
import dev.inmo.saucenaoapi.additional.results.adapted
import dev.inmo.saucenaoapi.models.SauceNaoAnswer
val SauceNaoAnswer.adapted: AdaptedAnswer
get() = header.adapted.let { resultMetainfo ->
val adaptedResults = results.map {
it.adapted(resultMetainfo)
}
AdaptedAnswer(
resultMetainfo,
adaptedResults
)
}
data class AdaptedAnswer(
val resultMetaInfo: ResultMetaInfo,
val results: List<AdaptedResult>
)

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.SauceNaoAPI.additional
package dev.inmo.saucenaoapi.additional
import com.soywiz.klock.TimeSpan

View File

@ -1,7 +1,7 @@
package com.insanusmokrassar.SauceNaoAPI.additional.header
package dev.inmo.saucenaoapi.additional.header
import com.insanusmokrassar.SauceNaoAPI.additional.*
import com.insanusmokrassar.SauceNaoAPI.models.Header
import dev.inmo.saucenaoapi.additional.*
import dev.inmo.saucenaoapi.models.Header
val Header.shortLimitStatus: LimitStatus
get() = LimitStatus(

View File

@ -1,6 +1,6 @@
package com.insanusmokrassar.SauceNaoAPI.additional.header
package dev.inmo.saucenaoapi.additional.header
import com.insanusmokrassar.SauceNaoAPI.models.Header
import dev.inmo.saucenaoapi.models.Header
data class IndexInfo(
val id: Int,

View File

@ -1,6 +1,6 @@
package com.insanusmokrassar.SauceNaoAPI.additional.header
package dev.inmo.saucenaoapi.additional.header
import com.insanusmokrassar.SauceNaoAPI.models.Header
import dev.inmo.saucenaoapi.models.Header
val Header.queryPreview
get() = QueryResultPreview(

View File

@ -1,6 +1,6 @@
package com.insanusmokrassar.SauceNaoAPI.additional.header
package dev.inmo.saucenaoapi.additional.header
import com.insanusmokrassar.SauceNaoAPI.models.Header
import dev.inmo.saucenaoapi.models.Header
data class ResultMetaInfo(
val accountInfo: AccountInfo = AccountInfo(),

View File

@ -1,9 +1,9 @@
package com.insanusmokrassar.SauceNaoAPI.additional.results
package dev.inmo.saucenaoapi.additional.results
import com.insanusmokrassar.SauceNaoAPI.additional.header.IndexInfo
import com.insanusmokrassar.SauceNaoAPI.additional.header.ResultMetaInfo
import com.insanusmokrassar.SauceNaoAPI.models.Result
import com.insanusmokrassar.SauceNaoAPI.models.ResultData
import dev.inmo.saucenaoapi.additional.header.IndexInfo
import dev.inmo.saucenaoapi.additional.header.ResultMetaInfo
import dev.inmo.saucenaoapi.models.Result
import dev.inmo.saucenaoapi.models.ResultData
fun Result.adapted(
resultMetaInfo: ResultMetaInfo

View File

@ -0,0 +1,9 @@
package dev.inmo.saucenaoapi.additional.results
import dev.inmo.saucenaoapi.additional.header.IndexInfo
data class ResultHeader(
val similarity: Float,
val thumbnail: String,
val index: IndexInfo
)

View File

@ -1,7 +1,7 @@
package com.insanusmokrassar.SauceNaoAPI.exceptions
package dev.inmo.saucenaoapi.exceptions
import com.insanusmokrassar.SauceNaoAPI.additional.LONG_TIME_RECALCULATING_MILLIS
import com.insanusmokrassar.SauceNaoAPI.additional.SHORT_TIME_RECALCULATING_MILLIS
import dev.inmo.saucenaoapi.additional.LONG_TIME_RECALCULATING_MILLIS
import dev.inmo.saucenaoapi.additional.SHORT_TIME_RECALCULATING_MILLIS
import com.soywiz.klock.TimeSpan
import io.ktor.client.features.ClientRequestException
import io.ktor.client.statement.readText

View File

@ -1,6 +1,6 @@
package com.insanusmokrassar.SauceNaoAPI.models
package dev.inmo.saucenaoapi.models
import com.insanusmokrassar.SauceNaoAPI.defaultSauceNaoParser
import dev.inmo.saucenaoapi.defaultSauceNaoParser
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.SerialDescriptor

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.SauceNaoAPI.models
package dev.inmo.saucenaoapi.models
import kotlinx.serialization.Serializable

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.SauceNaoAPI.models
package dev.inmo.saucenaoapi.models
import kotlinx.serialization.Serializable

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.SauceNaoAPI.models
package dev.inmo.saucenaoapi.models
import kotlinx.serialization.Serializable

View File

@ -1,6 +1,6 @@
package com.insanusmokrassar.SauceNaoAPI.models
package dev.inmo.saucenaoapi.models
import com.insanusmokrassar.SauceNaoAPI.utils.CommonMultivariantStringSerializer
import dev.inmo.saucenaoapi.utils.CommonMultivariantStringSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.SauceNaoAPI.models
package dev.inmo.saucenaoapi.models
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

View File

@ -1,6 +1,6 @@
package com.insanusmokrassar.SauceNaoAPI.models
package dev.inmo.saucenaoapi.models
import com.insanusmokrassar.SauceNaoAPI.defaultSauceNaoParser
import dev.inmo.saucenaoapi.defaultSauceNaoParser
import kotlinx.serialization.*
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.encoding.Decoder

View File

@ -1,8 +1,7 @@
package com.insanusmokrassar.SauceNaoAPI.utils
package dev.inmo.saucenaoapi.utils
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializer
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.json.*

View File

@ -1,11 +1,11 @@
package com.insanusmokrassar.SauceNaoAPI.utils
package dev.inmo.saucenaoapi.utils
import com.insanusmokrassar.SauceNaoAPI.additional.LONG_TIME_RECALCULATING_MILLIS
import com.insanusmokrassar.SauceNaoAPI.additional.SHORT_TIME_RECALCULATING_MILLIS
import com.insanusmokrassar.SauceNaoAPI.exceptions.TooManyRequestsException
import com.insanusmokrassar.SauceNaoAPI.exceptions.TooManyRequestsLongException
import com.insanusmokrassar.SauceNaoAPI.models.Header
import com.insanusmokrassar.SauceNaoAPI.models.LimitsState
import dev.inmo.saucenaoapi.additional.LONG_TIME_RECALCULATING_MILLIS
import dev.inmo.saucenaoapi.additional.SHORT_TIME_RECALCULATING_MILLIS
import dev.inmo.saucenaoapi.exceptions.TooManyRequestsException
import dev.inmo.saucenaoapi.exceptions.TooManyRequestsLongException
import dev.inmo.saucenaoapi.models.Header
import dev.inmo.saucenaoapi.models.LimitsState
import com.soywiz.klock.DateTime
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.SauceNaoAPI.utils
package dev.inmo.saucenaoapi.utils
import kotlinx.coroutines.supervisorScope

View File

@ -1,7 +1,7 @@
package com.insanusmokrassar.SauceNaoAPI.utils
package dev.inmo.saucenaoapi.utils
import com.insanusmokrassar.SauceNaoAPI.additional.LONG_TIME_RECALCULATING_MILLIS
import com.insanusmokrassar.SauceNaoAPI.additional.SHORT_TIME_RECALCULATING_MILLIS
import dev.inmo.saucenaoapi.additional.LONG_TIME_RECALCULATING_MILLIS
import dev.inmo.saucenaoapi.additional.SHORT_TIME_RECALCULATING_MILLIS
import com.soywiz.klock.DateTime
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.Channel

View File

@ -1,5 +1,5 @@
import com.insanusmokrassar.SauceNaoAPI.SauceNaoAPI
import com.insanusmokrassar.SauceNaoAPI.utils.useSafe
import dev.inmo.saucenaoapi.SauceNaoAPI
import dev.inmo.saucenaoapi.utils.useSafe
import io.ktor.http.ContentType
import io.ktor.utils.io.streams.asInput
import kotlinx.coroutines.*