mirror of
https://github.com/recloudstream/cloudstream-extensions.git
synced 2024-08-15 03:03:54 +00:00
update superembed
This commit is contained in:
parent
d4fcfbb77e
commit
ad526142b9
2 changed files with 60 additions and 34 deletions
|
@ -0,0 +1,36 @@
|
||||||
|
package com.lagradost
|
||||||
|
|
||||||
|
import com.lagradost.cloudstream3.*
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import org.json.JSONArray
|
||||||
|
import org.json.JSONObject
|
||||||
|
import android.util.Log
|
||||||
|
|
||||||
|
public object CaptchaSolver {
|
||||||
|
suspend fun predictFace(url: String): String? {
|
||||||
|
val img = "data:image/jpeg;base64," + base64Encode(app.get(url).body.bytes())
|
||||||
|
val reqData = HFRequest(listOf(img)).toJson()
|
||||||
|
val res = app.post("https://yuqi-gender-classifier.hf.space/api/queue/push/", json = reqData).text
|
||||||
|
val request = tryParseJson<JSONObject>(res)
|
||||||
|
for (i in 1..5) {
|
||||||
|
delay(500L)
|
||||||
|
val document = app.post("https://yuqi-gender-classifier.hf.space/api/queue/status/", json=request?.toJson()).text
|
||||||
|
val status = tryParseJson<JSONObject>(document)
|
||||||
|
if (status?.get("status") != "COMPLETE") continue
|
||||||
|
return (((status.get("data") as? JSONObject?)
|
||||||
|
?.get("data") as? JSONArray?)
|
||||||
|
?.get(0) as? JSONObject?)
|
||||||
|
?.get("label") as String?
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
private data class HFRequest(
|
||||||
|
val data: List<String>,
|
||||||
|
val action: String = "predict",
|
||||||
|
val fn_index: Int = 0,
|
||||||
|
val session_hash: String = "aaaaaaaaaaa"
|
||||||
|
)
|
||||||
|
}
|
|
@ -6,9 +6,8 @@ import com.lagradost.cloudstream3.metaproviders.TmdbProvider
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.loadExtractor
|
import com.lagradost.cloudstream3.utils.loadExtractor
|
||||||
import kotlinx.coroutines.delay
|
import okhttp3.FormBody
|
||||||
import org.json.JSONArray
|
import android.util.Log
|
||||||
import org.json.JSONObject
|
|
||||||
|
|
||||||
class SuperembedProvider : TmdbProvider() {
|
class SuperembedProvider : TmdbProvider() {
|
||||||
override var mainUrl = "https://seapi.link"
|
override var mainUrl = "https://seapi.link"
|
||||||
|
@ -54,40 +53,31 @@ class SuperembedProvider : TmdbProvider() {
|
||||||
val url: String
|
val url: String
|
||||||
) {
|
) {
|
||||||
suspend fun getIframeContents(): String? {
|
suspend fun getIframeContents(): String? {
|
||||||
val document = app.get(url)
|
var document = app.get(url)
|
||||||
|
for (i in 1..5) {
|
||||||
|
if ("captcha-message" in document.text) {
|
||||||
|
val soup = document.document
|
||||||
|
val prompt = soup.selectFirst(".captcha-message")?.text() ?: continue
|
||||||
|
val captchaId = soup.selectFirst("input[name=\"captcha_id\"]")?.attr("value") ?: continue
|
||||||
|
val promptGender = if ("female" in prompt) "female" else "male"
|
||||||
|
val checkboxes = soup.select(".captcha-checkbox").mapNotNull { it ->
|
||||||
|
val img = it.selectFirst("img")?.attr("src") ?: return@mapNotNull null
|
||||||
|
val gender = CaptchaSolver.predictFace("https://streamembed.net${img}") ?: return@mapNotNull null
|
||||||
|
if (gender != promptGender) return@mapNotNull null
|
||||||
|
return@mapNotNull it.selectFirst("input")?.attr("value")
|
||||||
|
}
|
||||||
|
val formData = FormBody.Builder().apply {
|
||||||
|
add("captcha_id", captchaId)
|
||||||
|
checkboxes.forEach { check ->
|
||||||
|
add("captcha_answer[]", check)
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
document = app.post(url, requestBody=formData)
|
||||||
|
} else { break }
|
||||||
|
}
|
||||||
val regex = "<iframe[^+]+\\+(?:window\\.)?atob\\(['\"]([-A-Za-z0-9+/=]+)".toRegex()
|
val regex = "<iframe[^+]+\\+(?:window\\.)?atob\\(['\"]([-A-Za-z0-9+/=]+)".toRegex()
|
||||||
val encoded = regex.find(document.text)?.groupValues?.get(1) ?: return null
|
val encoded = regex.find(document.text)?.groupValues?.get(1) ?: return null
|
||||||
return base64Decode(encoded)
|
return base64Decode(encoded)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
private object CaptchaSolver {
|
|
||||||
private enum class Gender { Female, Male }
|
|
||||||
private suspend fun predictFace(url: String): Gender? {
|
|
||||||
val img = "data:image/jpeg;base64," + base64Encode(app.get(url).body.bytes())
|
|
||||||
val res = app.post("https://hf.space/embed/njgroene/age-gender-profilepic/api/queue/push/ HTTP/1.1", json = HFRequest(
|
|
||||||
listOf(img))).text
|
|
||||||
val request = tryParseJson<JSONObject>(res)
|
|
||||||
for (i in 1..5) {
|
|
||||||
delay(500L)
|
|
||||||
val document = app.post("https://hf.space/embed/njgroene/age-gender-profilepic/api/queue/status/", json=request).text
|
|
||||||
val status = tryParseJson<JSONObject>(document)
|
|
||||||
if (status?.get("status") != "COMPLETE") continue
|
|
||||||
val pred = (((status.get("data") as? JSONObject?)
|
|
||||||
?.get("data") as? JSONArray?)
|
|
||||||
?.get(0) as? String?) ?: return null
|
|
||||||
return if ("Male" in pred) Gender.Male
|
|
||||||
else if ("Female" in pred) Gender.Female
|
|
||||||
else null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private data class HFRequest(
|
|
||||||
val data: List<String>,
|
|
||||||
val action: String = "predict",
|
|
||||||
val fn_index: Int = 0,
|
|
||||||
val session_hash: String = "aaaaaaaaaaa"
|
|
||||||
)
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue