added new sources in LayarKaca

This commit is contained in:
hexated 2023-01-24 10:41:12 +07:00
parent 1a80c14c94
commit 563c4f633d
3 changed files with 44 additions and 4 deletions

View File

@ -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) }
}
}

View File

@ -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")
}

View File

@ -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())
}
}