sora: fix filmxy

This commit is contained in:
hexated 2023-08-19 09:38:32 +07:00
parent 0c99e2af7f
commit 8c287e2cd1
2 changed files with 22 additions and 22 deletions

View file

@ -562,7 +562,7 @@ object SoraExtractor : SoraStream() {
} else { } else {
"${filmxyAPI}/tv/$imdbId" "${filmxyAPI}/tv/$imdbId"
} }
val filmxyCookies = getFilmxyCookies(imdbId, season) val filmxyCookies = getFilmxyCookies(url)
val doc = session.get(url, cookies = filmxyCookies).document val doc = session.get(url, cookies = filmxyCookies).document
val script = doc.selectFirst("script:containsData(var isSingle)")?.data() ?: return val script = doc.selectFirst("script:containsData(var isSingle)")?.data() ?: return

View file

@ -905,31 +905,29 @@ suspend fun getTvMoviesServer(url: String, season: Int?, episode: Int?): Pair<St
} }
} }
suspend fun getFilmxyCookies(imdbId: String? = null, season: Int? = null): Map<String,String> { var filmxyCookies: Map<String,String>? = null
suspend fun getFilmxyCookies(url: String) = filmxyCookies ?: fetchFilmxyCookies(url).also { filmxyCookies = it }
suspend fun fetchFilmxyCookies(url: String): Map<String, String> {
val url = if (season == null) { val defaultCookies = mutableMapOf("G_ENABLED_IDPS" to "google", "true_checker" to "1", "XID" to "1")
"${filmxyAPI}/movie/$imdbId" session.get(
} else {
"${filmxyAPI}/tv/$imdbId"
}
val cookieUrl = "${filmxyAPI}/wp-admin/admin-ajax.php"
val res = session.get(
url, url,
headers = mapOf( 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"
), ),
cookies = defaultCookies,
) )
if (!res.isSuccessful) return emptyMap()
val userNonce =
res.document.select("script").find { it.data().contains("var userNonce") }?.data()?.let {
Regex("var\\suserNonce.*?\"(\\S+?)\";").find(it)?.groupValues?.get(1)
}
val phpsessid = session.baseClient.cookieJar.loadForRequest(url.toHttpUrl()) val phpsessid = session.baseClient.cookieJar.loadForRequest(url.toHttpUrl())
.first { it.name == "PHPSESSID" }.value .first { it.name == "PHPSESSID" }.value
defaultCookies["PHPSESSID"] = phpsessid
val userNonce =
app.get("$filmxyAPI/login/?redirect_to=$filmxyAPI/", cookies = defaultCookies).document.select("script")
.find { it.data().contains("var userNonce") }?.data()?.let {
Regex("var\\suserNonce.*?\"(\\S+?)\";").find(it)?.groupValues?.get(1)
}
val cookieUrl = "${filmxyAPI}/wp-admin/admin-ajax.php"
session.post( session.post(
cookieUrl, cookieUrl,
@ -938,12 +936,14 @@ suspend fun getFilmxyCookies(imdbId: String? = null, season: Int? = null): Map<S
"nonce" to "$userNonce", "nonce" to "$userNonce",
), ),
headers = mapOf( headers = mapOf(
"Cookie" to "PHPSESSID=$phpsessid; G_ENABLED_IDPS=google",
"X-Requested-With" to "XMLHttpRequest", "X-Requested-With" to "XMLHttpRequest",
) ),
cookies = defaultCookies
) )
val cookieJar = session.baseClient.cookieJar.loadForRequest(cookieUrl.toHttpUrl()).associate { it.name to it.value }.toMutableMap() val cookieJar = session.baseClient.cookieJar.loadForRequest(cookieUrl.toHttpUrl())
return cookieJar.plus(mapOf("G_ENABLED_IDPS" to "google")) .associate { it.name to it.value }.toMutableMap()
return cookieJar.plus(defaultCookies)
} }
fun Document.findTvMoviesIframe(): String? { fun Document.findTvMoviesIframe(): String? {