small fix

This commit is contained in:
hexated 2023-03-12 03:39:22 +07:00
parent 08fa378e28
commit dd4da22ab0
2 changed files with 36 additions and 7 deletions

View file

@ -3,11 +3,10 @@ package com.hexated
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
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.*
import com.lagradost.cloudstream3.utils.loadExtractor
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import java.net.URI
import java.net.URLDecoder import java.net.URLDecoder
import java.net.URI
class LayarKacaProvider : MainAPI() { class LayarKacaProvider : MainAPI() {
override var mainUrl = "https://tv.lk21official.live" override var mainUrl = "https://tv.lk21official.live"
@ -22,6 +21,11 @@ class LayarKacaProvider : MainAPI() {
TvType.AsianDrama TvType.AsianDrama
) )
companion object {
const val filemoon = "https://filemoon.sx"
const val streamhide = "https://streamhide.to"
}
override val mainPage = mainPageOf( override val mainPage = mainPageOf(
"$mainUrl/populer/page/" to "Film Terplopuler", "$mainUrl/populer/page/" to "Film Terplopuler",
"$mainUrl/rating/page/" to "Film Berdasarkan IMDb Rating", "$mainUrl/rating/page/" to "Film Berdasarkan IMDb Rating",
@ -217,12 +221,37 @@ class LayarKacaProvider : MainAPI() {
it it
} }
} }
loadExtractor(link, data, subtitleCallback, callback) if(link.startsWith(filemoon) || link.startsWith(streamhide)) {
invokeBackup(link, callback)
} else {
loadExtractor(link, data, subtitleCallback, callback)
}
} }
return true return true
} }
private suspend fun invokeBackup(
url: String,
callback: (ExtractorLink) -> Unit
) {
val response = app.get(url).document
response.select("script[type=text/javascript]").map { script ->
if (script.data().contains(Regex("eval\\(function\\(p,a,c,k,e,[rd]"))) {
val unpackedscript = getAndUnpack(script.data())
val m3u8Regex = Regex("file.\"(.*?m3u8.*?)\"")
val m3u8 = m3u8Regex.find(unpackedscript)?.destructured?.component1() ?: ""
if (m3u8.isNotEmpty()) {
M3u8Helper.generateM3u8(
fixTitle(URI(url).host).substringBefore("."),
m3u8,
mainUrl
).forEach(callback)
}
}
}
}
private fun getBaseUrl(url: String): String { private fun getBaseUrl(url: String): String {
return URI(url).let { return URI(url).let {
"${it.scheme}://${it.host}" "${it.scheme}://${it.host}"

View file

@ -899,9 +899,9 @@ fun Headers.getGomoviesCookies(cookieKey: String = "set-cookie"): Map<String, St
fun String?.createSlug(): String? { fun String?.createSlug(): String? {
return this?.replace(Regex("[^\\w\\s]"), "") return this?.replace(Regex("[^\\w\\s]"), "")
?.replace(Regex("( )|( -)|(- )"), "-") ?.replace(" ", "-")
?.replace("--", "-") ?.replace(Regex("( )|( -)|(- )|(--)"), "-")
?.replace(" ", "-")?.lowercase() ?.lowercase()
} }
fun getLanguage(str: String): String { fun getLanguage(str: String): String {