AnimeIndoProvider: fixed homepage

This commit is contained in:
sora 2023-07-20 20:26:43 +07:00
parent 864b266f9e
commit ee302555a5
2 changed files with 20 additions and 17 deletions

View file

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

View file

@ -13,7 +13,6 @@ class AnimeIndoProvider : MainAPI() {
override var name = "AnimeIndo" override var name = "AnimeIndo"
override val hasMainPage = true override val hasMainPage = true
override var lang = "id" override var lang = "id"
override val hasDownloadSupport = true
override val supportedTypes = setOf( override val supportedTypes = setOf(
TvType.Anime, TvType.Anime,
@ -39,18 +38,19 @@ class AnimeIndoProvider : MainAPI() {
} }
override val mainPage = mainPageOf( override val mainPage = mainPageOf(
"$mainUrl/anime-terbaru/page/" to "Anime Terbaru", "episode-terbaru" to "Episode Terbaru",
"$mainUrl/ongoing/page/" to "Anime Ongoing", "ongoing" to "Anime Ongoing",
"$mainUrl/populer/page/" to "Anime Populer", "populer" to "Anime Populer",
"$mainUrl/donghua-terbaru/page/" to "Donghua Terbaru", "donghua-terbaru" to "Donghua Terbaru",
) )
override suspend fun getMainPage( override suspend fun getMainPage(
page: Int, page: Int,
request: MainPageRequest request: MainPageRequest
): HomePageResponse { ): HomePageResponse {
val document = app.get(request.data + page).document val url = "$mainUrl/pages/${request.data}/page/$page"
val home = document.select("div.post-show > article, div.relat > article").mapNotNull { val document = app.get(url).document
val home = document.select("main#main div.animposx").mapNotNull {
it.toSearchResult() it.toSearchResult()
} }
return newHomePageResponse(request.name, home) return newHomePageResponse(request.name, home)
@ -60,7 +60,7 @@ class AnimeIndoProvider : MainAPI() {
return if (uri.contains("/anime/")) { return if (uri.contains("/anime/")) {
uri uri
} else { } else {
var title = uri.substringAfter("$mainUrl/") var title = uri.substringAfter("nonton/")
title = when { title = when {
(title.contains("-episode")) && !(title.contains("-movie")) -> Regex("(.+)-episode").find( (title.contains("-episode")) && !(title.contains("-movie")) -> Regex("(.+)-episode").find(
title title
@ -74,15 +74,13 @@ class AnimeIndoProvider : MainAPI() {
} }
} }
private fun Element.toSearchResult(): AnimeSearchResponse? { private fun Element.toSearchResult(): AnimeSearchResponse {
val title = this.selectFirst("div.title")?.text()?.trim() ?: return null val title = this.selectFirst("div.titlex, h2.entry-title, h4")?.text()?.trim() ?: ""
val href = getProperAnimeLink(this.selectFirst("a")!!.attr("href")) val href = getProperAnimeLink(this.selectFirst("a")!!.attr("href"))
val posterUrl = this.select("img[itemprop=image]").attr("src").toString() val posterUrl = fixUrlNull(this.selectFirst("img")?.attr("src"))
val type = getType(this.select("div.type").text().trim()) val epNum = this.selectFirst("span.episode")?.ownText()?.replace(Regex("\\D"), "")?.trim()
val epNum =
this.selectFirst("span.episode")?.ownText()?.replace(Regex("\\D"), "")?.trim()
?.toIntOrNull() ?.toIntOrNull()
return newAnimeSearchResponse(title, href, type) { return newAnimeSearchResponse(title, href, TvType.Anime) {
this.posterUrl = posterUrl this.posterUrl = posterUrl
addSub(epNum) addSub(epNum)
} }
@ -131,6 +129,10 @@ class AnimeIndoProvider : MainAPI() {
Episode(link, header.text(), episode = episode) Episode(link, header.text(), episode = episode)
}.reversed() }.reversed()
val recommendations = document.select("div.relat div.animposx").mapNotNull {
it.toSearchResult()
}
return newAnimeLoadResponse(title, url, getType(type)) { return newAnimeLoadResponse(title, url, getType(type)) {
engName = title engName = title
posterUrl = poster posterUrl = poster
@ -139,6 +141,7 @@ class AnimeIndoProvider : MainAPI() {
showStatus = status showStatus = status
plot = description plot = description
this.tags = tags this.tags = tags
this.recommendations = recommendations
addTrailer(trailer) addTrailer(trailer)
} }
} }