[Kiutaku] Debug attempt 1
parent
cc98931147
commit
95fcbd44fd
@ -1,15 +1,42 @@
|
|||||||
package org.koitharu.kotatsu.parsers.site.gallery.all
|
package org.koitharu.kotatsu.parsers.site.gallery.all
|
||||||
|
|
||||||
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
import okhttp3.Interceptor
|
||||||
import org.koitharu.kotatsu.parsers.MangaSourceParser
|
import okhttp3.Request
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaParserSource
|
import okhttp3.Response
|
||||||
import org.koitharu.kotatsu.parsers.config.ConfigKey
|
import kotlinx.coroutines.*
|
||||||
import org.koitharu.kotatsu.parsers.model.ContentType
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaListFilterOptions
|
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.site.gallery.GalleryParser
|
||||||
import org.koitharu.kotatsu.parsers.Broken
|
|
||||||
|
|
||||||
@Broken("Blocked by Cloudflare")
|
|
||||||
@MangaSourceParser("KIUTAKU", "Kiutaku", type = ContentType.OTHER)
|
@MangaSourceParser("KIUTAKU", "Kiutaku", type = ContentType.OTHER)
|
||||||
internal class Kiutaku(context: MangaLoaderContext) :
|
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…
Reference in New Issue