fixed LayarKaca

This commit is contained in:
hexated 2022-11-26 20:06:38 +07:00
parent b31f705c3e
commit 89230ce991
2 changed files with 17 additions and 17 deletions

View file

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

View file

@ -8,9 +8,9 @@ import com.lagradost.cloudstream3.utils.loadExtractor
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
class LayarKacaProvider : MainAPI() { class LayarKacaProvider : MainAPI() {
override var mainUrl = "https://lk21official.art" override var mainUrl = "https://lk21official.info"
// private val redirectUrl = "https://nd21x1.github.io" // private val redirectUrl = "https://nd21x1.github.io"
private val seriesUrl = "https://nontondrama.icu" private val seriesUrl = "https://drama.nontondrama.lol"
override var name = "LayarKaca" override var name = "LayarKaca"
override val hasMainPage = true override val hasMainPage = true
override var lang = "id" override var lang = "id"
@ -49,21 +49,21 @@ class LayarKacaProvider : MainAPI() {
} }
} }
private fun changesUrl(url: String): String { // private fun changesUrl(url: String): String {
val startsWithNoHttp = url.startsWith("//") // val startsWithNoHttp = url.startsWith("//")
if (startsWithNoHttp) { // if (startsWithNoHttp) {
return "https:$url" // return "https:$url"
} else { // } else {
if (url.startsWith('/')) { // if (url.startsWith('/')) {
return seriesUrl + url // return seriesUrl + url
} // }
return "$seriesUrl/$url" // return "$seriesUrl/$url"
} // }
} // }
private fun Element.toSearchResult(): SearchResponse? { private fun Element.toSearchResult(): SearchResponse? {
val title = this.selectFirst("h1.grid-title > a")?.ownText()?.trim() ?: return null val title = this.selectFirst("h1.grid-title > a")?.ownText()?.trim() ?: return null
val href = fixUrl(this.selectFirst("a")!!.attr("href")) val href = getProperLink(this.selectFirst("a")!!.attr("href"), title)
val posterUrl = fixUrlNull(this.selectFirst(".grid-poster > a > img")?.attr("src")) val posterUrl = fixUrlNull(this.selectFirst(".grid-poster > a > img")?.attr("src"))
val type = val type =
if (this.selectFirst("div.last-episode") == null) TvType.Movie else TvType.TvSeries if (this.selectFirst("div.last-episode") == null) TvType.Movie else TvType.TvSeries
@ -130,7 +130,7 @@ class LayarKacaProvider : MainAPI() {
return if (tvType == TvType.TvSeries) { return if (tvType == TvType.TvSeries) {
val episodes = document.select("div.episode-list > a:matches(\\d+)").map { val episodes = document.select("div.episode-list > a:matches(\\d+)").map {
val href = changesUrl(it.attr("href")) val href = fixUrl(it.attr("href"))
val episode = it.text().toIntOrNull() val episode = it.text().toIntOrNull()
val season = val season =
it.attr("href").substringAfter("season-").substringBefore("-").toIntOrNull() it.attr("href").substringAfter("season-").substringBefore("-").toIntOrNull()