mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Added Vidguard Extractor (#1053)
This commit is contained in:
parent
e6b9d621f9
commit
e2946cad6b
2 changed files with 104 additions and 1 deletions
|
@ -0,0 +1,101 @@
|
|||
package com.lagradost.cloudstream3.extractors
|
||||
|
||||
import android.util.Log
|
||||
import com.lagradost.cloudstream3.SubtitleFile
|
||||
import com.lagradost.cloudstream3.app
|
||||
import com.lagradost.cloudstream3.utils.AppUtils
|
||||
import com.lagradost.cloudstream3.utils.ExtractorApi
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.INFER_TYPE
|
||||
import com.lagradost.cloudstream3.utils.Qualities
|
||||
import org.mozilla.javascript.Context
|
||||
import org.mozilla.javascript.NativeJSON
|
||||
import org.mozilla.javascript.NativeObject
|
||||
import org.mozilla.javascript.Scriptable
|
||||
import java.util.Base64
|
||||
|
||||
open class Vidguardto : ExtractorApi() {
|
||||
override val name = "Vidguard"
|
||||
override val mainUrl = "https://vidguard.to"
|
||||
override val requiresReferer = false
|
||||
|
||||
override suspend fun getUrl(
|
||||
url: String,
|
||||
referer: String?,
|
||||
subtitleCallback: (SubtitleFile) -> Unit,
|
||||
callback: (ExtractorLink) -> Unit
|
||||
) {
|
||||
val res = app.get(url)
|
||||
val resc = res.document.select("script:containsData(eval)").firstOrNull()?.data()
|
||||
resc?.let {
|
||||
val jsonStr2 = AppUtils.parseJson<SvgObject>(runJS2(it))
|
||||
val watchlink = sigDecode(jsonStr2.stream)
|
||||
|
||||
callback.invoke(
|
||||
ExtractorLink(
|
||||
this.name,
|
||||
name,
|
||||
watchlink,
|
||||
this.mainUrl,
|
||||
Qualities.Unknown.value,
|
||||
INFER_TYPE
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun sigDecode(url: String): String {
|
||||
val sig = url.split("sig=")[1].split("&")[0]
|
||||
var t = ""
|
||||
for (v in sig.chunked(2)) {
|
||||
val byteValue = Integer.parseInt(v, 16) xor 2
|
||||
t += byteValue.toChar()
|
||||
}
|
||||
val padding = when (t.length % 4) {
|
||||
2 -> "=="
|
||||
3 -> "="
|
||||
else -> ""
|
||||
}
|
||||
val decoded = Base64.getDecoder().decode((t + padding).toByteArray(Charsets.UTF_8))
|
||||
t = String(decoded).dropLast(5).reversed()
|
||||
val charArray = t.toCharArray()
|
||||
for (i in 0 until charArray.size - 1 step 2) {
|
||||
val temp = charArray[i]
|
||||
charArray[i] = charArray[i + 1]
|
||||
charArray[i + 1] = temp
|
||||
}
|
||||
val modifiedSig = String(charArray).dropLast(5)
|
||||
return url.replace(sig, modifiedSig)
|
||||
}
|
||||
|
||||
private fun runJS2(hideMyHtmlContent: String): String {
|
||||
Log.d("runJS", "start")
|
||||
val rhino = Context.enter()
|
||||
rhino.initSafeStandardObjects()
|
||||
rhino.optimizationLevel = -1
|
||||
val scope: Scriptable = rhino.initSafeStandardObjects()
|
||||
scope.put("window", scope, scope)
|
||||
var result = ""
|
||||
try {
|
||||
Log.d("runJS", "Executing JavaScript: $hideMyHtmlContent")
|
||||
rhino.evaluateString(scope, hideMyHtmlContent, "JavaScript", 1, null)
|
||||
val svgObject = scope.get("svg", scope)
|
||||
result = if (svgObject is NativeObject) {
|
||||
NativeJSON.stringify(Context.getCurrentContext(), scope, svgObject, null, null).toString()
|
||||
} else {
|
||||
Context.toString(svgObject)
|
||||
}
|
||||
Log.d("runJS", "Result: $result")
|
||||
} catch (e: Exception) {
|
||||
Log.e("runJS", "Error executing JavaScript", e)
|
||||
} finally {
|
||||
Context.exit()
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
data class SvgObject(
|
||||
val stream: String,
|
||||
val hash: String
|
||||
)
|
||||
}
|
|
@ -186,6 +186,7 @@ import com.lagradost.cloudstream3.extractors.VideoVard
|
|||
import com.lagradost.cloudstream3.extractors.VideovardSX
|
||||
import com.lagradost.cloudstream3.extractors.Vidgomunime
|
||||
import com.lagradost.cloudstream3.extractors.Vidgomunimesb
|
||||
import com.lagradost.cloudstream3.extractors.Vidguardto
|
||||
import com.lagradost.cloudstream3.extractors.VidhideExtractor
|
||||
import com.lagradost.cloudstream3.extractors.Vidmoly
|
||||
import com.lagradost.cloudstream3.extractors.Vidmolyme
|
||||
|
@ -888,7 +889,8 @@ val extractorApis: MutableList<ExtractorApi> = arrayListOf(
|
|||
StreamWishExtractor(),
|
||||
EmturbovidExtractor(),
|
||||
Vtbe(),
|
||||
EPlayExtractor()
|
||||
EPlayExtractor(),
|
||||
Vidguardto()
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue