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
1 changed files with 54 additions and 1 deletions

View File

@ -28,7 +28,10 @@ class TenshiProvider : MainAPI() {
get() = "Tenshi.moe"
override val hasQuickSearch: Boolean
get() = false
override val hasMainPage: Boolean
get() = true
override val supportedTypes: Set<TvType>
get() = setOf(TvType.Anime, TvType.AnimeMovie, TvType.ONA)
@ -48,6 +51,56 @@ class TenshiProvider : MainAPI() {
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 {
if (!id) return type == "Movie"