Updated Animixplay search

This commit is contained in:
KillerDogeEmpire 2022-10-02 23:10:16 -07:00
parent 421924efd1
commit ef6da9600b

View file

@ -51,7 +51,7 @@ class Animixplay : MainAPI() {
"$mainUrl/api/search" to "Movie", "$mainUrl/api/search" to "Movie",
) )
private var newPagination : String? = null private var newPagination: String? = null
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse { override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
val items = mutableListOf<HomePageList>() val items = mutableListOf<HomePageList>()
val paged = page.toString() val paged = page.toString()
@ -132,35 +132,21 @@ class Animixplay : MainAPI() {
} }
override suspend fun search(query: String):List<SearchResponse>?{ override suspend fun search(query: String): List<SearchResponse>? {
val searchData = app.post( return app.post(
url = "https://v1.ij7p9towl8uj4qafsopjtrjk.workers.dev", url = "https://v1.ij7p9towl8uj4qafsopjtrjk.workers.dev",
referer = mainUrl, referer = mainUrl,
data = mapOf( data = mapOf(
"q2" to query, "q2" to query,
"origin" to "1", "origin" to "1",
"root" to "animixplay.to", "root" to "animixplay.to",
"d" to "gogoanime.tel") "d" to "gogoanime.tel"
) )
return Jsoup.parse(JSONObject(searchData.text).get("result").toString()).select("div").map{elem-> ).parsedSafe<FullSearch>()?.result?.let {
Jsoup.parse(it).select("div").map { elem ->
val href = fixUrl(elem.select("a").attr("href")) val href = fixUrl(elem.select("a").attr("href"))
val title = elem.select("a").attr("title") val title = elem.select("a").attr("title")
newAnimeSearchResponse(title, href, TvType.Anime) {
this.posterUrl = elem.select("img").attr("src")
addDubStatus(isDub = title.contains("Dub"))
}
}
}
override suspend fun quickSearch(query: String): List<SearchResponse>? {
return app.post(
"https://cdn.animixplay.to/api/search",
data = mapOf("qfast" to query, "root" to URI(mainUrl).host)
).parsedSafe<Search>()?.result?.let {
Jsoup.parse(it).select("a").map { elem ->
val href = elem.attr("href")
val title = elem.select("p.name").text()
newAnimeSearchResponse(title, href, TvType.Anime) { newAnimeSearchResponse(title, href, TvType.Anime) {
this.posterUrl = elem.select("img").attr("src") this.posterUrl = elem.select("img").attr("src")
addDubStatus(isDub = title.contains("Dub")) addDubStatus(isDub = title.contains("Dub"))
@ -169,189 +155,206 @@ class Animixplay : MainAPI() {
} }
} }
override suspend fun quickSearch(query: String): List<SearchResponse>? {
override suspend fun load(url: String): LoadResponse? { return app.post(
"https://cdn.animixplay.to/api/search",
val (fixUrl, malId) = if (url.contains("/anime/")) { data = mapOf("qfast" to query, "root" to URI(mainUrl).host)
listOf(url, Regex("anime/([0-9]+)/?").find(url)?.groupValues?.get(1)) ).parsedSafe<Search>()?.result?.let {
} else { Jsoup.parse(it).select("a").map { elem ->
val malId = app.get(url).text.substringAfterLast("malid = '").substringBefore("';") val href = elem.attr("href")
listOf("$mainUrl/anime/$malId", malId) val title = elem.select("p.name").text()
newAnimeSearchResponse(title, href, TvType.Anime) {
this.posterUrl = elem.select("img").attr("src")
addDubStatus(isDub = title.contains("Dub"))
}
}
}
} }
val anilistId = app.post(
"https://graphql.anilist.co/", data = mapOf(
"query" to "{Media(idMal:$malId,type:ANIME){id}}",
)
).parsedSafe<DataAni>()?.data?.media?.id
val res = app.get("$mainUrl/assets/mal/$malId.json").parsedSafe<AnimeDetail>() override suspend fun load(url: String): LoadResponse? {
?: throw ErrorLoadingException("Invalid json responses")
val subEpisodes = mutableListOf<Episode>() val (fixUrl, malId) = if (url.contains("/anime/")) {
val dubEpisodes = mutableListOf<Episode>() listOf(url, Regex("anime/([0-9]+)/?").find(url)?.groupValues?.get(1))
} else {
val malId = app.get(url).text.substringAfterLast("malid = '").substringBefore("';")
listOf("$mainUrl/anime/$malId", malId)
}
app.post("$mainUrl/api/search", data = mapOf("recomended" to "$malId")) val anilistId = app.post(
.parsedSafe<Data>()?.data?.filter { it.type == "GOGO" }?.map { item -> "https://graphql.anilist.co/", data = mapOf(
item.items?.apmap { server -> "query" to "{Media(idMal:$malId,type:ANIME){id}}",
val dataEps = )
app.get(fixUrl(server.url.toString())).document.select("div#epslistplace") ).parsedSafe<DataAni>()?.data?.media?.id
.text().trim()
Regex("\"([0-9]+)\":\"(\\S+?)\"").findAll(dataEps).toList() val res = app.get("$mainUrl/assets/mal/$malId.json").parsedSafe<AnimeDetail>()
.map { it.groupValues[1] to it.groupValues[2] }.map { (ep, link) -> ?: throw ErrorLoadingException("Invalid json responses")
val episode = Episode(fixUrl(link), episode = ep.toInt() + 1)
if (server.url?.contains("-dub") == true) { val subEpisodes = mutableListOf<Episode>()
dubEpisodes.add(episode) val dubEpisodes = mutableListOf<Episode>()
} else {
subEpisodes.add(episode) app.post("$mainUrl/api/search", data = mapOf("recomended" to "$malId"))
.parsedSafe<Data>()?.data?.filter { it.type == "GOGO" }?.map { item ->
item.items?.apmap { server ->
val dataEps =
app.get(fixUrl(server.url.toString())).document.select("div#epslistplace")
.text().trim()
Regex("\"([0-9]+)\":\"(\\S+?)\"").findAll(dataEps).toList()
.map { it.groupValues[1] to it.groupValues[2] }.map { (ep, link) ->
val episode = Episode(fixUrl(link), episode = ep.toInt() + 1)
if (server.url?.contains("-dub") == true) {
dubEpisodes.add(episode)
} else {
subEpisodes.add(episode)
}
} }
} }
} }
val recommendations = app.get("$mainUrl/assets/similar/$malId.json")
.parsedSafe<RecResult>()?.recommendations?.mapNotNull { rec ->
newAnimeSearchResponse(
rec.title ?: return@mapNotNull null,
"$mainUrl/anime/${rec.malId}/",
TvType.Anime
) {
this.posterUrl = rec.imageUrl
addDubStatus(dubExist = false, subExist = true)
}
}
return newAnimeLoadResponse(
res.title ?: return null,
url,
TvType.Anime
) {
engName = res.title
posterUrl = res.imageUrl
this.year = res.aired?.from?.split("-")?.firstOrNull()?.toIntOrNull()
showStatus = getStatus(res.status)
plot = res.synopsis
this.tags = res.genres?.mapNotNull { it.name }
this.recommendations = recommendations
addMalId(malId?.toIntOrNull())
addAniListId(anilistId?.toIntOrNull())
addTrailer(res.trailerUrl)
if (subEpisodes.isNotEmpty()) addEpisodes(DubStatus.Subbed, subEpisodes)
if (dubEpisodes.isNotEmpty()) addEpisodes(DubStatus.Dubbed, dubEpisodes)
} }
val recommendations = app.get("$mainUrl/assets/similar/$malId.json")
.parsedSafe<RecResult>()?.recommendations?.mapNotNull { rec ->
newAnimeSearchResponse(
rec.title ?: return@mapNotNull null,
"$mainUrl/anime/${rec.malId}/",
TvType.Anime
) {
this.posterUrl = rec.imageUrl
addDubStatus(dubExist = false, subExist = true)
}
}
return newAnimeLoadResponse(
res.title ?: return null,
url,
TvType.Anime
) {
engName = res.title
posterUrl = res.imageUrl
this.year = res.aired?.from?.split("-")?.firstOrNull()?.toIntOrNull()
showStatus = getStatus(res.status)
plot = res.synopsis
this.tags = res.genres?.mapNotNull { it.name }
this.recommendations = recommendations
addMalId(malId?.toIntOrNull())
addAniListId(anilistId?.toIntOrNull())
addTrailer(res.trailerUrl)
if (subEpisodes.isNotEmpty()) addEpisodes(DubStatus.Subbed, subEpisodes)
if (dubEpisodes.isNotEmpty()) addEpisodes(DubStatus.Dubbed, dubEpisodes)
} }
override suspend fun loadLinks(
data: String,
isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
val iframe = app.get(data)
val iframeDoc = iframe.document
argamap({
iframeDoc.select(".list-server-items > .linkserver")
.forEach { element ->
val status = element.attr("data-status") ?: return@forEach
if (status != "1") return@forEach
val extractorData = element.attr("data-video") ?: return@forEach
loadExtractor(extractorData, iframe.url, subtitleCallback, callback)
}
}, {
val iv = "3134003223491201"
val secretKey = "37911490979715163134003223491201"
val secretDecryptKey = "54674138327930866480207815084989"
GogoanimeProvider.extractVidstream(
iframe.url,
this.name,
callback,
iv,
secretKey,
secretDecryptKey,
isUsingAdaptiveKeys = false,
isUsingAdaptiveData = true,
iframeDocument = iframeDoc
)
})
return true
} }
override suspend fun loadLinks( private data class IdAni(
data: String, @JsonProperty("id") val id: String? = null,
isCasting: Boolean, )
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
val iframe = app.get(data) private data class MediaAni(
val iframeDoc = iframe.document @JsonProperty("Media") val media: IdAni? = null,
)
argamap({ private data class DataAni(
iframeDoc.select(".list-server-items > .linkserver") @JsonProperty("data") val data: MediaAni? = null,
.forEach { element -> )
val status = element.attr("data-status") ?: return@forEach
if (status != "1") return@forEach
val extractorData = element.attr("data-video") ?: return@forEach
loadExtractor(extractorData, iframe.url, subtitleCallback, callback)
}
}, {
val iv = "3134003223491201"
val secretKey = "37911490979715163134003223491201"
val secretDecryptKey = "54674138327930866480207815084989"
GogoanimeProvider.extractVidstream(
iframe.url,
this.name,
callback,
iv,
secretKey,
secretDecryptKey,
isUsingAdaptiveKeys = false,
isUsingAdaptiveData = true,
iframeDocument = iframeDoc
)
})
return true
}
private data class Items(
@JsonProperty("url") val url: String? = null,
@JsonProperty("title") val title: String? = null,
)
private data class Episodes(
@JsonProperty("type") val type: String? = null,
@JsonProperty("items") val items: ArrayList<Items>? = arrayListOf(),
)
private data class Data(
@JsonProperty("data") val data: ArrayList<Episodes>? = arrayListOf(),
)
private data class IdAni( private data class Aired(
@JsonProperty("id") val id: String? = null, @JsonProperty("from") val from: String? = null,
) )
private data class MediaAni( private data class Genres(
@JsonProperty("Media") val media: IdAni? = null, @JsonProperty("name") val name: String? = null,
) )
private data class DataAni( private data class RecResult(
@JsonProperty("data") val data: MediaAni? = null, @JsonProperty("recommendations") val recommendations: ArrayList<Recommendations>? = arrayListOf(),
) )
private data class Items( private data class Recommendations(
@JsonProperty("url") val url: String? = null, @JsonProperty("mal_id") val malId: String? = null,
@JsonProperty("title") val title: String? = null, @JsonProperty("image_url") val imageUrl: String? = null,
) @JsonProperty("title") val title: String? = null,
)
private data class Episodes( private data class AnimeDetail(
@JsonProperty("type") val type: String? = null, @JsonProperty("title") val title: String? = null,
@JsonProperty("items") val items: ArrayList<Items>? = arrayListOf(), @JsonProperty("image_url") val imageUrl: String? = null,
) @JsonProperty("type") val type: String? = null,
@JsonProperty("aired") val aired: Aired? = null,
@JsonProperty("status") val status: String? = null,
@JsonProperty("synopsis") val synopsis: String? = null,
@JsonProperty("trailer_url") val trailerUrl: String? = null,
@JsonProperty("genres") val genres: ArrayList<Genres>? = arrayListOf(),
)
private data class Data( private data class Search(
@JsonProperty("data") val data: ArrayList<Episodes>? = arrayListOf(), @JsonProperty("result") val result: String? = null,
) )
private data class Aired( private data class Result(
@JsonProperty("from") val from: String? = null, @JsonProperty("result") val result: ArrayList<Anime> = arrayListOf(),
) @JsonProperty("last") val last: Any? = null,
)
private data class Genres( private data class Anime(
@JsonProperty("name") val name: String? = null, @JsonProperty("title") val title: String? = null,
) @JsonProperty("url") val url: String? = null,
@JsonProperty("img") val img: String? = null,
@JsonProperty("picture") val picture: String? = null,
@JsonProperty("infotext") val infotext: String? = null,
)
private data class RecResult( private data class FullSearch(
@JsonProperty("recommendations") val recommendations: ArrayList<Recommendations>? = arrayListOf(),
)
private data class Recommendations(
@JsonProperty("mal_id") val malId: String? = null,
@JsonProperty("image_url") val imageUrl: String? = null,
@JsonProperty("title") val title: String? = null,
)
private data class AnimeDetail(
@JsonProperty("title") val title: String? = null,
@JsonProperty("image_url") val imageUrl: String? = null,
@JsonProperty("type") val type: String? = null,
@JsonProperty("aired") val aired: Aired? = null,
@JsonProperty("status") val status: String? = null,
@JsonProperty("synopsis") val synopsis: String? = null,
@JsonProperty("trailer_url") val trailerUrl: String? = null,
@JsonProperty("genres") val genres: ArrayList<Genres>? = arrayListOf(),
)
private data class Search(
@JsonProperty("result") val result: String? = null, @JsonProperty("result") val result: String? = null,
) )
private data class Result(
@JsonProperty("result") val result: ArrayList<Anime> = arrayListOf(),
@JsonProperty("last") val last: Any? = null,
)
private data class Anime(
@JsonProperty("title") val title: String? = null,
@JsonProperty("url") val url: String? = null,
@JsonProperty("img") val img: String? = null,
@JsonProperty("picture") val picture: String? = null,
@JsonProperty("infotext") val infotext: String? = null,
)
} }