This commit is contained in:
hexated 2023-10-01 15:34:30 +07:00
parent c034103e81
commit 836154ac84
3 changed files with 18 additions and 12 deletions

View file

@ -62,7 +62,7 @@ object NineTv {
) { ) {
val mainUrl = getBaseUrl(url) val mainUrl = getBaseUrl(url)
val res = app.get(url, referer = referer) val res = app.get(url, referer = referer)
val master = Regex("MasterJS\\s*=\\s*'([^']+)").find(res.text)?.groupValues?.get(1) val master = Regex("JScript\\s*=\\s*'([^']+)").find(res.text)?.groupValues?.get(1)
val key = res.document.getKeys() ?: throw ErrorLoadingException("can't generate key") val key = res.document.getKeys() ?: throw ErrorLoadingException("can't generate key")
val decrypt = AesHelper.cryptoAESHandler(master ?: return, key.toByteArray(), false) val decrypt = AesHelper.cryptoAESHandler(master ?: return, key.toByteArray(), false)
?.replace("\\", "") ?.replace("\\", "")
@ -70,11 +70,11 @@ object NineTv {
val source = Regex(""""?file"?:\s*"([^"]+)""").find(decrypt)?.groupValues?.get(1) val source = Regex(""""?file"?:\s*"([^"]+)""").find(decrypt)?.groupValues?.get(1)
val tracks = Regex("""tracks:\s*\[(.+)]""").find(decrypt)?.groupValues?.get(1) val tracks = Regex("""tracks:\s*\[(.+)]""").find(decrypt)?.groupValues?.get(1)
val name = source?.getHost() val name = url.getHost()
M3u8Helper.generateM3u8( M3u8Helper.generateM3u8(
name ?: return, name,
source, source ?: return,
"$mainUrl/", "$mainUrl/",
headers = mapOf( headers = mapOf(
"Accept" to "*/*", "Accept" to "*/*",

View file

@ -248,7 +248,7 @@ object NineTv {
) { ) {
val mainUrl = getBaseUrl(url) val mainUrl = getBaseUrl(url)
val res = app.get(url, referer = referer) val res = app.get(url, referer = referer)
val master = Regex("MasterJS\\s*=\\s*'([^']+)").find(res.text)?.groupValues?.get(1) val master = Regex("JScript\\s*=\\s*'([^']+)").find(res.text)?.groupValues?.get(1)
val key = res.document.getKeys() ?: throw ErrorLoadingException("can't generate key") val key = res.document.getKeys() ?: throw ErrorLoadingException("can't generate key")
val decrypt = AesHelper.cryptoAESHandler(master ?: return, key.toByteArray(), false) val decrypt = AesHelper.cryptoAESHandler(master ?: return, key.toByteArray(), false)
?.replace("\\", "") ?.replace("\\", "")
@ -256,11 +256,11 @@ object NineTv {
val source = Regex(""""?file"?:\s*"([^"]+)""").find(decrypt)?.groupValues?.get(1) val source = Regex(""""?file"?:\s*"([^"]+)""").find(decrypt)?.groupValues?.get(1)
val tracks = Regex("""tracks:\s*\[(.+)]""").find(decrypt)?.groupValues?.get(1) val tracks = Regex("""tracks:\s*\[(.+)]""").find(decrypt)?.groupValues?.get(1)
val name = source?.getHost() val name = url.getHost()
M3u8Helper.generateM3u8( M3u8Helper.generateM3u8(
name ?: return, name,
source, source ?: return,
"$mainUrl/", "$mainUrl/",
headers = mapOf( headers = mapOf(
"Accept" to "*/*", "Accept" to "*/*",

View file

@ -2129,15 +2129,21 @@ object SoraExtractor : SoraStream() {
?.attr("href") ?.attr("href")
} ?: return } ?: return
val users = if(season == null) {
media.third.substringAfterLast("/") to "0"
} else {
media.third.substringAfterLast("/") to iframe.substringAfterLast("/").substringBefore("-")
}
val res = app.get(fixUrl(iframe, api), verify = false) val res = app.get(fixUrl(iframe, api), verify = false)
val serverUrl = "var url = '(/user/servers/.*?\\?ep=.*?)';".toRegex() val serverUrl = res.document.selectFirst("script:containsData(pushState)")?.data()?.let {
.find(res.text)?.groupValues?.get(1) ?: return """,\s*'([^']+)""".toRegex().find(it)?.groupValues?.get(1)
} ?: return
val cookies = res.cookies val cookies = res.cookies
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)
val serverRes = app.get( val serverRes = app.get(
"$api$serverUrl", "$api/user/servers/${users.first}?ep=${users.second}",
cookies = cookies, referer = url, headers = headers cookies = cookies, referer = url, headers = headers
) )
val unpack = getAndUnpack(serverRes.text) val unpack = getAndUnpack(serverRes.text)
@ -2146,7 +2152,7 @@ object SoraExtractor : SoraStream() {
serverRes.document.select("ul li").amap { el -> 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&_=$unixTimeMS", "${fixUrl(serverUrl, api)}?server=$server&_=$unixTimeMS",
cookies = cookies, cookies = cookies,
referer = url, referer = url,
headers = headers headers = headers