mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
WebViewResolver: added timeout (#941)
This commit is contained in:
parent
e007714701
commit
93d81ea038
1 changed files with 15 additions and 3 deletions
|
@ -31,6 +31,7 @@ import java.net.URI
|
|||
* @param useOkhttp will try to use the okhttp client as much as possible, but this might cause some requests to fail. Disable for cloudflare.
|
||||
* @param script pass custom js to execute
|
||||
* @param scriptCallback will be called with the result from custom js
|
||||
* @param timeout close webview after timeout
|
||||
* */
|
||||
class WebViewResolver(
|
||||
val interceptUrl: Regex,
|
||||
|
@ -38,18 +39,29 @@ class WebViewResolver(
|
|||
val userAgent: String? = USER_AGENT,
|
||||
val useOkhttp: Boolean = true,
|
||||
val script: String? = null,
|
||||
val scriptCallback: ((String) -> Unit)? = null
|
||||
val scriptCallback: ((String) -> Unit)? = null,
|
||||
val timeout: Long = DEFAULT_TIMEOUT
|
||||
) :
|
||||
Interceptor {
|
||||
|
||||
constructor(
|
||||
interceptUrl: Regex,
|
||||
additionalUrls: List<Regex> = emptyList(),
|
||||
userAgent: String? = USER_AGENT,
|
||||
useOkhttp: Boolean = true,
|
||||
script: String? = null,
|
||||
scriptCallback: ((String) -> Unit)? = null,
|
||||
) : this(interceptUrl, additionalUrls, userAgent, useOkhttp, script, scriptCallback, DEFAULT_TIMEOUT)
|
||||
|
||||
constructor(
|
||||
interceptUrl: Regex,
|
||||
additionalUrls: List<Regex> = emptyList(),
|
||||
userAgent: String? = USER_AGENT,
|
||||
useOkhttp: Boolean = true
|
||||
) : this(interceptUrl, additionalUrls, userAgent, useOkhttp, null, null)
|
||||
) : this(interceptUrl, additionalUrls, userAgent, useOkhttp, null, null, DEFAULT_TIMEOUT)
|
||||
|
||||
companion object {
|
||||
private const val DEFAULT_TIMEOUT = 60_000L
|
||||
var webViewUserAgent: String? = null
|
||||
|
||||
@JvmName("getWebViewUserAgent1")
|
||||
|
@ -262,7 +274,7 @@ class WebViewResolver(
|
|||
|
||||
var loop = 0
|
||||
// Timeouts after this amount, 60s
|
||||
val totalTime = 60000L
|
||||
val totalTime = timeout
|
||||
|
||||
val delayTime = 100L
|
||||
|
||||
|
|
Loading…
Reference in a new issue