Fix AllAnimeProvider
This commit is contained in:
parent
101161e829
commit
4f74324be3
|
@ -1,5 +1,5 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
|
||||||
import com.lagradost.cloudstream3.mvvm.safeApiCall
|
import com.lagradost.cloudstream3.mvvm.safeApiCall
|
||||||
|
import com.lagradost.cloudstream3.ui.settings.SettingsProviders
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.M3u8Helper
|
import com.lagradost.cloudstream3.utils.M3u8Helper
|
||||||
|
@ -104,56 +105,70 @@ class AllAnimeProvider : MainAPI() {
|
||||||
@JsonProperty("__typename") val _typename: String? = null
|
@JsonProperty("__typename") val _typename: String? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
override suspend fun getMainPage(page: Int, request : MainPageRequest): HomePageResponse {
|
private val popularTitle = "Popular"
|
||||||
val items = ArrayList<HomePageList>()
|
private val recentTitle = "Recently updated"
|
||||||
val urls = listOf(
|
override val mainPage = listOf(
|
||||||
// Pair(
|
MainPageData(
|
||||||
// "Top Anime",
|
recentTitle,
|
||||||
// """$mainUrl/graphql?variables={"type":"anime","size":30,"dateRange":30}&extensions={"persistedQuery":{"version":1,"sha256Hash":"276d52ba09ca48ce2b8beb3affb26d9d673b22f9d1fd4892aaa39524128bc745"}}"""
|
"""$mainUrl/allanimeapi?variables={"search":{"sortBy":"Recent","allowAdult":${settingsForProvider.enableAdult},"allowUnknown":false},"limit":26,"page":%d,"translationType":"sub","countryOrigin":"ALL"}&extensions={"persistedQuery":{"version":1,"sha256Hash":"9c7a8bc1e095a34f2972699e8105f7aaf9082c6e1ccd56eab99c2f1a971152c6"}}"""
|
||||||
// ),
|
),
|
||||||
// "countryOrigin":"JP" for Japanese only
|
MainPageData(
|
||||||
Pair(
|
popularTitle,
|
||||||
"Recently updated",
|
"""$mainUrl/allanimeapi?variables={"type":"anime","size":30,"dateRange":1,"page":%d,"allowAdult":${settingsForProvider.enableAdult},"allowUnknown":false}&extensions={"persistedQuery":{"version":1,"sha256Hash":"6f6fe5663e3e9ea60bdfa693f878499badab83e7f18b56acdba5f8e8662002aa"}}"""
|
||||||
"""$mainUrl/graphql?variables={"search":{"allowAdult":false,"allowUnknown":false},"limit":30,"page":1,"translationType":"dub","countryOrigin":"ALL"}&extensions={"persistedQuery":{"version":1,"sha256Hash":"d2670e3e27ee109630991152c8484fce5ff5e280c523378001f9a23dc1839068"}}"""
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
val random =
|
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
|
||||||
"""$mainUrl/graphql?variables={"format":"anime"}&extensions={"persistedQuery":{"version":1,"sha256Hash":"21ac672633498a3698e8f6a93ce6c2b3722b29a216dcca93363bf012c360cd54"}}"""
|
val url = request.data.format(page)
|
||||||
val ranlink = app.get(random).text
|
val test = app.get(url).text
|
||||||
val jsonran = parseJson<RandomMain>(ranlink)
|
|
||||||
val ranhome = jsonran.data?.queryRandomRecommendation?.map {
|
|
||||||
newAnimeSearchResponse(it.name!!, "$mainUrl/anime/${it.Id}", fix = false) {
|
|
||||||
this.posterUrl = it.thumbnail
|
|
||||||
this.otherName = it.nativeName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
items.add(HomePageList("Random", ranhome!!))
|
val home = when (request.name) {
|
||||||
|
recentTitle -> {
|
||||||
|
val json = parseJson<AllAnimeQuery>(test)
|
||||||
|
val results = json.data.shows.edges.filter {
|
||||||
|
// filtering in case there is an anime with 0 episodes available on the site.
|
||||||
|
!(it.availableEpisodes?.raw == 0 && it.availableEpisodes.sub == 0 && it.availableEpisodes.dub == 0)
|
||||||
|
}
|
||||||
|
|
||||||
urls.apmap { (HomeName, url) ->
|
results.map {
|
||||||
val test = app.get(url).text
|
|
||||||
val json = parseJson<AllAnimeQuery>(test)
|
|
||||||
val home = ArrayList<SearchResponse>()
|
|
||||||
val results = json.data.shows.edges.filter {
|
|
||||||
// filtering in case there is an anime with 0 episodes available on the site.
|
|
||||||
!(it.availableEpisodes?.raw == 0 && it.availableEpisodes.sub == 0 && it.availableEpisodes.dub == 0)
|
|
||||||
}
|
|
||||||
results.map {
|
|
||||||
home.add(
|
|
||||||
newAnimeSearchResponse(it.name, "$mainUrl/anime/${it.Id}", fix = false) {
|
newAnimeSearchResponse(it.name, "$mainUrl/anime/${it.Id}", fix = false) {
|
||||||
this.posterUrl = it.thumbnail
|
this.posterUrl = it.thumbnail
|
||||||
this.year = it.airedStart?.year
|
this.year = it.airedStart?.year
|
||||||
this.otherName = it.englishName
|
this.otherName = it.englishName
|
||||||
addDub(it.availableEpisodes?.dub)
|
addDub(it.availableEpisodes?.dub)
|
||||||
addSub(it.availableEpisodes?.sub)
|
addSub(it.availableEpisodes?.sub)
|
||||||
})
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
items.add(HomePageList(HomeName, home))
|
popularTitle -> {
|
||||||
|
val json = parseJson<PopularQuery>(test)
|
||||||
|
val results = json.data?.queryPopular?.recommendations?.filter {
|
||||||
|
// filtering in case there is an anime with 0 episodes available on the site.
|
||||||
|
!(it.anyCard?.availableEpisodes?.raw == 0 && it.anyCard.availableEpisodes.sub == 0 && it.anyCard.availableEpisodes.dub == 0)
|
||||||
|
}
|
||||||
|
results?.mapNotNull {
|
||||||
|
newAnimeSearchResponse(
|
||||||
|
it.anyCard?.name ?: return@mapNotNull null,
|
||||||
|
"$mainUrl/anime/${it.anyCard.Id ?: it.pageStatus?.Id}",
|
||||||
|
fix = false
|
||||||
|
) {
|
||||||
|
this.posterUrl = it.anyCard.thumbnail
|
||||||
|
this.otherName = it.anyCard.englishName
|
||||||
|
addDub(it.anyCard.availableEpisodes?.dub)
|
||||||
|
addSub(it.anyCard.availableEpisodes?.sub)
|
||||||
|
}
|
||||||
|
} ?: emptyList()
|
||||||
|
}
|
||||||
|
else -> emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.size <= 0) throw ErrorLoadingException()
|
|
||||||
return HomePageResponse(items)
|
|
||||||
|
return HomePageResponse(
|
||||||
|
listOf(
|
||||||
|
HomePageList(request.name, home)
|
||||||
|
), hasNext = home.isNotEmpty()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun search(query: String): List<SearchResponse> {
|
override suspend fun search(query: String): List<SearchResponse> {
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.lagradost
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
|
||||||
|
data class PopularQuery(
|
||||||
|
@JsonProperty("data") val data: Data? = Data()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
data class AvailableEpisodes(
|
||||||
|
@JsonProperty("sub") val sub: Int? = null,
|
||||||
|
@JsonProperty("dub") val dub: Int? = null,
|
||||||
|
@JsonProperty("raw") val raw: Int? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
data class Sub(
|
||||||
|
@JsonProperty("hour") val hour: Int? = null,
|
||||||
|
@JsonProperty("minute") val minute: Int? = null,
|
||||||
|
@JsonProperty("year") val year: Int? = null,
|
||||||
|
@JsonProperty("month") val month: Int? = null,
|
||||||
|
@JsonProperty("date") val date: Int? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
data class LastEpisodeDate(
|
||||||
|
@JsonProperty("dub") val dub: Sub? = Sub(),
|
||||||
|
@JsonProperty("sub") val sub: Sub? = Sub(),
|
||||||
|
@JsonProperty("raw") val raw: Sub? = Sub()
|
||||||
|
)
|
||||||
|
|
||||||
|
data class AnyCard(
|
||||||
|
@JsonProperty("_id") val Id: String? = null,
|
||||||
|
@JsonProperty("name") val name: String? = null,
|
||||||
|
@JsonProperty("englishName") val englishName: String? = null,
|
||||||
|
@JsonProperty("nativeName") val nativeName: String? = null,
|
||||||
|
@JsonProperty("availableEpisodes") val availableEpisodes: AvailableEpisodes? = AvailableEpisodes(),
|
||||||
|
@JsonProperty("score") val score: Double? = null,
|
||||||
|
@JsonProperty("lastEpisodeDate") val lastEpisodeDate: LastEpisodeDate? = LastEpisodeDate(),
|
||||||
|
@JsonProperty("thumbnail") val thumbnail: String? = null,
|
||||||
|
@JsonProperty("lastChapterDate") val lastChapterDate: String? = null,
|
||||||
|
@JsonProperty("availableChapters") val availableChapters: String? = null,
|
||||||
|
@JsonProperty("__typename") val _typename: String? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
data class PageStatus(
|
||||||
|
@JsonProperty("_id") val Id: String? = null,
|
||||||
|
@JsonProperty("views") val views: String? = null,
|
||||||
|
@JsonProperty("showId") val showId: String? = null,
|
||||||
|
@JsonProperty("rangeViews") val rangeViews: String? = null,
|
||||||
|
@JsonProperty("isManga") val isManga: Boolean? = null,
|
||||||
|
@JsonProperty("__typename") val _typename: String? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
data class Recommendations(
|
||||||
|
@JsonProperty("anyCard") val anyCard: AnyCard? = AnyCard(),
|
||||||
|
@JsonProperty("pageStatus") val pageStatus: PageStatus? = PageStatus(),
|
||||||
|
@JsonProperty("__typename") val _typename: String? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
data class QueryPopular(
|
||||||
|
@JsonProperty("total") val total: Int? = null,
|
||||||
|
@JsonProperty("recommendations") val recommendations: ArrayList<Recommendations> = arrayListOf(),
|
||||||
|
@JsonProperty("__typename") val _typename: String? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
data class Data(
|
||||||
|
@JsonProperty("queryPopular") val queryPopular: QueryPopular? = QueryPopular()
|
||||||
|
)
|
Loading…
Reference in New Issue