sora: small fix

This commit is contained in:
hexated 2023-08-21 17:13:07 +07:00
parent 83e2c399f6
commit 52f50292c9

View file

@ -2320,16 +2320,17 @@ object SoraExtractor : SoraStream() {
} ?: return } ?: return
val res = app.get(fixUrl(iframe, primewireAPI), verify = false) val res = app.get(fixUrl(iframe, primewireAPI), verify = false)
val match = "var url = '(/user/servers/.*?\\?ep=.*?)';".toRegex().find(res.text) val serverUrl = "var url = '(/user/servers/.*?\\?ep=.*?)';".toRegex().find(res.text)?.groupValues?.get(1) ?: return
val serverUrl = match?.groupValues?.get(1) ?: return
val cookies = res.okhttpResponse.headers.getPrimewireCookies() val cookies = res.okhttpResponse.headers.getPrimewireCookies()
val url = res.document.select("meta[property=og:url]").attr("content") val url = res.document.select("meta[property=og:url]").attr("content")
val headers = mapOf("X-Requested-With" to "XMLHttpRequest") val headers = mapOf("X-Requested-With" to "XMLHttpRequest")
val qualities = intArrayOf(2160, 1440, 1080, 720, 480, 360) val qualities = intArrayOf(2160, 1440, 1080, 720, 480, 360)
app.get( val serverRes = app.get(
"$primewireAPI$serverUrl", "$primewireAPI$serverUrl",
cookies = cookies, referer = url, headers = headers cookies = cookies, referer = url, headers = headers
).document.select("ul li").amap { el -> )
val key = getAndUnpack(serverRes.text).substringAfter("(key=").substringBefore(")")
serverRes.document.select("ul li").amap { el ->
val server = el.attr("data-value") val server = el.attr("data-value")
val encryptedData = app.get( val encryptedData = app.get(
"$url?server=$server&_=${System.currentTimeMillis()}", "$url?server=$server&_=${System.currentTimeMillis()}",
@ -2337,7 +2338,7 @@ object SoraExtractor : SoraStream() {
referer = url, referer = url,
headers = headers headers = headers
).text ).text
val json = base64Decode(encryptedData).decodePrimewireXor() val json = base64Decode(encryptedData).decodePrimewireXor(key)
val links = tryParseJson<List<PrimewireSources>>(json) ?: return@amap val links = tryParseJson<List<PrimewireSources>>(json) ?: return@amap
links.forEach { video -> links.forEach { video ->
qualities.filter { it <= video.max.toInt() }.forEach { qualities.filter { it <= video.max.toInt() }.forEach {