Add anime providers

This commit is contained in:
Blatzar 2022-08-11 16:55:58 +02:00
parent b74b8614db
commit b3f33b368a
139 changed files with 9873 additions and 9 deletions

View file

@ -0,0 +1,22 @@
// use an integer for version numbers
version = 1
cloudstream {
// All of these properties are optional, you can safely remove them
// description = "Lorem Ipsum"
// authors = listOf("Cloudburst")
/**
* Status int as the following:
* 0: Down
* 1: Ok
* 2: Slow
* 3: Beta only
* */
status = 1 // will be 3 if unspecified
// Set to true to get an 18+ symbol next to the plugin
adult = false // will be false if unspecified
}

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.lagradost"/>

View file

@ -0,0 +1,174 @@
package com.lagradost
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.getQualityFromName
import org.jsoup.Jsoup
import java.util.*
class KawaiifuProvider : MainAPI() {
override var mainUrl = "https://kawaiifu.com"
override var name = "Kawaiifu"
override val hasQuickSearch = false
override val hasMainPage = true
override val supportedTypes = setOf(TvType.Anime, TvType.AnimeMovie)
override suspend fun getMainPage(page: Int, request : MainPageRequest): HomePageResponse {
val items = ArrayList<HomePageList>()
val resp = app.get(mainUrl).text
val soup = Jsoup.parse(resp)
items.add(HomePageList("Latest Updates", soup.select(".today-update .item").mapNotNull {
val title = it.selectFirst("img")?.attr("alt")
AnimeSearchResponse(
title ?: return@mapNotNull null,
it.selectFirst("a")?.attr("href") ?: return@mapNotNull null,
this.name,
TvType.Anime,
it.selectFirst("img")?.attr("src"),
it.selectFirst("h4 > a")?.attr("href")?.split("-")?.last()?.toIntOrNull(),
if (title.contains("(DUB)")) EnumSet.of(DubStatus.Dubbed) else EnumSet.of(
DubStatus.Subbed
),
)
}))
for (section in soup.select(".section")) {
try {
val title = section.selectFirst(".title")!!.text()
val anime = section.select(".list-film > .item").mapNotNull { ani ->
val animTitle = ani.selectFirst("img")?.attr("alt")
AnimeSearchResponse(
animTitle ?: return@mapNotNull null,
ani.selectFirst("a")?.attr("href") ?: return@mapNotNull null,
this.name,
TvType.Anime,
ani.selectFirst("img")?.attr("src"),
ani.selectFirst(".vl-chil-date")?.text()?.toIntOrNull(),
if (animTitle.contains("(DUB)")) EnumSet.of(DubStatus.Dubbed) else EnumSet.of(
DubStatus.Subbed
),
)
}
items.add(HomePageList(title, anime))
} catch (e: Exception) {
e.printStackTrace()
}
}
if (items.size <= 0) throw ErrorLoadingException()
return HomePageResponse(items)
}
override suspend fun search(query: String): ArrayList<SearchResponse> {
val link = "$mainUrl/search-movie?keyword=${query}"
val html = app.get(link).text
val soup = Jsoup.parse(html)
return ArrayList(soup.select(".item").mapNotNull {
val year = it.selectFirst("h4 > a")?.attr("href")?.split("-")?.last()?.toIntOrNull()
val title = it.selectFirst("img")?.attr("alt") ?: return@mapNotNull null
val poster = it.selectFirst("img")?.attr("src")
val uri = it.selectFirst("a")?.attr("href") ?: return@mapNotNull null
AnimeSearchResponse(
title,
uri,
this.name,
TvType.Anime,
poster,
year,
if (title.contains("(DUB)")) EnumSet.of(DubStatus.Dubbed) else EnumSet.of(DubStatus.Subbed),
)
})
}
override suspend fun load(url: String): LoadResponse {
val html = app.get(url).text
val soup = Jsoup.parse(html)
val title = soup.selectFirst(".title")!!.text()
val tags = soup.select(".table a[href*=\"/tag/\"]").map { tag -> tag.text() }
val description = soup.select(".sub-desc p")
.filter { it -> it.select("strong").isEmpty() && it.select("iframe").isEmpty() }
.joinToString("\n") { it.text() }
val year = url.split("/").filter { it.contains("-") }[0].split("-")[1].toIntOrNull()
val episodesLink = soup.selectFirst("a[href*=\".html-episode\"]")?.attr("href")
?: throw ErrorLoadingException("Error getting episode list")
val episodes = Jsoup.parse(
app.get(episodesLink).text
).selectFirst(".list-ep")?.select("li")?.map {
Episode(
it.selectFirst("a")!!.attr("href"),
if (it.text().trim().toIntOrNull() != null) "Episode ${
it.text().trim()
}" else it.text().trim()
)
}
val poster = soup.selectFirst("a.thumb > img")?.attr("src")
return newAnimeLoadResponse(title, url, TvType.Anime) {
this.year = year
posterUrl = poster
addEpisodes(DubStatus.Subbed, episodes)
plot = description
this.tags = tags
}
}
override suspend fun loadLinks(
data: String,
isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
val htmlSource = app.get(data).text
val soupa = Jsoup.parse(htmlSource)
val episodeNum =
if (data.contains("ep=")) data.split("ep=")[1].split("&")[0].toIntOrNull() else null
val servers = soupa.select(".list-server").map {
val serverName = it.selectFirst(".server-name")!!.text()
val episodes = it.select(".list-ep > li > a")
.map { episode -> Pair(episode.attr("href"), episode.text()) }
val episode = if (episodeNum == null) episodes[0] else episodes.mapNotNull { ep ->
if ((if (ep.first.contains("ep=")) ep.first.split("ep=")[1].split("&")[0].toIntOrNull() else null) == episodeNum) {
ep
} else null
}[0]
Pair(serverName, episode)
}.map {
if (it.second.first == data) {
val sources = soupa.select("video > source")
.map { source -> Pair(source.attr("src"), source.attr("data-quality")) }
Triple(it.first, sources, it.second.second)
} else {
val html = app.get(it.second.first).text
val soup = Jsoup.parse(html)
val sources = soup.select("video > source")
.map { source -> Pair(source.attr("src"), source.attr("data-quality")) }
Triple(it.first, sources, it.second.second)
}
}
servers.forEach {
it.second.forEach { source ->
callback(
ExtractorLink(
"Kawaiifu",
it.first,
source.first,
"",
getQualityFromName(source.second),
source.first.contains(".m3u")
)
)
}
}
return true
}
}

View file

@ -0,0 +1,14 @@
package com.lagradost
import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
import com.lagradost.cloudstream3.plugins.Plugin
import android.content.Context
@CloudstreamPlugin
class KawaiifuProviderPlugin: Plugin() {
override fun load(context: Context) {
// All providers should be added in this manner. Please don't edit the providers list directly.
registerMainAPI(KawaiifuProvider())
}
}