mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
fixed LayarKaca
This commit is contained in:
parent
23d5d33882
commit
6f0055f41f
2 changed files with 32 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
|
@ -23,5 +23,5 @@ cloudstream {
|
||||||
"Movie",
|
"Movie",
|
||||||
)
|
)
|
||||||
|
|
||||||
iconUrl = "https://www.google.com/s2/favicons?domain=lk21.homes&sz=%size%"
|
iconUrl = "https://www.google.com/s2/favicons?domain=lk21official.biz&sz=%size%"
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@ import org.jsoup.Jsoup
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
|
||||||
class LayarKacaProvider : MainAPI() {
|
class LayarKacaProvider : MainAPI() {
|
||||||
override var mainUrl = "https://lk21.cloud"
|
override var mainUrl = "https://lk21official.biz"
|
||||||
override var name = "LayarKaca"
|
override var name = "LayarKaca"
|
||||||
override val hasMainPage = true
|
override val hasMainPage = true
|
||||||
override var lang = "id"
|
override var lang = "id"
|
||||||
|
@ -27,6 +27,10 @@ class LayarKacaProvider : MainAPI() {
|
||||||
"$mainUrl/latest/page/" to "Film Upload Terbaru",
|
"$mainUrl/latest/page/" to "Film Upload Terbaru",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val seriesUrl = "https://nontondrama.today"
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun getMainPage(
|
override suspend fun getMainPage(
|
||||||
page: Int,
|
page: Int,
|
||||||
request: MainPageRequest
|
request: MainPageRequest
|
||||||
|
@ -38,9 +42,29 @@ class LayarKacaProvider : MainAPI() {
|
||||||
return newHomePageResponse(request.name, home)
|
return newHomePageResponse(request.name, home)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getProperLink(str: String, check: String): String {
|
||||||
|
return if (check.contains("/series", true) || check.contains("Season", true)) {
|
||||||
|
str.replace(mainUrl, seriesUrl)
|
||||||
|
} else {
|
||||||
|
str
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun changesUrl(url: String): String {
|
||||||
|
val startsWithNoHttp = url.startsWith("//")
|
||||||
|
if (startsWithNoHttp) {
|
||||||
|
return "https:$url"
|
||||||
|
} else {
|
||||||
|
if (url.startsWith('/')) {
|
||||||
|
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("h1.grid-title > a")!!.attr("href"))
|
val href = getProperLink(fixUrl(this.selectFirst("h1.grid-title > 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 quality = this.select("div.quality").text().trim()
|
val quality = this.select("div.quality").text().trim()
|
||||||
return newMovieSearchResponse(title, href, TvType.Movie) {
|
return newMovieSearchResponse(title, href, TvType.Movie) {
|
||||||
|
@ -50,12 +74,12 @@ class LayarKacaProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun search(query: String): List<SearchResponse> {
|
override suspend fun search(query: String): List<SearchResponse> {
|
||||||
val link = "$mainUrl/?s=$query"
|
val document = app.get( "$mainUrl/?s=$query").document
|
||||||
val document = app.get(link).document
|
|
||||||
|
|
||||||
return document.select("div.search-item").map {
|
return document.select("div.search-item").map {
|
||||||
val title = it.selectFirst("h2 > a")!!.text().trim()
|
val title = it.selectFirst("h2 > a")!!.text().trim()
|
||||||
val href = it.selectFirst("h2 > a")!!.attr("href")
|
val type = it.selectFirst("p.cat-links a")?.attr("href").toString()
|
||||||
|
val href = getProperLink(it.selectFirst("h2 > a")!!.attr("href"), type)
|
||||||
val posterUrl = fixUrl(it.selectFirst("img.img-thumbnail")?.attr("src").toString())
|
val posterUrl = fixUrl(it.selectFirst("img.img-thumbnail")?.attr("src").toString())
|
||||||
newTvSeriesSearchResponse(title, href, TvType.TvSeries) {
|
newTvSeriesSearchResponse(title, href, TvType.TvSeries) {
|
||||||
this.posterUrl = posterUrl
|
this.posterUrl = posterUrl
|
||||||
|
@ -95,7 +119,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 = fixUrl(it.attr("href"))
|
val href = changesUrl(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()
|
||||||
|
|
Loading…
Reference in a new issue