Fix OlgplyProvider.kt

This commit is contained in:
Blatzar 2022-08-14 18:22:24 +02:00
parent cf61c718f8
commit c1379b558a
2 changed files with 50 additions and 51 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers // use an integer for version numbers
version = 2 version = 3
cloudstream { cloudstream {

View file

@ -27,7 +27,6 @@ class OlgplyProvider : TmdbProvider() {
// subtitleCallback: (SubtitleFile) -> Unit, // subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
) { ) {
println("URKKKKKKKKKK $url")
val foundVideo = WebViewResolver( val foundVideo = WebViewResolver(
Regex("""\.m3u8|i7njdjvszykaieynzsogaysdgb0hm8u1mzubmush4maopa4wde\.com""") Regex("""\.m3u8|i7njdjvszykaieynzsogaysdgb0hm8u1mzubmush4maopa4wde\.com""")
).resolveUsingWebView( ).resolveUsingWebView(
@ -62,55 +61,55 @@ class OlgplyProvider : TmdbProvider() {
val apiUrl = val apiUrl =
"https://olgply.xyz/${tmdbId}${mappedData.season?.let { "/$it" } ?: ""}${mappedData.episode?.let { "/$it" } ?: ""}" "https://olgply.xyz/${tmdbId}${mappedData.season?.let { "/$it" } ?: ""}${mappedData.episode?.let { "/$it" } ?: ""}"
val html = // val html =
app.get(apiUrl, referer = "https://olgply.xyz/").text // app.get(apiUrl, referer = "https://olgply.xyz/").text
val rhino = Context.enter() // val rhino = Context.enter()
rhino.optimizationLevel = -1 // rhino.optimizationLevel = -1
val scope: Scriptable = rhino.initSafeStandardObjects() // val scope: Scriptable = rhino.initSafeStandardObjects()
val documentJs = """ // val documentJs = """
Plyr = function(){}; // Plyr = function(){};
//
hlsPrototype = { // hlsPrototype = {
loadSource(url) { // loadSource(url) {
this.url = url; // this.url = url;
} // }
}; // };
//
function Hls() {}; // function Hls() {};
Hls.isSupported = function(){return true}; // Hls.isSupported = function(){return true};
//
Hls.prototype = hlsPrototype; // Hls.prototype = hlsPrototype;
Hls.prototype.constructor = Hls; // Hls.prototype.constructor = Hls;
//
document = { // document = {
"querySelector" : function() {} // "querySelector" : function() {}
}; // };
""".trimIndent() // """.trimIndent()
//
val foundJs = jsRegex.find(html)?.groupValues?.getOrNull(0) ?: return false // val foundJs = jsRegex.find(html)?.groupValues?.getOrNull(0) ?: return false
try { // try {
rhino.evaluateString(scope, documentJs + foundJs, "JavaScript", 1, null) // rhino.evaluateString(scope, documentJs + foundJs, "JavaScript", 1, null)
} catch (e: Exception) { // } catch (e: Exception) {
} // }
//
val hls = scope.get("hls", scope) as? ScriptableObject // val hls = scope.get("hls", scope) as? ScriptableObject
//
if (hls != null) { // if (hls != null) {
callback.invoke( // callback.invoke(
ExtractorLink( // ExtractorLink(
this.name, // this.name,
this.name, // this.name,
hls["url"].toString(), // hls["url"].toString(),
this.mainUrl + "/", // this.mainUrl + "/",
Qualities.Unknown.value, // Qualities.Unknown.value,
headers = mapOf("range" to "bytes=0-"), // headers = mapOf("range" to "bytes=0-"),
isM3u8 = true // isM3u8 = true
) // )
) // )
} else { // } else {
// Disgraceful fallback, but the js for Movies4Discord refuses to work correctly :( // Disgraceful fallback, but the js for Movies4Discord refuses to work correctly :(
loadLinksWithWebView(apiUrl, callback) loadLinksWithWebView(apiUrl, callback)
} // }
return true return true
} }
} }