RCO: increase timeout & Tachimanga workaround (#8536)

* RCO: Add workaround for Tachimanga.

* increase the timeout to 30 seconds
This commit is contained in:
lamaxama 2025-04-19 14:04:06 +08:00 committed by Draff
parent e6866d43c2
commit b6ab8fb843
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 12 additions and 8 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'ReadComicOnline'
extClass = '.Readcomiconline'
extVersionCode = 32
extVersionCode = 33
}
apply from: "$rootDir/common.gradle"

View File

@ -252,12 +252,12 @@ class Readcomiconline : ConfigurableSource, ParsedHttpSource() {
innerWv.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
innerWv.webViewClient = object : WebViewClient() {
private val emptyResponse = WebResourceResponse("text/plain", "utf-8", 200, "OK", mapOf(), "".byteInputStream())
override fun shouldInterceptRequest(
view: WebView?,
request: WebResourceRequest?,
): WebResourceResponse? {
val emptyResponse = WebResourceResponse("text/plain", "utf-8", 200, "OK", mapOf(), "".byteInputStream())
val url = request?.url?.toString()
url ?: return emptyResponse
@ -314,7 +314,7 @@ class Readcomiconline : ConfigurableSource, ParsedHttpSource() {
)
}
latch.await(10, TimeUnit.SECONDS)
latch.await(30, TimeUnit.SECONDS)
handler.post { webView?.destroy() }
if (latch.count == 1L) {
@ -330,11 +330,15 @@ class Readcomiconline : ConfigurableSource, ParsedHttpSource() {
.headers(headers)
.build()
val response = client.newCall(request).await()
val contentType = response.headers["content-type"] ?: ""
val size = response.headers["content-length"]?.toLongOrNull() ?: 0L
try {
val response = client.newCall(request).await()
val contentType = response.headers["content-type"] ?: ""
val size = response.headers["content-length"]?.toLongOrNull() ?: 0L
response.isSuccessful && contentType.startsWith("image") && size > 100
response.isSuccessful && contentType.startsWith("image") && size > 100
} catch (e: Exception) {
false
}
}
}.awaitAll()