[Sora] minor refactoring code

This commit is contained in:
hexated 2023-01-03 23:42:50 +07:00
parent 1419a2a298
commit f6aa675ff4
2 changed files with 18 additions and 38 deletions

View file

@ -1863,4 +1863,12 @@ data class MediaAni(
data class DataAni(
@JsonProperty("data") val data: MediaAni? = null,
)
data class Safelink(
@JsonProperty("safelink") val safelink: String? = null,
)
data class FDAds(
@JsonProperty("linkr") val linkr: String? = null,
)

View file

@ -263,46 +263,18 @@ fun getDirectGdrive(url: String): String {
}
suspend fun bypassFdAds(url: String?): String? {
val freeRedirect = app.get(url ?: return null, verify = false).document.selectFirst("a#link")?.attr("href")
val res = app.get(freeRedirect ?: return null,verify = false).document
val formLink = res.select("form#landing").attr("action")
val value = res.select("form#landing input").attr("value")
val headers = mapOf(
"Accept" to "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
"Content-Type" to "application/x-www-form-urlencoded"
)
val res2 = app.post(formLink, data = mapOf("go" to value), verify = false, headers = headers).document
val formLink2 = res2.select("form#landing").attr("action")
val humanVer = res2.select("form#landing input[name=humanverification]").attr("value")
val newwp = res2.select("form#landing input[name=newwpsafelink]").attr("value")
val res3 = app.post(
formLink2,
requestBody = FormBody.Builder()
.add("humanverification", humanVer)
.add("newwpsafelink", newwp)
.build(),
headers = headers,
val directUrl = app.get(url ?: return null, verify = false).document.select("a#link").attr("href")
.substringAfter("/go/")
.let { base64Decode(it) }
val doc = app.get(directUrl, verify = false).document
val lastDoc = app.post(
doc.select("form#landing").attr("action"),
data = mapOf("go" to doc.select("form#landing input").attr("value")),
verify = false
).document
val formLink3 = res3.select("form#wpsafelink-landing").attr("action")
val newwpsafelink = res3.select("form#wpsafelink-landing input[name=newwpsafelink]").attr("value")
val res4 = app.post(
formLink3,
requestBody = FormBody.Builder()
.add("newwpsafelink", newwpsafelink)
.build(),
headers = headers,
verify = false
).document
val finalLink = res4.selectFirst("div#wpsafe-link a")?.attr("onclick")?.substringAfter("open('")
?.substringBefore("',")
return app.get(finalLink ?: return null).url
val json = lastDoc.select("form#landing input[name=newwpsafelink]").attr("value").let { base64Decode(it) }
val finaJson = tryParseJson<FDAds>(json)?.linkr?.substringAfter("redirect=")?.let { base64Decode(it) }
return tryParseJson<Safelink>(finaJson)?.safelink
}
suspend fun bypassHrefli(url: String): String? {