2022-09-09 16:09:54 +00:00
|
|
|
package com.hexated
|
|
|
|
|
2022-11-24 13:01:13 +00:00
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty
|
2022-09-09 16:09:54 +00:00
|
|
|
import com.lagradost.cloudstream3.*
|
2022-11-24 13:01:13 +00:00
|
|
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId
|
|
|
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
|
2022-09-09 16:09:54 +00:00
|
|
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
|
|
|
|
import com.lagradost.cloudstream3.mvvm.safeApiCall
|
|
|
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
|
|
|
import com.lagradost.cloudstream3.utils.getQualityFromName
|
|
|
|
import com.lagradost.cloudstream3.utils.loadExtractor
|
|
|
|
import org.jsoup.Jsoup
|
|
|
|
import org.jsoup.nodes.Element
|
|
|
|
|
|
|
|
class KuronimeProvider : MainAPI() {
|
|
|
|
override var mainUrl = "https://45.12.2.2"
|
|
|
|
override var name = "Kuronime"
|
|
|
|
override val hasQuickSearch = false
|
|
|
|
override val hasMainPage = true
|
|
|
|
override var lang = "id"
|
|
|
|
override val hasDownloadSupport = true
|
|
|
|
|
|
|
|
override val supportedTypes = setOf(
|
|
|
|
TvType.Anime,
|
|
|
|
TvType.AnimeMovie,
|
|
|
|
TvType.OVA
|
|
|
|
)
|
|
|
|
|
|
|
|
companion object {
|
2022-11-24 13:01:13 +00:00
|
|
|
private const val jikanAPI = "https://api.jikan.moe/v4"
|
|
|
|
|
2022-09-09 16:09:54 +00:00
|
|
|
fun getType(t: String): TvType {
|
|
|
|
return if (t.contains("OVA") || t.contains("Special")) TvType.OVA
|
|
|
|
else if (t.contains("Movie")) TvType.AnimeMovie
|
|
|
|
else TvType.Anime
|
|
|
|
}
|
|
|
|
|
|
|
|
fun getStatus(t: String): ShowStatus {
|
|
|
|
return when (t) {
|
|
|
|
"Completed" -> ShowStatus.Completed
|
|
|
|
"Ongoing" -> ShowStatus.Ongoing
|
|
|
|
else -> ShowStatus.Completed
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override val mainPage = mainPageOf(
|
|
|
|
"$mainUrl/page/" to "New Episodes",
|
|
|
|
"$mainUrl/popular-anime/page/" to "Popular Anime",
|
|
|
|
"$mainUrl/movies/page/" to "Movies",
|
|
|
|
"$mainUrl/genres/donghua/page/" to "Donghua",
|
|
|
|
"$mainUrl/live-action/page/" to "Live Action",
|
|
|
|
)
|
|
|
|
|
|
|
|
override suspend fun getMainPage(
|
|
|
|
page: Int,
|
|
|
|
request: MainPageRequest
|
|
|
|
): HomePageResponse {
|
|
|
|
val document = app.get(request.data + page).document
|
|
|
|
val home = document.select("article").map {
|
|
|
|
it.toSearchResult()
|
|
|
|
}
|
|
|
|
return newHomePageResponse(request.name, home)
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun getProperAnimeLink(uri: String): String {
|
|
|
|
return if (uri.contains("/anime/")) {
|
|
|
|
uri
|
|
|
|
} else {
|
|
|
|
var title = uri.substringAfter("$mainUrl/")
|
|
|
|
title = when {
|
|
|
|
(title.contains("-episode")) && !(title.contains("-movie")) -> Regex("nonton-(.+)-episode").find(
|
|
|
|
title
|
|
|
|
)?.groupValues?.get(1).toString()
|
|
|
|
(title.contains("-movie")) -> Regex("nonton-(.+)-movie").find(title)?.groupValues?.get(
|
|
|
|
1
|
|
|
|
).toString()
|
|
|
|
else -> title
|
|
|
|
}
|
|
|
|
|
|
|
|
"$mainUrl/anime/$title"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun Element.toSearchResult(): AnimeSearchResponse {
|
|
|
|
val href = getProperAnimeLink(fixUrlNull(this.selectFirst("a")?.attr("href")).toString())
|
|
|
|
val title = this.select(".bsuxtt, .tt > h4").text().trim()
|
|
|
|
val posterUrl = fixUrlNull(
|
|
|
|
this.selectFirst("div.view,div.bt")?.nextElementSibling()?.select("img")
|
|
|
|
?.attr("data-src")
|
|
|
|
)
|
|
|
|
val epNum = this.select(".ep").text().replace(Regex("[^0-9]"), "").trim().toIntOrNull()
|
|
|
|
val tvType = getType(this.selectFirst(".bt > span")?.text().toString())
|
|
|
|
return newAnimeSearchResponse(title, href, tvType) {
|
|
|
|
this.posterUrl = posterUrl
|
|
|
|
addSub(epNum)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
override suspend fun search(query: String): List<SearchResponse> {
|
|
|
|
val link = "$mainUrl/?s=$query"
|
|
|
|
val document = app.get(link).document
|
|
|
|
|
|
|
|
return document.select("article.bs").map {
|
|
|
|
it.toSearchResult()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override suspend fun load(url: String): LoadResponse {
|
|
|
|
val document = app.get(url).document
|
|
|
|
|
|
|
|
val title = document.selectFirst(".entry-title")?.text().toString().trim()
|
|
|
|
val poster = document.selectFirst("div.l[itemprop=image] > img")?.attr("data-src")
|
|
|
|
val tags = document.select(".infodetail > ul > li:nth-child(2) > a").map { it.text() }
|
2022-11-24 13:01:13 +00:00
|
|
|
val type = document.selectFirst(".infodetail > ul > li:nth-child(7)")?.ownText()?.removePrefix(":")
|
|
|
|
?.lowercase()?.trim() ?: "tv"
|
|
|
|
|
2022-09-09 16:09:54 +00:00
|
|
|
val trailer = document.selectFirst("div.tply iframe")?.attr("data-src")
|
|
|
|
val year = Regex("\\d, ([0-9]*)").find(
|
|
|
|
document.select(".infodetail > ul > li:nth-child(5)").text()
|
|
|
|
)?.groupValues?.get(1)?.toIntOrNull()
|
2022-11-24 13:01:13 +00:00
|
|
|
val malId = app.get("$jikanAPI/anime?q=$title&start_date=${year}&type=$type&limit=1")
|
|
|
|
.parsedSafe<JikanResponse>()?.data?.firstOrNull()?.mal_id
|
|
|
|
val anilistId = app.post(
|
|
|
|
"https://graphql.anilist.co/", data = mapOf(
|
|
|
|
"query" to "{Media(idMal:$malId,type:ANIME){id}}",
|
|
|
|
)
|
|
|
|
).parsedSafe<DataAni>()?.data?.media?.id
|
2022-09-09 16:09:54 +00:00
|
|
|
val status = getStatus(
|
|
|
|
document.selectFirst(".infodetail > ul > li:nth-child(3)")!!.ownText()
|
|
|
|
.replace(Regex("\\W"), "")
|
|
|
|
)
|
|
|
|
val description = document.select("span.const > p").text()
|
|
|
|
|
|
|
|
val episodes = document.select("div.bixbox.bxcl > ul > li").map {
|
|
|
|
val name = it.selectFirst("a")?.text()?.trim()
|
|
|
|
val episode =
|
|
|
|
it.selectFirst("a")?.text()?.trim()?.replace("Episode", "")?.trim()?.toIntOrNull()
|
|
|
|
val link = it.selectFirst("a")!!.attr("href")
|
|
|
|
Episode(link, name = name, episode = episode)
|
|
|
|
}.reversed()
|
|
|
|
|
2022-11-24 13:01:13 +00:00
|
|
|
return newAnimeLoadResponse(title, url, getType(type)) {
|
2022-09-09 16:09:54 +00:00
|
|
|
engName = title
|
|
|
|
posterUrl = poster
|
|
|
|
this.year = year
|
|
|
|
addEpisodes(DubStatus.Subbed, episodes)
|
|
|
|
showStatus = status
|
|
|
|
plot = description
|
2022-11-24 13:01:13 +00:00
|
|
|
addMalId(malId?.toIntOrNull())
|
|
|
|
addAniListId(anilistId?.toIntOrNull())
|
2022-09-09 16:09:54 +00:00
|
|
|
addTrailer(trailer)
|
|
|
|
this.tags = tags
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private suspend fun invokeKuroSource(
|
|
|
|
url: String,
|
|
|
|
sourceCallback: (ExtractorLink) -> Unit
|
|
|
|
) {
|
|
|
|
val doc = app.get(url, referer = "${mainUrl}/").document
|
|
|
|
|
|
|
|
doc.select("script").map { script ->
|
|
|
|
if (script.data().contains("function jalankan_jwp() {")) {
|
|
|
|
val data = script.data()
|
|
|
|
val doma = data.substringAfter("var doma = \"").substringBefore("\";")
|
|
|
|
val token = data.substringAfter("var token = \"").substringBefore("\";")
|
|
|
|
val pat = data.substringAfter("var pat = \"").substringBefore("\";")
|
|
|
|
val link = "$doma$token$pat/index.m3u8"
|
|
|
|
val quality =
|
|
|
|
Regex("\\d{3,4}p").find(doc.select("title").text())?.groupValues?.get(0)
|
|
|
|
|
|
|
|
sourceCallback.invoke(
|
|
|
|
ExtractorLink(
|
|
|
|
this.name,
|
|
|
|
this.name,
|
|
|
|
link,
|
|
|
|
referer = "https://animeku.org/",
|
|
|
|
quality = getQualityFromName(quality),
|
|
|
|
headers = mapOf("Origin" to "https://animeku.org"),
|
|
|
|
isM3u8 = true
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override suspend fun loadLinks(
|
|
|
|
data: String,
|
|
|
|
isCasting: Boolean,
|
|
|
|
subtitleCallback: (SubtitleFile) -> Unit,
|
|
|
|
callback: (ExtractorLink) -> Unit
|
|
|
|
): Boolean {
|
|
|
|
val document = app.get(data).document
|
|
|
|
val sources = document.select(".mobius > .mirror > option").mapNotNull {
|
|
|
|
fixUrl(Jsoup.parse(base64Decode(it.attr("value"))).select("iframe").attr("data-src"))
|
|
|
|
}
|
|
|
|
|
|
|
|
sources.apmap {
|
|
|
|
safeApiCall {
|
|
|
|
when {
|
|
|
|
it.startsWith("https://animeku.org") -> invokeKuroSource(it, callback)
|
|
|
|
else -> loadExtractor(it, mainUrl, subtitleCallback, callback)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2022-11-24 13:01:13 +00:00
|
|
|
data class Data(
|
|
|
|
@JsonProperty("mal_id") val mal_id: String? = null,
|
|
|
|
)
|
|
|
|
|
|
|
|
data class JikanResponse(
|
|
|
|
@JsonProperty("data") val data: ArrayList<Data>? = arrayListOf(),
|
|
|
|
)
|
|
|
|
|
|
|
|
private data class IdAni(
|
|
|
|
@JsonProperty("id") val id: String? = null,
|
|
|
|
)
|
|
|
|
|
|
|
|
private data class MediaAni(
|
|
|
|
@JsonProperty("Media") val media: IdAni? = null,
|
|
|
|
)
|
|
|
|
|
|
|
|
private data class DataAni(
|
|
|
|
@JsonProperty("data") val data: MediaAni? = null,
|
|
|
|
)
|
|
|
|
|
2022-09-09 16:09:54 +00:00
|
|
|
}
|