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 // use an integer for version numbers
version = 46 version = 47
cloudstream { cloudstream {

View file

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

View file

@ -1,11 +1,13 @@
package com.hexated package com.hexated
import com.hexated.SoraStream.Companion.filmxyAPI
import com.hexated.SoraStream.Companion.gdbot import com.hexated.SoraStream.Companion.gdbot
import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.base64Decode import com.lagradost.cloudstream3.base64Decode
import com.lagradost.cloudstream3.base64Encode import com.lagradost.cloudstream3.base64Encode
import com.lagradost.cloudstream3.network.WebViewResolver import com.lagradost.cloudstream3.network.WebViewResolver
import com.lagradost.cloudstream3.utils.AppUtils import com.lagradost.cloudstream3.utils.AppUtils
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities import com.lagradost.cloudstream3.utils.Qualities
import com.lagradost.cloudstream3.utils.getQualityFromName 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? { suspend fun extractGdbot(url: String): String? {
val headers = mapOf( val headers = mapOf(
"Accept" to "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", "Accept" to "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
@ -115,13 +166,13 @@ suspend fun extractDrivebot(url: String): String? {
cookies = cookies, cookies = cookies,
referer = iframeGdbot referer = iframeGdbot
).text ).text
return AppUtils.tryParseJson<DriveBotLink>(result)?.url return tryParseJson<DriveBotLink>(result)?.url
} }
suspend fun bypassFdAds(url: String): String? { suspend fun bypassFdAds(url: String): String? {
val res = app.get(url).document val res = app.get(url).document
val freeRedirect = res.selectFirst("a#link")?.attr("href") val freeRedirect = res.selectFirst("a#link")?.attr("href")
val res2 = app.get(freeRedirect ?: return null , verify = false).document val res2 = app.get(freeRedirect ?: return null, verify = false).document
val formLink = res2.select("form#landing").attr("action") val formLink = res2.select("form#landing").attr("action")
val value = res2.select("form#landing input").attr("value") val value = res2.select("form#landing input").attr("value")
val res3 = app.post(formLink, data = mapOf("go" to value), verify = false).document val res3 = app.post(formLink, data = mapOf("go" to value), verify = false).document
@ -149,11 +200,11 @@ suspend fun bypassFdAds(url: String): String? {
suspend fun getFilmxyCookies(imdbId: String? = null, season: Int? = null): FilmxyCookies? { suspend fun getFilmxyCookies(imdbId: String? = null, season: Int? = null): FilmxyCookies? {
val url = if (season == null) { val url = if (season == null) {
"${SoraStream.filmxyAPI}/movie/$imdbId" "${filmxyAPI}/movie/$imdbId"
} else { } 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( val res = session.get(
url, url,