mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
1e11a78698
1 changed files with 12 additions and 0 deletions
|
@ -9,6 +9,7 @@ import com.lagradost.nicehttp.Requests.Companion.await
|
||||||
import com.lagradost.nicehttp.cookies
|
import com.lagradost.nicehttp.cookies
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import okhttp3.*
|
import okhttp3.*
|
||||||
|
import java.net.URI
|
||||||
|
|
||||||
|
|
||||||
@AnyThread
|
@AnyThread
|
||||||
|
@ -30,6 +31,17 @@ class CloudflareKiller : Interceptor {
|
||||||
|
|
||||||
val savedCookies: MutableMap<String, Map<String, String>> = mutableMapOf()
|
val savedCookies: MutableMap<String, Map<String, String>> = mutableMapOf()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the headers with cookies, webview user agent included!
|
||||||
|
* */
|
||||||
|
fun getCookieHeaders(url: String): Headers {
|
||||||
|
val userAgentHeaders = WebViewResolver.webViewUserAgent?.let {
|
||||||
|
mapOf("user-agent" to it)
|
||||||
|
} ?: emptyMap()
|
||||||
|
|
||||||
|
return getHeaders(userAgentHeaders, savedCookies[URI(url).host] ?: emptyMap())
|
||||||
|
}
|
||||||
|
|
||||||
override fun intercept(chain: Interceptor.Chain): Response = runBlocking {
|
override fun intercept(chain: Interceptor.Chain): Response = runBlocking {
|
||||||
val request = chain.request()
|
val request = chain.request()
|
||||||
val cookies = savedCookies[request.url.host]
|
val cookies = savedCookies[request.url.host]
|
||||||
|
|
Loading…
Reference in a new issue