[Kiutaku] Debug attempt 1

Draken 12 months ago
parent cc98931147
commit 95fcbd44fd

@ -1 +1 @@
total: 1220
total: 1220

@ -1,15 +1,42 @@
package org.koitharu.kotatsu.parsers.site.gallery.all
import org.koitharu.kotatsu.parsers.MangaLoaderContext
import org.koitharu.kotatsu.parsers.MangaSourceParser
import org.koitharu.kotatsu.parsers.model.MangaParserSource
import org.koitharu.kotatsu.parsers.config.ConfigKey
import org.koitharu.kotatsu.parsers.model.ContentType
import org.koitharu.kotatsu.parsers.model.MangaListFilterOptions
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response
import kotlinx.coroutines.*
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import org.koitharu.kotatsu.parsers.*
import org.koitharu.kotatsu.parsers.model.*
import org.koitharu.kotatsu.parsers.site.gallery.GalleryParser
import org.koitharu.kotatsu.parsers.Broken
@Broken("Blocked by Cloudflare")
@MangaSourceParser("KIUTAKU", "Kiutaku", type = ContentType.OTHER)
internal class Kiutaku(context: MangaLoaderContext) :
GalleryParser(context, MangaParserSource.KIUTAKU, "kiutaku.com")
GalleryParser(context, MangaParserSource.KIUTAKU, "kiutaku.com") {
companion object {
private val mutex = Mutex()
private var lastImageRequestTime = 0L
private val IMAGE_EXTENSIONS = listOf(".jpg", ".jpeg", ".png", ".webp")
}
override fun intercept(chain: Interceptor.Chain): Response {
val request = chain.request()
val url = request.url.toString()
if (IMAGE_EXTENSIONS.any { url.endsWith(it, ignoreCase = true) }) {
runBlocking {
mutex.withLock {
val now = System.currentTimeMillis()
val wait = 500L - (now - lastImageRequestTime)
if (wait > 0) {
delay(wait)
}
lastImageRequestTime = System.currentTimeMillis()
}
}
}
return chain.proceed(request)
}
}

Loading…
Cancel
Save