From e986782af64d325d96fd95333f19d573c62ff94f Mon Sep 17 00:00:00 2001 From: hexated Date: Fri, 16 Dec 2022 00:30:38 +0700 Subject: [PATCH] [Sora] small clean --- .../main/kotlin/com/hexated/SoraExtractor.kt | 54 ++----------------- .../src/main/kotlin/com/hexated/SoraUtils.kt | 37 +++++++++++++ 2 files changed, 42 insertions(+), 49 deletions(-) diff --git a/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt b/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt index 3cde3148..323dcba5 100644 --- a/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt +++ b/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt @@ -1524,58 +1524,14 @@ object SoraExtractor : SoraStream() { } val server = getTvMoviesServer(url, season, episode) ?: return - - val request = session.get(server.second ?: return, referer = "$tvMoviesAPI/") - var filehosting = session.baseClient.cookieJar.loadForRequest(url.toHttpUrl()) - .find { it.name == "filehosting" }?.value - val iframe = request.document.findTvMoviesIframe() - delay(10000) - val request2 = session.get( - iframe ?: return, referer = url, headers = mapOf( - "Accept" to "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", - "Connection" to "keep-alive", - "Cookie" to "filehosting=$filehosting", - ) - ) - - filehosting = session.baseClient.cookieJar.loadForRequest(url.toHttpUrl()) - .find { it.name == "filehosting" }?.value - val iframe2 = request2.document.findTvMoviesIframe() - delay(11000) - val request3 = session.get( - iframe2 ?: return, referer = iframe, headers = mapOf( - "Accept" to "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", - "Connection" to "keep-alive", - "Cookie" to "filehosting=$filehosting", - ) - ) - - filehosting = session.baseClient.cookieJar.loadForRequest(url.toHttpUrl()) - .find { it.name == "filehosting" }?.value - val response = request3.document - val videoLink = - response.selectFirst("button.btn.btn--primary")?.attr("onclick") - ?.substringAfter("location = '")?.substringBefore("';")?.let { - app.get( - it, referer = iframe2, headers = mapOf( - "Accept" to "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", - "Connection" to "keep-alive", - "Cookie" to "filehosting=$filehosting", - ) - ).url - } - - val quality = - Regex("([0-9]{3,4})p").find(server.first)?.groupValues?.getOrNull(1)?.toIntOrNull() - val size = - response.selectFirst("ul.row--list li:contains(Filesize) span:last-child") - ?.text() + val videoData = extractCovyn(server.second ?: return) + val quality = Regex("([0-9]{3,4})p").find(server.first)?.groupValues?.getOrNull(1)?.toIntOrNull() callback.invoke( ExtractorLink( - "TVMovies [$size]", - "TVMovies [$size]", - videoLink ?: return, + "TVMovies [${videoData?.second}]", + "TVMovies [${videoData?.second}]", + videoData?.first ?: return, "", quality ?: Qualities.Unknown.value ) diff --git a/SoraStream/src/main/kotlin/com/hexated/SoraUtils.kt b/SoraStream/src/main/kotlin/com/hexated/SoraUtils.kt index 24d6918c..1a7c7ba7 100644 --- a/SoraStream/src/main/kotlin/com/hexated/SoraUtils.kt +++ b/SoraStream/src/main/kotlin/com/hexated/SoraUtils.kt @@ -2,6 +2,7 @@ package com.hexated import com.hexated.SoraStream.Companion.filmxyAPI import com.hexated.SoraStream.Companion.gdbot +import com.hexated.SoraStream.Companion.tvMoviesAPI import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.base64Decode import com.lagradost.cloudstream3.base64Encode @@ -12,6 +13,7 @@ import com.lagradost.cloudstream3.utils.Qualities import com.lagradost.cloudstream3.utils.getQualityFromName import com.lagradost.nicehttp.RequestBodyTypes import com.lagradost.nicehttp.requestCreator +import kotlinx.coroutines.delay import okhttp3.FormBody import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType.Companion.toMediaTypeOrNull @@ -200,6 +202,41 @@ suspend fun extractOiya(url: String, quality: String): String? { ?: doc.selectFirst("div.wp-block-button a")?.attr("href") } +suspend fun extractCovyn(url: String?): Pair? { + val request = session.get(url ?: return null, referer = "${tvMoviesAPI}/") + val filehosting = session.baseClient.cookieJar.loadForRequest(url.toHttpUrl()) + .find { it.name == "filehosting" }?.value + val headers = mapOf( + "Accept" to "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", + "Connection" to "keep-alive", + "Cookie" to "filehosting=$filehosting", + ) + + val iframe = request.document.findTvMoviesIframe() + delay(10500) + val request2 = session.get( + iframe ?: return null, referer = url, headers = headers + ) + + val iframe2 = request2.document.findTvMoviesIframe() + delay(10500) + val request3 = session.get( + iframe2 ?: return null, referer = iframe, headers = headers + ) + + val response = request3.document + val videoLink = response.selectFirst("button.btn.btn--primary")?.attr("onclick") + ?.substringAfter("location = '")?.substringBefore("';")?.let { + app.get( + it, referer = iframe2, headers = headers + ).url + } + val size = response.selectFirst("ul.row--list li:contains(Filesize) span:last-child") + ?.text() + + return Pair(videoLink, size) +} + suspend fun bypassFdAds(url: String): String? { val res = app.get(url).document val freeRedirect = res.selectFirst("a#link")?.attr("href")