diff --git a/AllAnimeProvider/src/main/kotlin/com/lagradost/AllAnimeProvider.kt b/AllAnimeProvider/src/main/kotlin/com/lagradost/AllAnimeProvider.kt index 7460fdf..7207ff7 100644 --- a/AllAnimeProvider/src/main/kotlin/com/lagradost/AllAnimeProvider.kt +++ b/AllAnimeProvider/src/main/kotlin/com/lagradost/AllAnimeProvider.kt @@ -2,8 +2,11 @@ package com.lagradost import com.fasterxml.jackson.annotation.JsonProperty 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.addTrailer +import com.lagradost.cloudstream3.R.string.year import com.lagradost.cloudstream3.mvvm.safeApiCall import com.lagradost.cloudstream3.ui.settings.SettingsProviders import com.lagradost.cloudstream3.utils.AppUtils.parseJson @@ -211,6 +214,7 @@ class AllAnimeProvider : MainAPI() { override suspend fun load(url: String): LoadResponse? { + val document = app.get(url).document val rhino = Context.enter() rhino.initSafeStandardObjects() rhino.optimizationLevel = -1 @@ -218,11 +222,11 @@ class AllAnimeProvider : MainAPI() { val html = app.get(url).text val soup = Jsoup.parse(html) - val (malId, anilistId, image, cover) = getTracker(title, typeCheck, year) val script = soup.select("script").firstOrNull { it.html().contains("window.__NUXT__") } ?: return null + val js = """ const window = {} ${script.html()} @@ -234,10 +238,20 @@ class AllAnimeProvider : MainAPI() { val showData = parseJson(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 description = showData.description val poster = showData.thumbnail + val (malId, anilistId, image, cover) = getTracker(title, typeCheck, year) + val episodes = showData.availableEpisodes.let { if (it == null) return@let Pair(null, null) Pair(if (it.sub != 0) ((1..it.sub).map { epNum -> @@ -417,45 +431,6 @@ class AllAnimeProvider : MainAPI() { ).path), Qualities.P1080.value, false - } - } - - private suspend fun getTracker(title: String?, type: String?, year: Int?): Tracker { - val res = app.get("https://api.consumet.org/meta/anilist/$title") - .parsedSafe()?.results?.find { media -> - (media.title?.english.equals(title, true) || media.title?.romaji.equals( - title, - true - )) || (media.type.equals(type, true) && media.releaseDate == year) - } - return Tracker(res?.malId, res?.aniId, res?.image, res?.cover) - } - - data class Tracker( - val malId: Int? = null, - val aniId: String? = null, - val image: String? = null, - val cover: String? = null, - ) - - data class Title( - @JsonProperty("romaji") val romaji: String? = null, - @JsonProperty("english") val english: String? = null, - ) - - data class Results( - @JsonProperty("id") val aniId: String? = null, - @JsonProperty("malId") val malId: Int? = null, - @JsonProperty("title") val title: Title? = null, - @JsonProperty("releaseDate") val releaseDate: Int? = null, - @JsonProperty("type") val type: String? = null, - @JsonProperty("image") val image: String? = null, - @JsonProperty("cover") val cover: String? = null, - ) - - data class AniSearch( - @JsonProperty("results") val results: ArrayList? = arrayListOf(), - ) ) ) } @@ -467,4 +442,41 @@ class AllAnimeProvider : MainAPI() { return true } + private suspend fun getTracker(title: String?, type: String?, year: Int?): Tracker { + val res = app.get("https://api.consumet.org/meta/anilist/$title") + .parsedSafe()?.results?.find { media -> + (media.title?.english.equals(title, true) || media.title?.romaji.equals( + title, + true + )) || (media.type.equals(type, true) && media.releaseDate == year) + } + return Tracker(res?.malId, res?.aniId, res?.image, res?.cover) + } + + data class Tracker( + val malId: Int? = null, + val aniId: String? = null, + val image: String? = null, + val cover: String? = null, + ) + + data class Title( + @JsonProperty("romaji") val romaji: String? = null, + @JsonProperty("english") val english: String? = null, + ) + + data class Results( + @JsonProperty("id") val aniId: String? = null, + @JsonProperty("malId") val malId: Int? = null, + @JsonProperty("title") val title: Title? = null, + @JsonProperty("releaseDate") val releaseDate: Int? = null, + @JsonProperty("type") val type: String? = null, + @JsonProperty("image") val image: String? = null, + @JsonProperty("cover") val cover: String? = null, + ) + + data class AniSearch( + @JsonProperty("results") val results: ArrayList? = arrayListOf(), + + ) }