mirror of
https://github.com/recloudstream/cloudstream-extensions.git
synced 2024-08-15 03:03:54 +00:00
possibly added mal sync
This commit is contained in:
parent
1f255e555f
commit
0271fb3d1b
1 changed files with 52 additions and 40 deletions
|
|
@ -2,8 +2,11 @@ package com.lagradost
|
||||||
|
|
||||||
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.LoadResponse.Companion.addActors
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
|
||||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
|
||||||
|
import com.lagradost.cloudstream3.R.string.year
|
||||||
import com.lagradost.cloudstream3.mvvm.safeApiCall
|
import com.lagradost.cloudstream3.mvvm.safeApiCall
|
||||||
import com.lagradost.cloudstream3.ui.settings.SettingsProviders
|
import com.lagradost.cloudstream3.ui.settings.SettingsProviders
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
|
|
@ -211,6 +214,7 @@ class AllAnimeProvider : MainAPI() {
|
||||||
|
|
||||||
|
|
||||||
override suspend fun load(url: String): LoadResponse? {
|
override suspend fun load(url: String): LoadResponse? {
|
||||||
|
val document = app.get(url).document
|
||||||
val rhino = Context.enter()
|
val rhino = Context.enter()
|
||||||
rhino.initSafeStandardObjects()
|
rhino.initSafeStandardObjects()
|
||||||
rhino.optimizationLevel = -1
|
rhino.optimizationLevel = -1
|
||||||
|
|
@ -218,11 +222,11 @@ class AllAnimeProvider : MainAPI() {
|
||||||
|
|
||||||
val html = app.get(url).text
|
val html = app.get(url).text
|
||||||
val soup = Jsoup.parse(html)
|
val soup = Jsoup.parse(html)
|
||||||
val (malId, anilistId, image, cover) = getTracker(title, typeCheck, year)
|
|
||||||
|
|
||||||
val script = soup.select("script").firstOrNull {
|
val script = soup.select("script").firstOrNull {
|
||||||
it.html().contains("window.__NUXT__")
|
it.html().contains("window.__NUXT__")
|
||||||
} ?: return null
|
} ?: return null
|
||||||
|
|
||||||
val js = """
|
val js = """
|
||||||
const window = {}
|
const window = {}
|
||||||
${script.html()}
|
${script.html()}
|
||||||
|
|
@ -234,10 +238,20 @@ class AllAnimeProvider : MainAPI() {
|
||||||
|
|
||||||
val showData = parseJson<Edges>(jsEval as String)
|
val showData = parseJson<Edges>(jsEval as String)
|
||||||
|
|
||||||
|
val typeCheck =
|
||||||
|
when (document.select(".info-content > .spe > span:nth-child(5), .info-content > .spe > span")
|
||||||
|
.text().trim()) {
|
||||||
|
"OVA" -> "OVA"
|
||||||
|
"Movie" -> "Movie"
|
||||||
|
else -> "TV"
|
||||||
|
}
|
||||||
|
|
||||||
val title = showData.name
|
val title = showData.name
|
||||||
val description = showData.description
|
val description = showData.description
|
||||||
val poster = showData.thumbnail
|
val poster = showData.thumbnail
|
||||||
|
|
||||||
|
val (malId, anilistId, image, cover) = getTracker(title, typeCheck, year)
|
||||||
|
|
||||||
val episodes = showData.availableEpisodes.let {
|
val episodes = showData.availableEpisodes.let {
|
||||||
if (it == null) return@let Pair(null, null)
|
if (it == null) return@let Pair(null, null)
|
||||||
Pair(if (it.sub != 0) ((1..it.sub).map { epNum ->
|
Pair(if (it.sub != 0) ((1..it.sub).map { epNum ->
|
||||||
|
|
@ -417,8 +431,16 @@ class AllAnimeProvider : MainAPI() {
|
||||||
).path),
|
).path),
|
||||||
Qualities.P1080.value,
|
Qualities.P1080.value,
|
||||||
false
|
false
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun getTracker(title: String?, type: String?, year: Int?): Tracker {
|
private suspend fun getTracker(title: String?, type: String?, year: Int?): Tracker {
|
||||||
val res = app.get("https://api.consumet.org/meta/anilist/$title")
|
val res = app.get("https://api.consumet.org/meta/anilist/$title")
|
||||||
|
|
@ -455,16 +477,6 @@ class AllAnimeProvider : MainAPI() {
|
||||||
|
|
||||||
data class AniSearch(
|
data class AniSearch(
|
||||||
@JsonProperty("results") val results: ArrayList<Results>? = arrayListOf(),
|
@JsonProperty("results") val results: ArrayList<Results>? = arrayListOf(),
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue