mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
added tracker into Otakudesu & Kuramanime
This commit is contained in:
parent
58ff720cae
commit
a29e3354f2
4 changed files with 98 additions and 22 deletions
|
@ -1,5 +1,5 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package com.hexated
|
package com.hexated
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId
|
||||||
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
|
||||||
import com.lagradost.cloudstream3.mvvm.safeApiCall
|
import com.lagradost.cloudstream3.mvvm.safeApiCall
|
||||||
import com.lagradost.cloudstream3.mvvm.suspendSafeApiCall
|
import com.lagradost.cloudstream3.mvvm.suspendSafeApiCall
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
|
@ -24,6 +27,14 @@ class KuramanimeProvider : MainAPI() {
|
||||||
)
|
)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private const val jikanAPI = "https://api.jikan.moe/v4"
|
||||||
|
|
||||||
|
fun getType(t: String): TvType {
|
||||||
|
return if (t.contains("OVA", true) || t.contains("Special")) TvType.OVA
|
||||||
|
else if (t.contains("Movie", true)) TvType.AnimeMovie
|
||||||
|
else TvType.Anime
|
||||||
|
}
|
||||||
|
|
||||||
fun getStatus(t: String): ShowStatus {
|
fun getStatus(t: String): ShowStatus {
|
||||||
return when (t) {
|
return when (t) {
|
||||||
"Selesai Tayang" -> ShowStatus.Completed
|
"Selesai Tayang" -> ShowStatus.Completed
|
||||||
|
@ -90,9 +101,8 @@ class KuramanimeProvider : MainAPI() {
|
||||||
|
|
||||||
val title = document.selectFirst(".anime__details__title > h3")!!.text().trim()
|
val title = document.selectFirst(".anime__details__title > h3")!!.text().trim()
|
||||||
val poster = document.selectFirst(".anime__details__pic")?.attr("data-setbg")
|
val poster = document.selectFirst(".anime__details__pic")?.attr("data-setbg")
|
||||||
val tags =
|
val tags = document.select("div.anime__details__widget > div > div:nth-child(2) > ul > li:nth-child(1)")
|
||||||
document.select("div.anime__details__widget > div > div:nth-child(2) > ul > li:nth-child(1)")
|
.text().trim().replace("Genre: ", "").split(", ")
|
||||||
.text().trim().replace("Genre: ", "").split(", ")
|
|
||||||
|
|
||||||
val year = Regex("[^0-9]").replace(
|
val year = Regex("[^0-9]").replace(
|
||||||
document.select("div.anime__details__widget > div > div:nth-child(1) > ul > li:nth-child(5)")
|
document.select("div.anime__details__widget > div > div:nth-child(1) > ul > li:nth-child(5)")
|
||||||
|
@ -102,8 +112,17 @@ class KuramanimeProvider : MainAPI() {
|
||||||
document.select("div.anime__details__widget > div > div:nth-child(1) > ul > li:nth-child(3)")
|
document.select("div.anime__details__widget > div > div:nth-child(1) > ul > li:nth-child(3)")
|
||||||
.text().trim().replace("Status: ", "")
|
.text().trim().replace("Status: ", "")
|
||||||
)
|
)
|
||||||
|
val type = document.selectFirst("div.col-lg-6.col-md-6 ul li:contains(Tipe:) a")?.text()?.lowercase() ?: "tv"
|
||||||
val description = document.select(".anime__details__text > p").text().trim()
|
val description = document.select(".anime__details__text > p").text().trim()
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
val episodes =
|
val episodes =
|
||||||
Jsoup.parse(document.select("#episodeLists").attr("data-content")).select("a").map {
|
Jsoup.parse(document.select("#episodeLists").attr("data-content")).select("a").map {
|
||||||
val name = it.text().trim()
|
val name = it.text().trim()
|
||||||
|
@ -122,13 +141,15 @@ class KuramanimeProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return newAnimeLoadResponse(title, url, TvType.Anime) {
|
return newAnimeLoadResponse(title, url, getType(type)) {
|
||||||
engName = title
|
engName = title
|
||||||
posterUrl = poster
|
posterUrl = poster
|
||||||
this.year = year
|
this.year = year
|
||||||
addEpisodes(DubStatus.Subbed, episodes)
|
addEpisodes(DubStatus.Subbed, episodes)
|
||||||
showStatus = status
|
showStatus = status
|
||||||
plot = description
|
plot = description
|
||||||
|
addMalId(malId?.toIntOrNull())
|
||||||
|
addAniListId(anilistId?.toIntOrNull())
|
||||||
this.tags = tags
|
this.tags = tags
|
||||||
this.recommendations = recommendations
|
this.recommendations = recommendations
|
||||||
}
|
}
|
||||||
|
@ -191,4 +212,24 @@ class KuramanimeProvider : MainAPI() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 4
|
version = 5
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
|
|
|
@ -2,6 +2,8 @@ package com.hexated
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId
|
||||||
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
|
||||||
import com.lagradost.cloudstream3.network.CloudflareKiller
|
import com.lagradost.cloudstream3.network.CloudflareKiller
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
|
@ -23,11 +25,12 @@ class OtakudesuProvider : MainAPI() {
|
||||||
)
|
)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
// private val interceptor = CloudflareKiller()
|
// private val interceptor = CloudflareKiller()
|
||||||
|
private const val jikanAPI = "https://api.jikan.moe/v4"
|
||||||
|
|
||||||
fun getType(t: String): TvType {
|
fun getType(t: String): TvType {
|
||||||
return if (t.contains("OVA") || t.contains("Special")) TvType.OVA
|
return if (t.contains("OVA", true) || t.contains("Special")) TvType.OVA
|
||||||
else if (t.contains("Movie")) TvType.AnimeMovie
|
else if (t.contains("Movie", true)) TvType.AnimeMovie
|
||||||
else TvType.Anime
|
else TvType.Anime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +52,8 @@ class OtakudesuProvider : MainAPI() {
|
||||||
page: Int,
|
page: Int,
|
||||||
request: MainPageRequest
|
request: MainPageRequest
|
||||||
): HomePageResponse {
|
): HomePageResponse {
|
||||||
val document = app.get(request.data + page
|
val document = app.get(
|
||||||
|
request.data + page
|
||||||
// , interceptor = interceptor
|
// , interceptor = interceptor
|
||||||
).document
|
).document
|
||||||
val home = document.select("div.venz > ul > li").mapNotNull {
|
val home = document.select("div.venz > ul > li").mapNotNull {
|
||||||
|
@ -74,7 +78,8 @@ class OtakudesuProvider : MainAPI() {
|
||||||
|
|
||||||
override suspend fun search(query: String): List<SearchResponse> {
|
override suspend fun search(query: String): List<SearchResponse> {
|
||||||
val link = "$mainUrl/?s=$query&post_type=anime"
|
val link = "$mainUrl/?s=$query&post_type=anime"
|
||||||
val document = app.get(link
|
val document = app.get(
|
||||||
|
link
|
||||||
// , interceptor = interceptor
|
// , interceptor = interceptor
|
||||||
).document
|
).document
|
||||||
|
|
||||||
|
@ -91,7 +96,8 @@ class OtakudesuProvider : MainAPI() {
|
||||||
|
|
||||||
|
|
||||||
override suspend fun load(url: String): LoadResponse {
|
override suspend fun load(url: String): LoadResponse {
|
||||||
val document = app.get(url
|
val document = app.get(
|
||||||
|
url
|
||||||
// , interceptor = interceptor
|
// , interceptor = interceptor
|
||||||
).document
|
).document
|
||||||
|
|
||||||
|
@ -99,10 +105,9 @@ class OtakudesuProvider : MainAPI() {
|
||||||
?.replace(":", "")?.trim().toString()
|
?.replace(":", "")?.trim().toString()
|
||||||
val poster = document.selectFirst("div.fotoanime > img")?.attr("src")
|
val poster = document.selectFirst("div.fotoanime > img")?.attr("src")
|
||||||
val tags = document.select("div.infozingle > p:nth-child(11) > span > a").map { it.text() }
|
val tags = document.select("div.infozingle > p:nth-child(11) > span > a").map { it.text() }
|
||||||
val type = getType(
|
val type = document.selectFirst("div.infozingle > p:nth-child(5) > span")?.ownText()
|
||||||
document.selectFirst("div.infozingle > p:nth-child(5) > span")?.ownText()
|
?.replace(":", "")?.trim() ?: "tv"
|
||||||
?.replace(":", "")?.trim().toString()
|
|
||||||
)
|
|
||||||
val year = Regex("\\d, ([0-9]*)").find(
|
val year = Regex("\\d, ([0-9]*)").find(
|
||||||
document.select("div.infozingle > p:nth-child(9) > span").text()
|
document.select("div.infozingle > p:nth-child(9) > span").text()
|
||||||
)?.groupValues?.get(1)?.toIntOrNull()
|
)?.groupValues?.get(1)?.toIntOrNull()
|
||||||
|
@ -112,13 +117,20 @@ class OtakudesuProvider : MainAPI() {
|
||||||
.trim()
|
.trim()
|
||||||
)
|
)
|
||||||
val description = document.select("div.sinopc > p").text()
|
val description = document.select("div.sinopc > p").text()
|
||||||
|
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
|
||||||
|
|
||||||
val episodes = document.select("div.episodelist")[1].select("ul > li").mapNotNull {
|
val episodes = document.select("div.episodelist")[1].select("ul > li").mapNotNull {
|
||||||
val name = Regex("(Episode\\s?[0-9]+)").find(
|
val name = it.selectFirst("a")?.text() ?: return@mapNotNull null
|
||||||
it.selectFirst("a")?.text().toString()
|
val episode = Regex("Episode\\s?([0-9]+)").find(name)?.groupValues?.getOrNull(0)
|
||||||
)?.groupValues?.getOrNull(0) ?: it.selectFirst("a")?.text()
|
?: it.selectFirst("a")?.text()
|
||||||
val link = fixUrl(it.selectFirst("a")!!.attr("href"))
|
val link = fixUrl(it.selectFirst("a")!!.attr("href"))
|
||||||
Episode(link, name)
|
Episode(link, name, episode = episode?.toIntOrNull())
|
||||||
}.reversed()
|
}.reversed()
|
||||||
|
|
||||||
val recommendations =
|
val recommendations =
|
||||||
|
@ -132,7 +144,7 @@ class OtakudesuProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return newAnimeLoadResponse(title, url, type) {
|
return newAnimeLoadResponse(title, url, getType(type)) {
|
||||||
engName = title
|
engName = title
|
||||||
posterUrl = poster
|
posterUrl = poster
|
||||||
this.year = year
|
this.year = year
|
||||||
|
@ -140,6 +152,8 @@ class OtakudesuProvider : MainAPI() {
|
||||||
showStatus = status
|
showStatus = status
|
||||||
plot = description
|
plot = description
|
||||||
this.tags = tags
|
this.tags = tags
|
||||||
|
addMalId(malId?.toIntOrNull())
|
||||||
|
addAniListId(anilistId?.toIntOrNull())
|
||||||
this.recommendations = recommendations
|
this.recommendations = recommendations
|
||||||
// posterHeaders = interceptor.getCookieHeaders(url).toMap()
|
// posterHeaders = interceptor.getCookieHeaders(url).toMap()
|
||||||
}
|
}
|
||||||
|
@ -163,7 +177,8 @@ class OtakudesuProvider : MainAPI() {
|
||||||
callback: (ExtractorLink) -> Unit
|
callback: (ExtractorLink) -> Unit
|
||||||
): Boolean {
|
): Boolean {
|
||||||
|
|
||||||
val document = app.get(data
|
val document = app.get(
|
||||||
|
data
|
||||||
// , interceptor = interceptor
|
// , interceptor = interceptor
|
||||||
).document
|
).document
|
||||||
val scriptData = document.select("script").last()?.data()
|
val scriptData = document.select("script").last()?.data()
|
||||||
|
@ -215,4 +230,24 @@ class OtakudesuProvider : MainAPI() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue