mirror of
https://github.com/InsanusMokrassar/SauceNaoAPI.git
synced 2024-11-16 20:03:46 +00:00
Compare commits
No commits in common. "master" and "v0.13.0" have entirely different histories.
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,4 +8,3 @@ settings.xml
|
|||||||
.gradle/
|
.gradle/
|
||||||
build/
|
build/
|
||||||
out/
|
out/
|
||||||
kotlin-js-store/
|
|
||||||
|
49
CHANGELOG.md
49
CHANGELOG.md
@ -1,54 +1,5 @@
|
|||||||
# SauceNaoAPI Changelog
|
# SauceNaoAPI Changelog
|
||||||
|
|
||||||
## 0.17.2
|
|
||||||
|
|
||||||
* Versions:
|
|
||||||
* `Coroutines`: `1.7.3`
|
|
||||||
* `Ktor`: `2.3.4`
|
|
||||||
* `MicroUtils`: `0.19.9`
|
|
||||||
|
|
||||||
## 0.17.1
|
|
||||||
|
|
||||||
* Versions:
|
|
||||||
* `Coroutines`: `1.7.2`
|
|
||||||
* `Ktor`: `2.3.2`
|
|
||||||
* `MicroUtils`: `0.19.7`
|
|
||||||
|
|
||||||
## 0.17.0
|
|
||||||
|
|
||||||
* Versions:
|
|
||||||
* `Kotlin`: `1.8.22`
|
|
||||||
* `Serialization`: `1.5.1`
|
|
||||||
* `Ktor`: `2.3.1`
|
|
||||||
* `MicroUtils`: `0.19.2`
|
|
||||||
* `Klock`: `4.0.3`
|
|
||||||
|
|
||||||
## 0.16.0
|
|
||||||
|
|
||||||
Add `MicroUtils` as used micro utils
|
|
||||||
|
|
||||||
* Versions:
|
|
||||||
* `Kotlin`: `1.8.21`
|
|
||||||
* `Ktor`: `2.3.0`
|
|
||||||
|
|
||||||
## 0.15.1
|
|
||||||
|
|
||||||
* Versions:
|
|
||||||
* `Ktor`: `2.2.4`
|
|
||||||
|
|
||||||
## 0.15.0
|
|
||||||
|
|
||||||
* Versions:
|
|
||||||
* `Kotlin`: `1.8.10`
|
|
||||||
* `Serialization`: `1.5.0`
|
|
||||||
* `Ktor`: `2.2.3`
|
|
||||||
|
|
||||||
## 0.14.0
|
|
||||||
|
|
||||||
* `LimitStatus` is `Comparable<LimitStatus>` since this update
|
|
||||||
* `Limits` is `Comparable<Limits>` since this update
|
|
||||||
* Main API has been changed
|
|
||||||
|
|
||||||
## 0.13.0
|
## 0.13.0
|
||||||
|
|
||||||
* Versions:
|
* Versions:
|
||||||
|
18
build.gradle
18
build.gradle
@ -28,19 +28,11 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
jvm {
|
jvm()
|
||||||
compilations.main {
|
|
||||||
kotlinOptions {
|
|
||||||
jvmTarget = "1.8"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
js(IR) {
|
js(IR) {
|
||||||
browser()
|
browser()
|
||||||
nodejs()
|
nodejs()
|
||||||
}
|
}
|
||||||
linuxX64()
|
|
||||||
mingwX64()
|
|
||||||
|
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@ -52,9 +44,6 @@ kotlin {
|
|||||||
api libs.kt.serialization
|
api libs.kt.serialization
|
||||||
api libs.klock
|
api libs.klock
|
||||||
api libs.ktor.client
|
api libs.ktor.client
|
||||||
api libs.microutils.common
|
|
||||||
api libs.microutils.ktor.common
|
|
||||||
api libs.microutils.mimetypes
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commonTest {
|
commonTest {
|
||||||
@ -76,8 +65,3 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
}
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
|
|
||||||
library_version=0.17.2
|
library_version=0.13.0
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
kt = "1.8.22"
|
kt = "1.7.22"
|
||||||
kt-serialization = "1.5.1"
|
kt-serialization = "1.4.1"
|
||||||
kt-coroutines = "1.7.3"
|
kt-coroutines = "1.6.4"
|
||||||
|
|
||||||
klock = "4.0.3"
|
klock = "3.4.0"
|
||||||
ktor = "2.3.4"
|
ktor = "2.2.1"
|
||||||
|
|
||||||
microutils = "0.19.9"
|
|
||||||
|
|
||||||
gh-release = "2.4.1"
|
gh-release = "2.4.1"
|
||||||
|
|
||||||
@ -22,10 +20,6 @@ klock = { module = "com.soywiz.korlibs.klock:klock", version.ref = "klock" }
|
|||||||
ktor-client = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
|
ktor-client = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
|
||||||
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
|
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
|
||||||
|
|
||||||
microutils-common = { module = "dev.inmo:micro_utils.common", version.ref = "microutils" }
|
|
||||||
microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" }
|
|
||||||
microutils-mimetypes = { module = "dev.inmo:micro_utils.mime_types", version.ref = "microutils" }
|
|
||||||
|
|
||||||
buildscript-kt-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kt" }
|
buildscript-kt-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kt" }
|
||||||
buildscript-kt-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kt" }
|
buildscript-kt-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kt" }
|
||||||
buildscript-gh-release = { module = "com.github.breadmoirai:github-release", version.ref = "gh-release" }
|
buildscript-gh-release = { module = "com.github.breadmoirai:github-release", version.ref = "gh-release" }
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -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-7.6.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||||
|
2058
kotlin-js-store/yarn.lock
Normal file
2058
kotlin-js-store/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,5 @@
|
|||||||
package dev.inmo.saucenaoapi
|
package dev.inmo.saucenaoapi
|
||||||
|
|
||||||
import dev.inmo.micro_utils.common.MPPFile
|
|
||||||
import dev.inmo.micro_utils.ktor.common.input
|
|
||||||
import dev.inmo.saucenaoapi.exceptions.TooManyRequestsException
|
import dev.inmo.saucenaoapi.exceptions.TooManyRequestsException
|
||||||
import dev.inmo.saucenaoapi.exceptions.sauceNaoAPIException
|
import dev.inmo.saucenaoapi.exceptions.sauceNaoAPIException
|
||||||
import dev.inmo.saucenaoapi.models.*
|
import dev.inmo.saucenaoapi.models.*
|
||||||
@ -24,7 +22,6 @@ private const val URL_FIELD = "url"
|
|||||||
private const val FILE_FIELD = "file"
|
private const val FILE_FIELD = "file"
|
||||||
private const val FILENAME_FIELD = "filename"
|
private const val FILENAME_FIELD = "filename"
|
||||||
private const val DB_FIELD = "db"
|
private const val DB_FIELD = "db"
|
||||||
private const val DBS_FIELD = "dbs[]"
|
|
||||||
private const val DBMASK_FIELD = "dbmask"
|
private const val DBMASK_FIELD = "dbmask"
|
||||||
private const val DBMASKI_FIELD = "dbmaski"
|
private const val DBMASKI_FIELD = "dbmaski"
|
||||||
private const val RESULTS_COUNT_FIELD = "numres"
|
private const val RESULTS_COUNT_FIELD = "numres"
|
||||||
@ -95,45 +92,6 @@ data class SauceNaoAPI(
|
|||||||
minSimilarity = minSimilarity
|
minSimilarity = minSimilarity
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
|
||||||
* @param db search a specific index number or all without needing to generate a bitmask.
|
|
||||||
* @param dbs search one or more specific index number, set more than once to search multiple.
|
|
||||||
*/
|
|
||||||
suspend fun requestByDBs(
|
|
||||||
url: String,
|
|
||||||
db: Int? = null,
|
|
||||||
dbs: Array<Int>? = null,
|
|
||||||
resultsCount: Int? = null,
|
|
||||||
minSimilarity: Float? = null
|
|
||||||
): SauceNaoAnswer = makeRequest(
|
|
||||||
url.asSauceRequestSubject,
|
|
||||||
db = db,
|
|
||||||
dbs = dbs,
|
|
||||||
resultsCount = resultsCount,
|
|
||||||
minSimilarity = minSimilarity
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mask Mask for selecting specific indexes to ENABLE. dbmask=8191 will search all of the first 14 indexes. If intending to search all databases, the db=999 option is more appropriate.
|
|
||||||
* @param excludedMask Mask for selecting specific indexes to DISABLE. dbmaski=8191 would search only indexes higher than the first 14. This is ideal when attempting to disable only certain indexes, while allowing future indexes to be included by default.
|
|
||||||
*
|
|
||||||
* Bitmask Note: Index numbers start with 0. Even though pixiv is labeled as index 5, it would be controlled with the 6th bit position, which has a decimal value of 32 when set.
|
|
||||||
* db=<index num or 999 for all>
|
|
||||||
*/
|
|
||||||
suspend fun requestByMasks(
|
|
||||||
url: String,
|
|
||||||
mask: Int?,
|
|
||||||
excludedMask: Int? = null,
|
|
||||||
resultsCount: Int? = null,
|
|
||||||
minSimilarity: Float? = null
|
|
||||||
): SauceNaoAnswer = makeRequest(
|
|
||||||
url.asSauceRequestSubject,
|
|
||||||
dbmask = mask,
|
|
||||||
dbmaski = excludedMask,
|
|
||||||
resultsCount = resultsCount,
|
|
||||||
minSimilarity = minSimilarity
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun request(
|
suspend fun request(
|
||||||
mediaInput: Input,
|
mediaInput: Input,
|
||||||
mimeType: ContentType,
|
mimeType: ContentType,
|
||||||
@ -145,139 +103,51 @@ data class SauceNaoAPI(
|
|||||||
minSimilarity = minSimilarity
|
minSimilarity = minSimilarity
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
|
||||||
* @param db search a specific index number or all without needing to generate a bitmask.
|
|
||||||
* @param dbs search one or more specific index number, set more than once to search multiple.
|
|
||||||
*/
|
|
||||||
suspend fun requestByDBs(
|
|
||||||
mediaInput: Input,
|
|
||||||
mimeType: ContentType,
|
|
||||||
db: Int? = null,
|
|
||||||
dbs: Array<Int>? = null,
|
|
||||||
resultsCount: Int? = null,
|
|
||||||
minSimilarity: Float? = null
|
|
||||||
): SauceNaoAnswer = makeRequest(
|
|
||||||
mediaInput.asSauceRequestSubject(mimeType),
|
|
||||||
db = db,
|
|
||||||
dbs = dbs,
|
|
||||||
resultsCount = resultsCount,
|
|
||||||
minSimilarity = minSimilarity
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mask Mask for selecting specific indexes to ENABLE. dbmask=8191 will search all of the first 14 indexes. If intending to search all databases, the db=999 option is more appropriate.
|
|
||||||
* @param excludedMask Mask for selecting specific indexes to DISABLE. dbmaski=8191 would search only indexes higher than the first 14. This is ideal when attempting to disable only certain indexes, while allowing future indexes to be included by default.
|
|
||||||
*
|
|
||||||
* Bitmask Note: Index numbers start with 0. Even though pixiv is labeled as index 5, it would be controlled with the 6th bit position, which has a decimal value of 32 when set.
|
|
||||||
* db=<index num or 999 for all>
|
|
||||||
*/
|
|
||||||
suspend fun requestByMasks(
|
|
||||||
mediaInput: Input,
|
|
||||||
mimeType: ContentType,
|
|
||||||
mask: Int?,
|
|
||||||
excludedMask: Int? = null,
|
|
||||||
resultsCount: Int? = null,
|
|
||||||
minSimilarity: Float? = null
|
|
||||||
): SauceNaoAnswer = makeRequest(
|
|
||||||
mediaInput.asSauceRequestSubject(mimeType),
|
|
||||||
dbmask = mask,
|
|
||||||
dbmaski = excludedMask,
|
|
||||||
resultsCount = resultsCount,
|
|
||||||
minSimilarity = minSimilarity
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun request(
|
suspend fun request(
|
||||||
file: MPPFile,
|
file: MPPFile,
|
||||||
resultsCount: Int? = null,
|
resultsCount: Int? = null,
|
||||||
minSimilarity: Float? = null
|
minSimilarity: Float? = null
|
||||||
): SauceNaoAnswer = request(
|
): SauceNaoAnswer = request(
|
||||||
file.input(),
|
file.input,
|
||||||
file.contentType,
|
file.contentType,
|
||||||
resultsCount,
|
resultsCount = resultsCount,
|
||||||
minSimilarity
|
minSimilarity = minSimilarity
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
|
||||||
* @param db search a specific index number or all without needing to generate a bitmask.
|
|
||||||
* @param dbs search one or more specific index number, set more than once to search multiple.
|
|
||||||
*/
|
|
||||||
suspend fun requestByDBs(
|
|
||||||
file: MPPFile,
|
|
||||||
db: Int? = null,
|
|
||||||
dbs: Array<Int>? = null,
|
|
||||||
resultsCount: Int? = null,
|
|
||||||
minSimilarity: Float? = null
|
|
||||||
): SauceNaoAnswer = requestByDBs(
|
|
||||||
file.input(),
|
|
||||||
file.contentType,
|
|
||||||
db,
|
|
||||||
dbs,
|
|
||||||
resultsCount,
|
|
||||||
minSimilarity
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mask Mask for selecting specific indexes to ENABLE. dbmask=8191 will search all of the first 14 indexes. If intending to search all databases, the db=999 option is more appropriate.
|
|
||||||
* @param excludedMask Mask for selecting specific indexes to DISABLE. dbmaski=8191 would search only indexes higher than the first 14. This is ideal when attempting to disable only certain indexes, while allowing future indexes to be included by default.
|
|
||||||
*
|
|
||||||
* Bitmask Note: Index numbers start with 0. Even though pixiv is labeled as index 5, it would be controlled with the 6th bit position, which has a decimal value of 32 when set.
|
|
||||||
* db=<index num or 999 for all>
|
|
||||||
*/
|
|
||||||
suspend fun requestByMasks(
|
|
||||||
file: MPPFile,
|
|
||||||
mask: Int?,
|
|
||||||
excludedMask: Int? = null,
|
|
||||||
resultsCount: Int? = null,
|
|
||||||
minSimilarity: Float? = null
|
|
||||||
): SauceNaoAnswer = requestByMasks(
|
|
||||||
file.input(),
|
|
||||||
file.contentType,
|
|
||||||
mask,
|
|
||||||
excludedMask,
|
|
||||||
resultsCount,
|
|
||||||
minSimilarity
|
|
||||||
)
|
|
||||||
|
|
||||||
@Deprecated("Renamed", ReplaceWith("requestByDBs(url, db, null, resultsCount, minSimilarity)"))
|
|
||||||
suspend fun requestByDb(
|
suspend fun requestByDb(
|
||||||
url: String,
|
url: String,
|
||||||
db: Int,
|
db: Int,
|
||||||
resultsCount: Int? = null,
|
resultsCount: Int? = null,
|
||||||
minSimilarity: Float? = null
|
minSimilarity: Float? = null
|
||||||
): SauceNaoAnswer = requestByDBs(
|
): SauceNaoAnswer = makeRequest(
|
||||||
url,
|
url.asSauceRequestSubject,
|
||||||
db,
|
db = db,
|
||||||
null,
|
resultsCount = resultsCount,
|
||||||
resultsCount,
|
minSimilarity = minSimilarity
|
||||||
minSimilarity
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@Deprecated("Renamed", ReplaceWith("requestByMasks(url, dbmask, null, resultsCount, minSimilarity)"))
|
suspend fun requestByMask(
|
||||||
suspend fun request(
|
|
||||||
url: String,
|
url: String,
|
||||||
dbmask: Int,
|
dbmask: Int,
|
||||||
resultsCount: Int? = null,
|
resultsCount: Int? = null,
|
||||||
minSimilarity: Float? = null
|
minSimilarity: Float? = null
|
||||||
): SauceNaoAnswer = requestByMasks(
|
): SauceNaoAnswer = makeRequest(
|
||||||
url,
|
url.asSauceRequestSubject,
|
||||||
dbmask,
|
dbmask = dbmask,
|
||||||
null,
|
resultsCount = resultsCount,
|
||||||
resultsCount,
|
minSimilarity = minSimilarity
|
||||||
minSimilarity
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@Deprecated("Renamed", ReplaceWith("requestByMasks(url, null, dbmaski, resultsCount, minSimilarity)"))
|
|
||||||
suspend fun requestByMaskI(
|
suspend fun requestByMaskI(
|
||||||
url: String,
|
url: String,
|
||||||
dbmaski: Int,
|
dbmaski: Int,
|
||||||
resultsCount: Int? = null,
|
resultsCount: Int? = null,
|
||||||
minSimilarity: Float? = null
|
minSimilarity: Float? = null
|
||||||
): SauceNaoAnswer = requestByMasks(
|
): SauceNaoAnswer = makeRequest(
|
||||||
url,
|
url.asSauceRequestSubject,
|
||||||
null,
|
dbmaski = dbmaski,
|
||||||
dbmaski,
|
resultsCount = resultsCount,
|
||||||
resultsCount,
|
minSimilarity = minSimilarity
|
||||||
minSimilarity
|
|
||||||
)
|
)
|
||||||
|
|
||||||
private suspend fun makeRequest(
|
private suspend fun makeRequest(
|
||||||
@ -299,7 +169,6 @@ data class SauceNaoAPI(
|
|||||||
private suspend fun makeRequest(
|
private suspend fun makeRequest(
|
||||||
request: SauceRequestSubject,
|
request: SauceRequestSubject,
|
||||||
db: Int? = null,
|
db: Int? = null,
|
||||||
dbs: Array<Int>? = null,
|
|
||||||
dbmask: Int? = null,
|
dbmask: Int? = null,
|
||||||
dbmaski: Int? = null,
|
dbmaski: Int? = null,
|
||||||
resultsCount: Int? = null,
|
resultsCount: Int? = null,
|
||||||
@ -314,7 +183,6 @@ data class SauceNaoAPI(
|
|||||||
apiToken ?.also { parameter(API_TOKEN_FIELD, it) }
|
apiToken ?.also { parameter(API_TOKEN_FIELD, it) }
|
||||||
parameter(OUTPUT_TYPE_FIELD, JsonOutputType.typeCode)
|
parameter(OUTPUT_TYPE_FIELD, JsonOutputType.typeCode)
|
||||||
db ?.also { parameter(DB_FIELD, it) }
|
db ?.also { parameter(DB_FIELD, it) }
|
||||||
dbs ?.forEach { parameter(DBS_FIELD, it) }
|
|
||||||
dbmask ?.also { parameter(DBMASK_FIELD, it) }
|
dbmask ?.also { parameter(DBMASK_FIELD, it) }
|
||||||
dbmaski ?.also { parameter(DBMASKI_FIELD, it) }
|
dbmaski ?.also { parameter(DBMASKI_FIELD, it) }
|
||||||
resultsCount ?.also { parameter(RESULTS_COUNT_FIELD, it) }
|
resultsCount ?.also { parameter(RESULTS_COUNT_FIELD, it) }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.saucenaoapi.additional
|
package dev.inmo.saucenaoapi.additional
|
||||||
|
|
||||||
import korlibs.time.TimeSpan
|
import com.soywiz.klock.TimeSpan
|
||||||
|
|
||||||
typealias AccountType = Int
|
typealias AccountType = Int
|
||||||
const val defaultAccountType: AccountType = 1 // "basic"
|
const val defaultAccountType: AccountType = 1 // "basic"
|
||||||
|
@ -29,27 +29,15 @@ val Header.accountInfo
|
|||||||
data class LimitStatus(
|
data class LimitStatus(
|
||||||
val remain: Int = Int.MAX_VALUE,
|
val remain: Int = Int.MAX_VALUE,
|
||||||
val limit: Int = Int.MAX_VALUE
|
val limit: Int = Int.MAX_VALUE
|
||||||
) : Comparable<LimitStatus> {
|
)
|
||||||
override fun compareTo(other: LimitStatus): Int = when {
|
|
||||||
limit == other.limit && remain == other.remain -> 0
|
|
||||||
else -> remain.compareTo(other.remain)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data class Limits(
|
data class Limits(
|
||||||
val short: LimitStatus = LimitStatus(),
|
val short: LimitStatus = LimitStatus(),
|
||||||
val long: LimitStatus = LimitStatus()
|
val long: LimitStatus = LimitStatus()
|
||||||
) : Comparable<Limits> {
|
)
|
||||||
override fun compareTo(other: Limits): Int = when {
|
|
||||||
long == other.long && short == other.short -> 0
|
|
||||||
else -> short.remain.compareTo(other.short.remain)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data class AccountInfo(
|
data class AccountInfo(
|
||||||
val accountType: AccountType = defaultAccountType,
|
val accountType: AccountType = defaultAccountType,
|
||||||
val userId: UserId? = null,
|
val userId: UserId? = null,
|
||||||
val limits: Limits = Limits()
|
val limits: Limits = Limits()
|
||||||
) : Comparable<AccountInfo> {
|
)
|
||||||
override fun compareTo(other: AccountInfo): Int = limits.compareTo(other.limits)
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.saucenaoapi.exceptions
|
package dev.inmo.saucenaoapi.exceptions
|
||||||
|
|
||||||
import korlibs.time.TimeSpan
|
import com.soywiz.klock.TimeSpan
|
||||||
import dev.inmo.saucenaoapi.additional.LONG_TIME_RECALCULATING_MILLIS
|
import dev.inmo.saucenaoapi.additional.LONG_TIME_RECALCULATING_MILLIS
|
||||||
import dev.inmo.saucenaoapi.additional.SHORT_TIME_RECALCULATING_MILLIS
|
import dev.inmo.saucenaoapi.additional.SHORT_TIME_RECALCULATING_MILLIS
|
||||||
import io.ktor.client.plugins.ClientRequestException
|
import io.ktor.client.plugins.ClientRequestException
|
||||||
|
@ -8,6 +8,4 @@ data class LimitsState(
|
|||||||
val maxLongQuota: Int,
|
val maxLongQuota: Int,
|
||||||
val knownShortQuota: Int,
|
val knownShortQuota: Int,
|
||||||
val knownLongQuota: Int
|
val knownLongQuota: Int
|
||||||
) : Comparable<LimitsState> {
|
)
|
||||||
override fun compareTo(other: LimitsState): Int = knownShortQuota.compareTo(other.knownShortQuota)
|
|
||||||
}
|
|
||||||
|
@ -1,26 +1,9 @@
|
|||||||
package dev.inmo.saucenaoapi.utils
|
package dev.inmo.saucenaoapi.utils
|
||||||
|
|
||||||
import dev.inmo.micro_utils.common.MPPFile
|
|
||||||
import dev.inmo.micro_utils.common.filename
|
|
||||||
import dev.inmo.micro_utils.ktor.common.input
|
|
||||||
import dev.inmo.micro_utils.mime_types.KnownMimeTypes
|
|
||||||
import dev.inmo.micro_utils.mime_types.getMimeType
|
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
import io.ktor.utils.io.core.Input
|
import io.ktor.utils.io.core.Input
|
||||||
|
|
||||||
@Deprecated(
|
expect class MPPFile
|
||||||
"MPPFile from microutils is preferable since 0.16.0",
|
|
||||||
ReplaceWith("MPPFile", "dev.inmo.micro_utils.common.MPPFile")
|
|
||||||
)
|
|
||||||
typealias MPPFile = MPPFile
|
|
||||||
|
|
||||||
@Deprecated(
|
expect val MPPFile.input: Input
|
||||||
"input() from microutils is preferable since 0.16.0",
|
expect val MPPFile.contentType: ContentType
|
||||||
ReplaceWith("this.input()", "dev.inmo.micro_utils.ktor.common.input")
|
|
||||||
)
|
|
||||||
val MPPFile.input: Input
|
|
||||||
get() = input()
|
|
||||||
val MPPFile.contentType: ContentType
|
|
||||||
get() = ContentType.parse(
|
|
||||||
getMimeType(stringWithExtension = filename.extension) ?.raw ?: KnownMimeTypes.Any.raw
|
|
||||||
)
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.saucenaoapi.utils
|
package dev.inmo.saucenaoapi.utils
|
||||||
|
|
||||||
import korlibs.time.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
import dev.inmo.saucenaoapi.additional.LONG_TIME_RECALCULATING_MILLIS
|
import dev.inmo.saucenaoapi.additional.LONG_TIME_RECALCULATING_MILLIS
|
||||||
import dev.inmo.saucenaoapi.additional.SHORT_TIME_RECALCULATING_MILLIS
|
import dev.inmo.saucenaoapi.additional.SHORT_TIME_RECALCULATING_MILLIS
|
||||||
import dev.inmo.saucenaoapi.exceptions.TooManyRequestsException
|
import dev.inmo.saucenaoapi.exceptions.TooManyRequestsException
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.saucenaoapi.utils
|
package dev.inmo.saucenaoapi.utils
|
||||||
|
|
||||||
import korlibs.time.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
import dev.inmo.saucenaoapi.additional.LONG_TIME_RECALCULATING_MILLIS
|
import dev.inmo.saucenaoapi.additional.LONG_TIME_RECALCULATING_MILLIS
|
||||||
import dev.inmo.saucenaoapi.additional.SHORT_TIME_RECALCULATING_MILLIS
|
import dev.inmo.saucenaoapi.additional.SHORT_TIME_RECALCULATING_MILLIS
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package dev.inmo.saucenaoapi.utils
|
||||||
|
|
||||||
|
import io.ktor.http.ContentType
|
||||||
|
import io.ktor.utils.io.core.ByteReadPacket
|
||||||
|
import io.ktor.utils.io.core.Input
|
||||||
|
import org.khronos.webgl.Int8Array
|
||||||
|
import org.w3c.files.File
|
||||||
|
import org.w3c.files.FileReaderSync
|
||||||
|
|
||||||
|
actual typealias MPPFile = File
|
||||||
|
|
||||||
|
actual val MPPFile.input: Input
|
||||||
|
get() {
|
||||||
|
val reader = FileReaderSync()
|
||||||
|
return ByteReadPacket(Int8Array(reader.readAsArrayBuffer(this)) as ByteArray)
|
||||||
|
}
|
||||||
|
actual val MPPFile.contentType: ContentType
|
||||||
|
get() = ContentType.parse(type)
|
@ -0,0 +1,14 @@
|
|||||||
|
package dev.inmo.saucenaoapi.utils
|
||||||
|
|
||||||
|
import io.ktor.http.ContentType
|
||||||
|
import io.ktor.utils.io.core.Input
|
||||||
|
import io.ktor.utils.io.streams.asInput
|
||||||
|
import java.io.File
|
||||||
|
import java.nio.file.Files
|
||||||
|
|
||||||
|
actual typealias MPPFile = File
|
||||||
|
|
||||||
|
actual val MPPFile.input: Input
|
||||||
|
get() = inputStream().asInput()
|
||||||
|
actual val MPPFile.contentType: ContentType
|
||||||
|
get() = ContentType.parse(Files.probeContentType(toPath()))
|
Loading…
Reference in New Issue
Block a user