possibly added mal sync

This commit is contained in:
KillerDogeEmpire 2023-02-04 18:01:56 -08:00
parent 4f6d984d6a
commit 127f77131b
1 changed files with 40 additions and 0 deletions

View File

@ -218,6 +218,7 @@ 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__")
@ -417,6 +418,45 @@ 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<AniSearch>()?.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<Results>? = arrayListOf(),
)
)
)
}