This commit is contained in:
jack 2023-12-01 03:33:25 +07:00
parent cc2cc118d2
commit e644456bc6
2 changed files with 17 additions and 9 deletions

View File

@ -1,5 +1,5 @@
// use an integer for version numbers // use an integer for version numbers
version = 27 version = 28
cloudstream { cloudstream {

View File

@ -8,6 +8,7 @@ import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities import com.lagradost.cloudstream3.utils.Qualities
import com.lagradost.cloudstream3.utils.loadExtractor import com.lagradost.cloudstream3.utils.loadExtractor
import com.lagradost.nicehttp.requestCreator import com.lagradost.nicehttp.requestCreator
import okhttp3.HttpUrl
import org.jsoup.Jsoup import org.jsoup.Jsoup
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
@ -18,7 +19,7 @@ class KuramanimeProvider : MainAPI() {
override val hasMainPage = true override val hasMainPage = true
override var lang = "id" override var lang = "id"
override val hasDownloadSupport = true override val hasDownloadSupport = true
private var auth: Pair<String?, String?>? = null private var params: AuthParams? = null
private var headers: Map<String,String> = mapOf() private var headers: Map<String,String> = mapOf()
private var cookies: Map<String,String> = mapOf() private var cookies: Map<String,String> = mapOf()
override val supportedTypes = setOf( override val supportedTypes = setOf(
@ -203,14 +204,15 @@ class KuramanimeProvider : MainAPI() {
val auth = getAuth(data) val auth = getAuth(data)
headers = mapOf( headers = mapOf(
"Accept" to "application/json, text/javascript, */*; q=0.01", "Accept" to "application/json, text/javascript, */*; q=0.01",
"Authorization" to "${auth.second}", "Authorization" to "${auth.authHeader}",
"X-Requested-With" to "XMLHttpRequest", "X-Requested-With" to "XMLHttpRequest",
"X-CSRF-TOKEN" to token "X-CSRF-TOKEN" to token
) )
cookies = req.cookies cookies = req.cookies
res.select("select#changeServer option").apmap { source -> res.select("select#changeServer option").apmap { source ->
val server = source.attr("value") val server = source.attr("value")
val link = "$data?dfgRr1OagZvvxbzHNpyCy0FqJQ18mCnb=${getMisc(auth.first)}&twEvZlbZbYRWBdKKwxkOnwYF0VWoGGVg=$server" val query = auth.serverUrl?.queryParameterNames
val link = "$data?${query?.first()}=${getMisc(auth.authUrl)}&${query?.last()}=$server"
if (server.contains(Regex("(?i)kuramadrive|archive"))) { if (server.contains(Regex("(?i)kuramadrive|archive"))) {
invokeLocalSource(link, server, data, callback) invokeLocalSource(link, server, data, callback)
} else { } else {
@ -228,21 +230,21 @@ class KuramanimeProvider : MainAPI() {
return true return true
} }
private suspend fun fetchAuth(url: String) : Pair<String?,String?> { private suspend fun fetchAuth(url: String) : AuthParams {
val regex = Regex("""$mainUrl/(?!anime|assets|images|misc|cf-fonts)\w+""") val regex = Regex("""$mainUrl/(?!anime|assets|images|misc|cf-fonts)\w+""")
val found = WebViewResolver( val found = WebViewResolver(
Regex("""dfgRr1OagZvvxbzHNpyCy0FqJQ18mCnb"""), Regex("""$url(?!\?page=)\?"""),
additionalUrls = listOf(regex) additionalUrls = listOf(regex)
).resolveUsingWebView( ).resolveUsingWebView(
requestCreator( requestCreator(
"GET", url "GET", url
) )
) )
val foundUrl = found.second.last() val addition = found.second.last()
return foundUrl.url.toString() to foundUrl.headers["Authorization"] return AuthParams(found.first?.url, addition.url.toString(), addition.headers["Authorization"])
} }
private suspend fun getAuth(url: String) = auth ?: fetchAuth(url).also { auth = it } private suspend fun getAuth(url: String) = params ?: fetchAuth(url).also { params = it }
private suspend fun getMisc(url: String?): String { private suspend fun getMisc(url: String?): String {
val misc = app.get( val misc = app.get(
@ -261,4 +263,10 @@ class KuramanimeProvider : MainAPI() {
.joinToString("") .joinToString("")
} }
data class AuthParams (
val serverUrl: HttpUrl?,
val authUrl: String?,
val authHeader: String?,
)
} }