mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
properly fixed animepahe
This commit is contained in:
parent
15d85422ca
commit
7ddac2c454
1 changed files with 47 additions and 28 deletions
|
@ -63,6 +63,7 @@ class AnimePaheProvider : MainAPI() {
|
||||||
@JsonProperty("id") val id: Int,
|
@JsonProperty("id") val id: Int,
|
||||||
@JsonProperty("anime_id") val animeId: Int,
|
@JsonProperty("anime_id") val animeId: Int,
|
||||||
@JsonProperty("anime_title") val animeTitle: String,
|
@JsonProperty("anime_title") val animeTitle: String,
|
||||||
|
@JsonProperty("anime_slug") val animeSlug: String,
|
||||||
@JsonProperty("episode") val episode: Int,
|
@JsonProperty("episode") val episode: Int,
|
||||||
@JsonProperty("snapshot") val snapshot: String,
|
@JsonProperty("snapshot") val snapshot: String,
|
||||||
@JsonProperty("created_at") val createdAt: String,
|
@JsonProperty("created_at") val createdAt: String,
|
||||||
|
@ -86,7 +87,7 @@ class AnimePaheProvider : MainAPI() {
|
||||||
|
|
||||||
AnimeSearchResponse(
|
AnimeSearchResponse(
|
||||||
it.animeTitle,
|
it.animeTitle,
|
||||||
"https://animepahe.com/anime/${it.animeSession}",
|
"https://pahe.win/a/${it.animeId}?slug=${it.animeTitle}",
|
||||||
this.name,
|
this.name,
|
||||||
TvType.Anime,
|
TvType.Anime,
|
||||||
it.snapshot,
|
it.snapshot,
|
||||||
|
@ -107,8 +108,6 @@ class AnimePaheProvider : MainAPI() {
|
||||||
return HomePageResponse(items)
|
return HomePageResponse(items)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun search(query: String): ArrayList<SearchResponse> {
|
|
||||||
|
|
||||||
data class AnimePaheSearchData(
|
data class AnimePaheSearchData(
|
||||||
@JsonProperty("id") val id: Int,
|
@JsonProperty("id") val id: Int,
|
||||||
@JsonProperty("slug") val slug: String,
|
@JsonProperty("slug") val slug: String,
|
||||||
|
@ -129,6 +128,22 @@ class AnimePaheProvider : MainAPI() {
|
||||||
@JsonProperty("data") val data: List<AnimePaheSearchData>
|
@JsonProperty("data") val data: List<AnimePaheSearchData>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private fun getAnimeByIdAndTitle(title: String, animeId: Int): String? {
|
||||||
|
val url = "$mainUrl/api?m=search&l=8&q=$title"
|
||||||
|
val headers = mapOf("referer" to "$mainUrl/")
|
||||||
|
|
||||||
|
val req = khttp.get(url, headers = headers)
|
||||||
|
val data = req.let { mapper.readValue<AnimePaheSearch>(it.text) }
|
||||||
|
for (anime in data.data) {
|
||||||
|
if (anime.id == animeId) {
|
||||||
|
return "https://animepahe.com/anime/${anime.session}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun search(query: String): ArrayList<SearchResponse> {
|
||||||
val url = "$mainUrl/api?m=search&l=8&q=$query"
|
val url = "$mainUrl/api?m=search&l=8&q=$query"
|
||||||
val headers = mapOf("referer" to "$mainUrl/")
|
val headers = mapOf("referer" to "$mainUrl/")
|
||||||
|
|
||||||
|
@ -138,7 +153,7 @@ class AnimePaheProvider : MainAPI() {
|
||||||
return ArrayList(data.data.map {
|
return ArrayList(data.data.map {
|
||||||
AnimeSearchResponse(
|
AnimeSearchResponse(
|
||||||
it.title,
|
it.title,
|
||||||
"https://animepahe.com/anime/${it.session}",
|
"https://pahe.win/a/${it.id}?slug=${it.title}",
|
||||||
this.name,
|
this.name,
|
||||||
TvType.Anime,
|
TvType.Anime,
|
||||||
it.poster,
|
it.poster,
|
||||||
|
@ -178,7 +193,7 @@ class AnimePaheProvider : MainAPI() {
|
||||||
private fun generateListOfEpisodes(link: String): ArrayList<AnimeEpisode> {
|
private fun generateListOfEpisodes(link: String): ArrayList<AnimeEpisode> {
|
||||||
try {
|
try {
|
||||||
val attrs = link.split('/')
|
val attrs = link.split('/')
|
||||||
val id = attrs[attrs.size - 1]
|
val id = attrs[attrs.size - 1].split("?")[0]
|
||||||
|
|
||||||
val uri = "$mainUrl/api?m=release&id=$id&sort=episode_asc&page=1"
|
val uri = "$mainUrl/api?m=release&id=$id&sort=episode_asc&page=1"
|
||||||
val headers = mapOf("referer" to "$mainUrl/")
|
val headers = mapOf("referer" to "$mainUrl/")
|
||||||
|
@ -237,10 +252,14 @@ class AnimePaheProvider : MainAPI() {
|
||||||
|
|
||||||
override fun load(url: String): LoadResponse? {
|
override fun load(url: String): LoadResponse? {
|
||||||
return normalSafeApiCall {
|
return normalSafeApiCall {
|
||||||
val html = khttp.get(url).text
|
|
||||||
|
val regex = Regex("""a/(\d+)\?slug=(.+)""")
|
||||||
|
val (animeId, animeTitle) = regex.find(url)!!.destructured
|
||||||
|
val link = getAnimeByIdAndTitle(animeTitle, animeId.toInt())!!
|
||||||
|
|
||||||
|
val html = khttp.get(link).text
|
||||||
val doc = Jsoup.parse(html)
|
val doc = Jsoup.parse(html)
|
||||||
|
|
||||||
val title = doc.selectFirst(".anime-poster img")?.attr("alt")?.replace("Poster of ", "")
|
|
||||||
val japTitle = doc.selectFirst("h2.japanese")?.text()
|
val japTitle = doc.selectFirst("h2.japanese")?.text()
|
||||||
val poster = doc.selectFirst(".anime-poster a").attr("href")
|
val poster = doc.selectFirst(".anime-poster a").attr("href")
|
||||||
|
|
||||||
|
@ -277,9 +296,9 @@ class AnimePaheProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimeLoadResponse(
|
AnimeLoadResponse(
|
||||||
title,
|
animeTitle,
|
||||||
japTitle,
|
japTitle,
|
||||||
title.toString(),
|
animeTitle,
|
||||||
url,
|
url,
|
||||||
this.name,
|
this.name,
|
||||||
getType(tvType.toString()),
|
getType(tvType.toString()),
|
||||||
|
|
Loading…
Reference in a new issue