final fix for eggy

This commit is contained in:
Zaw 2022-10-13 12:49:28 +03:00
parent 005e81855a
commit 1ec8892184
2 changed files with 31 additions and 32 deletions

View file

@ -1,4 +1,4 @@
version = 6 version = 7
cloudstream { cloudstream {
description = "If links do not load, try again" description = "If links do not load, try again"

View file

@ -1,16 +1,19 @@
package com.egybest package com.egybest
import com.fasterxml.jackson.annotation.JsonProperty import android.annotation.TargetApi
import android.os.Build
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper import com.lagradost.cloudstream3.utils.M3u8Helper
import com.lagradost.cloudstream3.utils.Qualities
import com.lagradost.nicehttp.Requests import com.lagradost.nicehttp.Requests
import com.lagradost.nicehttp.Session import com.lagradost.nicehttp.Session
import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import java.util.Base64
import org.mozilla.javascript.Context
import org.mozilla.javascript.Scriptable
class EgyBest : MainAPI() { class EgyBest : MainAPI() {
override var lang = "ar" override var lang = "ar"
@ -181,28 +184,8 @@ class EgyBest : MainAPI() {
} }
} }
} }
data class Sources (
@JsonProperty("quality") val quality: Int?,
@JsonProperty("link") val link: String
)
private fun String.ExtractLinks(): Boolean? { @TargetApi(Build.VERSION_CODES.O)
val list = Regex("#EXT.*\\n.*").findAll(this).toList()
println(list)
list.map {
val url = Regex(".*stream\\.m3u8").find(it.value)?.value.toString()
val quality = Regex("[0-9]{3,4}x[0-9]{3,4}").find(it.value)?.value?.replace(".*x".toRegex(),"")?.toInt()
ExtractorLink(
this@EgyBest.name,
this@EgyBest.name,
url,
this@EgyBest.mainUrl,
quality ?: Qualities.Unknown.value,
true
)
}
return true
}
override suspend fun loadLinks( override suspend fun loadLinks(
data: String, data: String,
isCasting: Boolean, isCasting: Boolean,
@ -227,12 +210,28 @@ override suspend fun loadLinks(
headers = mapOf("range" to "bytes=0-") headers = mapOf("range" to "bytes=0-")
).forEach(callback) ).forEach(callback)
} ?: run { } ?: run {
val jsCode = videoSoup.select("script")[1].html() var jsCode = videoSoup.select("script")[1].html()
val javascriptResult = val function = videoSoup.select("script")[2].attr("onload")
session.post("https://helper.zr5.repl.co", data = mapOf("data" to jsCode, "baseUrl" to baseURL)).text.split(",") val verificationToken = Regex("\\{'[0-9a-zA-Z_]*':'ok'\\}").findAll(jsCode).first().value.replace("\\{'|':.*".toRegex(), "")
val adLink = javascriptResult[0] val encodedAdLinkVar = Regex("\\([0-9a-zA-Z_]{2,12}\\[Math").findAll(jsCode).first().value.replace("\\(|\\[M.*".toRegex(),"")
val verificationLink = javascriptResult[1] val encodingArraysRegEx = Regex(",[0-9a-zA-Z_]{2,12}=\\[]").findAll(jsCode).toList()
val verificationToken = javascriptResult[2] val firstEncodingArray = encodingArraysRegEx[1].value.replace(",|=.*".toRegex(),"")
val secondEncodingArray = encodingArraysRegEx[2].value.replace(",|=.*".toRegex(),"")
jsCode = jsCode.replace("^<script type=\"text/javascript\">".toRegex(),"")
jsCode = jsCode.replace(",\\\$\\('\\*'\\).*".toRegex(),";")
jsCode = jsCode.replace(",ismob=.*]\\);".toRegex(),";")
jsCode = jsCode.replace("var a0b=\\(function\\(\\)(.*)a0a\\(\\);".toRegex(),"")
jsCode = "$jsCode var link = ''; for (var i = 0; i <= $secondEncodingArray['length']; i++) { link += $firstEncodingArray[$secondEncodingArray[i]] || ''; } return [link, $encodedAdLinkVar[0]] };var result = $function"
val javascriptResult = jsCode.runJS("result").split(",")
val verificationPath = javascriptResult[0]
val encodedAdPath = javascriptResult[1]
val encodedString = encodedAdPath + "=".repeat(encodedAdPath.length % 4)
val decodedPath = String(Base64.getDecoder().decode(encodedString))
val adLink = "$baseURL/$decodedPath"
val verificationLink = "$baseURL/tvc.php?verify=$verificationPath"
session.get(adLink) session.get(adLink)
session.post(verificationLink, data=mapOf(verificationToken to "ok")) session.post(verificationLink, data=mapOf(verificationToken to "ok"))