diff --git a/src/en/spyfakku/build.gradle b/src/en/spyfakku/build.gradle index e5d7245a6..0d857e931 100644 --- a/src/en/spyfakku/build.gradle +++ b/src/en/spyfakku/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'SpyFakku' extClass = '.SpyFakku' - extVersionCode = 8 + extVersionCode = 9 isNsfw = true } diff --git a/src/en/spyfakku/src/eu/kanade/tachiyomi/extension/en/spyfakku/Filters.kt b/src/en/spyfakku/src/eu/kanade/tachiyomi/extension/en/spyfakku/Filters.kt index 4f289a6ab..6f6de5ee9 100644 --- a/src/en/spyfakku/src/eu/kanade/tachiyomi/extension/en/spyfakku/Filters.kt +++ b/src/en/spyfakku/src/eu/kanade/tachiyomi/extension/en/spyfakku/Filters.kt @@ -32,4 +32,5 @@ private val getSortsList: List> = listOf( Pair("Date Added", "created_at"), Pair("Date Released", "released_at"), Pair("Pages", "pages"), + Pair("Random", "random"), ) diff --git a/src/en/spyfakku/src/eu/kanade/tachiyomi/extension/en/spyfakku/SpyFakku.kt b/src/en/spyfakku/src/eu/kanade/tachiyomi/extension/en/spyfakku/SpyFakku.kt index bb95f5479..1f3cb2d05 100644 --- a/src/en/spyfakku/src/eu/kanade/tachiyomi/extension/en/spyfakku/SpyFakku.kt +++ b/src/en/spyfakku/src/eu/kanade/tachiyomi/extension/en/spyfakku/SpyFakku.kt @@ -27,6 +27,7 @@ import java.text.SimpleDateFormat import java.util.Locale import java.util.TimeZone import java.util.concurrent.TimeUnit +import kotlin.random.Random class SpyFakku : HttpSource() { @@ -48,6 +49,8 @@ class SpyFakku : HttpSource() { .rateLimit(2, 1, TimeUnit.SECONDS) .build() + private val charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + override fun headersBuilder() = super.headersBuilder() .set("Referer", "$baseUrl/") .set("Origin", baseUrl) @@ -76,6 +79,7 @@ class SpyFakku : HttpSource() { when (filter) { is SortFilter -> { addQueryParameter("sort", filter.getValue()) + if (filter.getValue() == "random") addQueryParameter("seed", generateSeed()) addQueryParameter("order", if (filter.state!!.ascending) "asc" else "desc") } @@ -298,6 +302,17 @@ class SpyFakku : HttpSource() { return json.decodeFromString(body.string()) } + private fun generateSeed(): String { + val length = Random.nextInt(4, 9) + val string = StringBuilder(length) + + for (i in 0 until length) { + string.append(charset.random()) + } + + return string.toString() + } + override fun imageUrlParse(response: Response): String = throw UnsupportedOperationException() override fun latestUpdatesRequest(page: Int): Request = throw UnsupportedOperationException() override fun latestUpdatesParse(response: Response) = throw UnsupportedOperationException()