fixed UHD

This commit is contained in:
hexated 2022-12-08 02:17:24 +07:00
parent df4178f088
commit cfe482b264
3 changed files with 65 additions and 28 deletions

View file

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

View file

@ -1243,28 +1243,14 @@ object SoraExtractor : SoraStream() {
?.substringBefore("\")")?.let {
app.get(fixUrl(it, base)).document
}
val bitLink =
resDoc?.selectFirst("a.btn.btn-outline-success")?.attr("href") ?: return@apmap null
val baseDoc = app.get(fixUrl(bitLink, base)).document
val downLink = baseDoc.select("div.mb-4 a").randomOrNull()
?.attr("href") ?: run {
val server = baseDoc.select("div.text-center a:contains(Server 2)").attr("href")
app.get(fixUrl(server, base)).document.selectFirst("div.mb-4 a")
?.attr("href")
val bitLink = resDoc?.selectFirst("a.btn.btn-outline-success")?.attr("href")
val downloadLink = if(bitLink.isNullOrEmpty()) {
val backupIframe = resDoc?.select("a.btn.btn-outline-warning")?.attr("href")
extractBackupUHD(backupIframe ?: return@apmap null)
} else {
extractMirrorUHD(bitLink, base)
}
val downPage = app.get(downLink ?: return@apmap null).document
val downloadLink = downPage.selectFirst("form[method=post] a.btn.btn-success")
?.attr("onclick")?.substringAfter("Openblank('")?.substringBefore("')") ?: run {
val mirror = downPage.selectFirst("form[method=post] a.btn.btn-primary")
?.attr("onclick")?.substringAfter("Openblank('")?.substringBefore("')")
app.get(
mirror ?: return@apmap null
).document.selectFirst("script:containsData(input.value =)")
?.data()?.substringAfter("input.value = '")?.substringBefore("';")
}
val videoQuality =
Regex("(\\d{3,4})p").find(quality)?.groupValues?.getOrNull(1)?.toIntOrNull()
val videoQuality = Regex("(\\d{3,4})p").find(quality)?.groupValues?.getOrNull(1)?.toIntOrNull()
?: Qualities.Unknown.value
val size = Regex("(?i)\\[(\\S+\\s?(gb|mb))[]/]").find(quality)?.groupValues?.getOrNull(1)
?.let { "[$it]" } ?: quality
@ -1418,7 +1404,7 @@ object SoraExtractor : SoraStream() {
}
data class GdBotLink(
data class UHDBackupUrl(
@JsonProperty("url") val url: String? = null,
)

View file

@ -1,11 +1,13 @@
package com.hexated
import com.hexated.SoraStream.Companion.filmxyAPI
import com.hexated.SoraStream.Companion.gdbot
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.base64Decode
import com.lagradost.cloudstream3.base64Encode
import com.lagradost.cloudstream3.network.WebViewResolver
import com.lagradost.cloudstream3.utils.AppUtils
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities
import com.lagradost.cloudstream3.utils.getQualityFromName
@ -55,6 +57,55 @@ fun String.filterMedia(title: String?, yearNum: Int?, seasonNum: Int?): Boolean
}
}
suspend fun extractMirrorUHD(url: String, ref: String): String? {
val baseDoc = app.get(fixUrl(url, ref)).document
val downLink = baseDoc.select("div.mb-4 a").randomOrNull()
?.attr("href") ?: run {
val server = baseDoc.select("div.text-center a:contains(Server 2)").attr("href")
app.get(fixUrl(server, ref)).document.selectFirst("div.mb-4 a")
?.attr("href")
}
val downPage = app.get(downLink ?: return null).document
return downPage.selectFirst("form[method=post] a.btn.btn-success")
?.attr("onclick")?.substringAfter("Openblank('")?.substringBefore("')") ?: run {
val mirror = downPage.selectFirst("form[method=post] a.btn.btn-primary")
?.attr("onclick")?.substringAfter("Openblank('")?.substringBefore("')")
app.get(
mirror ?: return null
).document.selectFirst("script:containsData(input.value =)")
?.data()?.substringAfter("input.value = '")?.substringBefore("';")
}
}
suspend fun extractBackupUHD(url: String): String? {
val resumeDoc = app.get(url)
val script = resumeDoc.document.selectFirst("script:containsData(FormData.)")?.data()
val ssid = resumeDoc.cookies["PHPSESSID"]
val baseIframe = getBaseUrl(url)
val fetchLink = script?.substringAfter("fetch('")?.substringBefore("',")?.let { fixUrl(it, baseIframe) }
val token = script?.substringAfter("'token', '")?.substringBefore("');")
val body = FormBody.Builder()
.addEncoded("token", "$token")
.build()
val cookies = mapOf("PHPSESSID" to "$ssid")
val result = app.post(
fetchLink ?: return null,
requestBody = body,
headers = mapOf(
"Accept" to "*/*",
"Origin" to baseIframe,
"Sec-Fetch-Site" to "same-origin"
),
cookies = cookies,
referer = url
).text
return tryParseJson<UHDBackupUrl>(result)?.url
}
suspend fun extractGdbot(url: String): String? {
val headers = mapOf(
"Accept" to "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
@ -115,7 +166,7 @@ suspend fun extractDrivebot(url: String): String? {
cookies = cookies,
referer = iframeGdbot
).text
return AppUtils.tryParseJson<DriveBotLink>(result)?.url
return tryParseJson<DriveBotLink>(result)?.url
}
suspend fun bypassFdAds(url: String): String? {
@ -149,11 +200,11 @@ suspend fun bypassFdAds(url: String): String? {
suspend fun getFilmxyCookies(imdbId: String? = null, season: Int? = null): FilmxyCookies? {
val url = if (season == null) {
"${SoraStream.filmxyAPI}/movie/$imdbId"
"${filmxyAPI}/movie/$imdbId"
} else {
"${SoraStream.filmxyAPI}/tv/$imdbId"
"${filmxyAPI}/tv/$imdbId"
}
val cookieUrl = "${SoraStream.filmxyAPI}/wp-admin/admin-ajax.php"
val cookieUrl = "${filmxyAPI}/wp-admin/admin-ajax.php"
val res = session.get(
url,