added homepage for tenshi.moe

This commit is contained in:
Arjix 2021-09-05 18:19:25 +03:00 committed by GitHub
parent 3cc4e3b262
commit 4db4581cdf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,7 +28,10 @@ class TenshiProvider : MainAPI() {
get() = "Tenshi.moe" get() = "Tenshi.moe"
override val hasQuickSearch: Boolean override val hasQuickSearch: Boolean
get() = false get() = false
override val hasMainPage: Boolean
get() = true
override val supportedTypes: Set<TvType> override val supportedTypes: Set<TvType>
get() = setOf(TvType.Anime, TvType.AnimeMovie, TvType.ONA) get() = setOf(TvType.Anime, TvType.AnimeMovie, TvType.ONA)
@ -48,6 +51,56 @@ class TenshiProvider : MainAPI() {
false false
} }
} }
override fun getMainPage(): HomePageResponse {
val items = ArrayList<HomePageList>()
val soup = Jsoup.parse(khttp.get(mainUrl).text)
for (section in soup.select("#content > section")) {
try {
if (section.attr("id") == "toplist-tabs") {
for (top in section.select(".tab-content > [role=\"tabpanel\"]")) {
val title = "Top of the " + top.attr("id").split("-")[1].capitalize(Locale.UK)
val anime = top.select("li > a").map {
AnimeSearchResponse(
it.selectFirst(".thumb-title").text(),
fixUrl(it.attr("href")),
this.name,
TvType.Anime,
it.selectFirst("img").attr("src"),
null,
null,
EnumSet.of(DubStatus.Subbed),
null,
null
)
}
items.add(HomePageList(title, anime))
}
} else {
val title = section.selectFirst("h2").text()
val anime = section.select("li > a").map {
AnimeSearchResponse(
it.selectFirst(".thumb-title").text(),
fixUrl(it.attr("href")),
this.name,
TvType.Anime,
it.selectFirst("img").attr("src"),
null,
null,
EnumSet.of(DubStatus.Subbed),
null,
null
)
}
items.add(HomePageList(title, anime))
}
} catch (e: Exception) {
e.printStackTrace()
}
}
if(items.size <= 0) throw ErrorLoadingException()
return HomePageResponse(items)
}
private fun getIsMovie(type: String, id: Boolean = false): Boolean { private fun getIsMovie(type: String, id: Boolean = false): Boolean {
if (!id) return type == "Movie" if (!id) return type == "Movie"