mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
Minioppai: added cloudflareKiller
This commit is contained in:
parent
60ac662c20
commit
eb19ad6cda
2 changed files with 23 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
// use an integer for version numbers
|
||||
version = 5
|
||||
version = 6
|
||||
|
||||
|
||||
cloudstream {
|
||||
|
|
|
@ -2,7 +2,10 @@ package com.hexated
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.lagradost.cloudstream3.*
|
||||
import com.lagradost.cloudstream3.network.CloudflareKiller
|
||||
import com.lagradost.cloudstream3.utils.*
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.Response
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Element
|
||||
import java.net.URLDecoder
|
||||
|
@ -14,11 +17,24 @@ class Minioppai : MainAPI() {
|
|||
override var lang = "id"
|
||||
override val hasDownloadSupport = true
|
||||
override val hasQuickSearch = true
|
||||
|
||||
private val cloudflareKiller by lazy { CloudflareKiller() }
|
||||
private val interceptor by lazy { CloudflareInterceptor(cloudflareKiller) }
|
||||
override val supportedTypes = setOf(
|
||||
TvType.NSFW,
|
||||
)
|
||||
|
||||
class CloudflareInterceptor(private val cloudflareKiller: CloudflareKiller): Interceptor {
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
val request = chain.request()
|
||||
val response = chain.proceed(request)
|
||||
val doc = Jsoup.parse(response.peekBody(1024 * 1024).string())
|
||||
if (doc.select("title").text() == "Just a moment...") {
|
||||
return cloudflareKiller.intercept(chain)
|
||||
}
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getStatus(t: String?): ShowStatus {
|
||||
return when (t) {
|
||||
|
@ -38,7 +54,7 @@ class Minioppai : MainAPI() {
|
|||
page: Int,
|
||||
request: MainPageRequest
|
||||
): HomePageResponse {
|
||||
val document = app.get("${request.data}/page/$page").document
|
||||
val document = app.get("${request.data}/page/$page", interceptor = interceptor).document
|
||||
val home = document.select("div.latest a").mapNotNull {
|
||||
it.toSearchResult()
|
||||
}
|
||||
|
@ -79,7 +95,8 @@ class Minioppai : MainAPI() {
|
|||
"$mainUrl/wp-admin/admin-ajax.php", data = mapOf(
|
||||
"action" to "ts_ac_do_search",
|
||||
"ts_ac_query" to query,
|
||||
), headers = mapOf("X-Requested-With" to "XMLHttpRequest")
|
||||
), headers = mapOf("X-Requested-With" to "XMLHttpRequest"),
|
||||
interceptor = interceptor
|
||||
).parsedSafe<SearchResponses>()?.post?.firstOrNull()?.all?.mapNotNull { item ->
|
||||
newAnimeSearchResponse(
|
||||
item.postTitle ?: "",
|
||||
|
@ -92,7 +109,7 @@ class Minioppai : MainAPI() {
|
|||
}
|
||||
|
||||
override suspend fun load(url: String): LoadResponse? {
|
||||
val document = app.get(url).document
|
||||
val document = app.get(url, interceptor = interceptor).document
|
||||
|
||||
val title = document.selectFirst("h1.entry-title")?.text()?.trim() ?: return null
|
||||
val poster = fixUrlNull(document.selectFirst("div.limage img")?.attr("src"))
|
||||
|
@ -127,7 +144,7 @@ class Minioppai : MainAPI() {
|
|||
subtitleCallback: (SubtitleFile) -> Unit,
|
||||
callback: (ExtractorLink) -> Unit
|
||||
): Boolean {
|
||||
val document = app.get(data).document
|
||||
val document = app.get(data, interceptor = interceptor).document
|
||||
document.select("div.server ul.mirror li a").mapNotNull {
|
||||
Jsoup.parse(base64Decode(it.attr("data-em"))).select("iframe").attr("src")
|
||||
}.apmap { link ->
|
||||
|
|
Loading…
Reference in a new issue