不满足并发率时报错

pull/1296/head
gedoor 3 years ago
parent b9341bc7a0
commit 26580744d1
  1. 9
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -15,7 +15,6 @@ import io.legado.app.help.CacheManager
import io.legado.app.help.JsExtensions import io.legado.app.help.JsExtensions
import io.legado.app.help.http.* import io.legado.app.help.http.*
import io.legado.app.utils.* import io.legado.app.utils.*
import kotlinx.coroutines.delay
import java.net.URLEncoder import java.net.URLEncoder
import java.util.* import java.util.*
import java.util.regex.Pattern import java.util.regex.Pattern
@ -268,7 +267,7 @@ class AnalyzeUrl(
/** /**
* 根据书源并发率等待 * 根据书源并发率等待
*/ */
private suspend fun concurrentWait() { private fun judgmentConcurrent() {
source ?: return source ?: return
val concurrentRate = source.concurrentRate val concurrentRate = source.concurrentRate
if (concurrentRate.isNullOrEmpty()) { if (concurrentRate.isNullOrEmpty()) {
@ -311,7 +310,7 @@ class AnalyzeUrl(
} }
} }
if (waitTime > 0) { if (waitTime > 0) {
delay(waitTime) error("根据并发率还需等待${waitTime}毫秒才可以访问")
} }
} }
@ -322,7 +321,7 @@ class AnalyzeUrl(
if (type != null) { if (type != null) {
return StrResponse(url, StringUtils.byteToHexString(getByteArray())) return StrResponse(url, StringUtils.byteToHexString(getByteArray()))
} }
concurrentWait() judgmentConcurrent()
setCookie(source?.getStoreUrl()) setCookie(source?.getStoreUrl())
if (useWebView) { if (useWebView) {
val params = AjaxWebView.AjaxParams(url) val params = AjaxWebView.AjaxParams(url)
@ -351,7 +350,7 @@ class AnalyzeUrl(
} }
suspend fun getByteArray(): ByteArray { suspend fun getByteArray(): ByteArray {
concurrentWait() judgmentConcurrent()
setCookie(source?.getStoreUrl()) setCookie(source?.getStoreUrl())
@Suppress("BlockingMethodInNonBlockingContext") @Suppress("BlockingMethodInNonBlockingContext")
return getProxyClient(proxy).newCall(retry) { return getProxyClient(proxy).newCall(retry) {

Loading…
Cancel
Save