[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

@ -1864,3 +1864,11 @@ data class MediaAni(
data class DataAni( data class DataAni(
@JsonProperty("data") val data: MediaAni? = null, @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? { suspend fun bypassFdAds(url: String?): String? {
val freeRedirect = app.get(url ?: return null, verify = false).document.selectFirst("a#link")?.attr("href") val directUrl = app.get(url ?: return null, verify = false).document.select("a#link").attr("href")
val res = app.get(freeRedirect ?: return null,verify = false).document .substringAfter("/go/")
val formLink = res.select("form#landing").attr("action") .let { base64Decode(it) }
val value = res.select("form#landing input").attr("value") val doc = app.get(directUrl, verify = false).document
val lastDoc = app.post(
val headers = mapOf( doc.select("form#landing").attr("action"),
"Accept" to "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", data = mapOf("go" to doc.select("form#landing input").attr("value")),
"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,
verify = false verify = false
).document ).document
val json = lastDoc.select("form#landing input[name=newwpsafelink]").attr("value").let { base64Decode(it) }
val formLink3 = res3.select("form#wpsafelink-landing").attr("action") val finaJson = tryParseJson<FDAds>(json)?.linkr?.substringAfter("redirect=")?.let { base64Decode(it) }
val newwpsafelink = res3.select("form#wpsafelink-landing input[name=newwpsafelink]").attr("value") return tryParseJson<Safelink>(finaJson)?.safelink
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
} }
suspend fun bypassHrefli(url: String): String? { suspend fun bypassHrefli(url: String): String? {