Merge remote-tracking branch 'origin/master'

This commit is contained in:
Blatzar 2022-08-24 03:10:33 +02:00
commit 1e11a78698

View file

@ -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]