From 563c4f633d1e1f91b0c87cfe89bd4cd086eb83ba Mon Sep 17 00:00:00 2001 From: hexated Date: Tue, 24 Jan 2023 10:41:12 +0700 Subject: [PATCH] added new sources in LayarKaca --- .../src/main/kotlin/com/hexated/Filemoon.kt | 33 +++++++++++++++++++ .../kotlin/com/hexated/LayarKacaProvider.kt | 14 +++++--- .../com/hexated/LayarKacaProviderPlugin.kt | 1 + 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 LayarKacaProvider/src/main/kotlin/com/hexated/Filemoon.kt diff --git a/LayarKacaProvider/src/main/kotlin/com/hexated/Filemoon.kt b/LayarKacaProvider/src/main/kotlin/com/hexated/Filemoon.kt new file mode 100644 index 00000000..2af8eace --- /dev/null +++ b/LayarKacaProvider/src/main/kotlin/com/hexated/Filemoon.kt @@ -0,0 +1,33 @@ +package com.hexated + +import com.lagradost.cloudstream3.SubtitleFile +import com.lagradost.cloudstream3.app +import com.lagradost.cloudstream3.utils.* +import org.jsoup.nodes.Element + +open class Filemoon : ExtractorApi() { + override val name = "Filemoon" + override val mainUrl = "https://filemoon.sx" + override val requiresReferer = true + + override suspend fun getUrl( + url: String, + referer: String?, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ) { + val doc = app.get(url).document + val link = unpackJs(doc)?.substringAfter("file:\"")?.substringBefore("\"") + M3u8Helper.generateM3u8( + name, + link ?: return, + "$mainUrl/", + ).forEach(callback) + } + + private fun unpackJs(script: Element): String? { + return script.select("script").find { it.data().contains("eval(function(p,a,c,k,e,d)") } + ?.data()?.let { getAndUnpack(it) } + } + +} \ No newline at end of file diff --git a/LayarKacaProvider/src/main/kotlin/com/hexated/LayarKacaProvider.kt b/LayarKacaProvider/src/main/kotlin/com/hexated/LayarKacaProvider.kt index c11ebbfd..8c5ea87f 100644 --- a/LayarKacaProvider/src/main/kotlin/com/hexated/LayarKacaProvider.kt +++ b/LayarKacaProvider/src/main/kotlin/com/hexated/LayarKacaProvider.kt @@ -6,6 +6,7 @@ import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.loadExtractor import org.jsoup.nodes.Element +import java.net.URLDecoder class LayarKacaProvider : MainAPI() { override var mainUrl = "https://lk21official.vip" @@ -196,10 +197,14 @@ class LayarKacaProvider : MainAPI() { document.select("ul#loadProviders > li").map { fixUrl(it.select("a").attr("href")) }.apmap { - val link = if (it.startsWith("https://layarkacaxxi.icu")) { - it.substringBeforeLast("/") - } else { - it + val link = when { + it.startsWith("https://layarkacaxxi.icu") -> { + it.substringBeforeLast("/") + } + it.startsWith("https://bananalicious.xyz") -> decode(it.substringAfter("url=")) + else -> { + it + } } loadExtractor(link, data, subtitleCallback, callback) } @@ -207,5 +212,6 @@ class LayarKacaProvider : MainAPI() { return true } + private fun decode(input: String): String = URLDecoder.decode(input, "utf-8").replace(" ", "%20") } \ No newline at end of file diff --git a/LayarKacaProvider/src/main/kotlin/com/hexated/LayarKacaProviderPlugin.kt b/LayarKacaProvider/src/main/kotlin/com/hexated/LayarKacaProviderPlugin.kt index 9743b456..6aeb7a18 100644 --- a/LayarKacaProvider/src/main/kotlin/com/hexated/LayarKacaProviderPlugin.kt +++ b/LayarKacaProvider/src/main/kotlin/com/hexated/LayarKacaProviderPlugin.kt @@ -10,5 +10,6 @@ class LayarKacaProviderPlugin: Plugin() { override fun load(context: Context) { // All providers should be added in this manner. Please don't edit the providers list directly. registerMainAPI(LayarKacaProvider()) + registerExtractorAPI(Filemoon()) } } \ No newline at end of file