AnimePahe: Fix broken library URLs (#1397)
* Fix: add support to old animepahe URLs * chore: bump version
This commit is contained in:
parent
70a9b8c71d
commit
4da99feaa3
@ -6,7 +6,7 @@ ext {
|
|||||||
extName = 'AnimePahe'
|
extName = 'AnimePahe'
|
||||||
pkgNameSuffix = 'en.animepahe'
|
pkgNameSuffix = 'en.animepahe'
|
||||||
extClass = '.AnimePahe'
|
extClass = '.AnimePahe'
|
||||||
extVersionCode = 21
|
extVersionCode = 22
|
||||||
libVersion = '13'
|
libVersion = '13'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,16 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
override val client: OkHttpClient = network.cloudflareClient
|
override val client: OkHttpClient = network.cloudflareClient
|
||||||
|
|
||||||
// =========================== Anime Details ============================
|
// =========================== Anime Details ============================
|
||||||
|
override fun animeDetailsRequest(anime: SAnime): Request {
|
||||||
|
return if (anime.getSession().isBlank()) {
|
||||||
|
val animeId = anime.getId()
|
||||||
|
val session = fetchSession(anime.title, animeId)
|
||||||
|
return GET("$baseUrl/anime/$session?anime_id=$animeId")
|
||||||
|
} else {
|
||||||
|
super.animeDetailsRequest(anime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun animeDetailsParse(response: Response): SAnime {
|
override fun animeDetailsParse(response: Response): SAnime {
|
||||||
val document = response.use { it.asJsoup() }
|
val document = response.use { it.asJsoup() }
|
||||||
return SAnime.create().apply {
|
return SAnime.create().apply {
|
||||||
@ -117,7 +127,9 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
|
|
||||||
// ============================== Episodes ==============================
|
// ============================== Episodes ==============================
|
||||||
override fun episodeListRequest(anime: SAnime): Request {
|
override fun episodeListRequest(anime: SAnime): Request {
|
||||||
val session = anime.url.substringBefore("?anime_id=").substringAfterLast("/")
|
val session = anime.getSession().ifEmpty {
|
||||||
|
fetchSession(anime.title, anime.getId())
|
||||||
|
}
|
||||||
return GET("$baseUrl/api?m=release&id=$session&sort=episode_desc&page=1")
|
return GET("$baseUrl/api?m=release&id=$session&sort=episode_desc&page=1")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,6 +274,15 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ============================= Utilities ==============================
|
// ============================= Utilities ==============================
|
||||||
|
private fun fetchSession(title: String, animeId: String): String {
|
||||||
|
return client.newCall(GET("$baseUrl/api?m=search&q=$title"))
|
||||||
|
.execute()
|
||||||
|
.use { it.body.string() }
|
||||||
|
.substringAfter("\"id\":$animeId")
|
||||||
|
.substringAfter("\"session\":\"")
|
||||||
|
.substringBefore("\"")
|
||||||
|
}
|
||||||
|
|
||||||
private fun parseStatus(statusString: String): Int {
|
private fun parseStatus(statusString: String): Int {
|
||||||
return when (statusString) {
|
return when (statusString) {
|
||||||
"Currently Airing" -> SAnime.ONGOING
|
"Currently Airing" -> SAnime.ONGOING
|
||||||
@ -270,6 +291,9 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun SAnime.getSession() = url.substringBefore("?anime_id=").substringAfterLast("/")
|
||||||
|
private fun SAnime.getId() = url.substringAfterLast("?anime_id=").substringBefore("\"")
|
||||||
|
|
||||||
private fun String.toDate(): Long {
|
private fun String.toDate(): Long {
|
||||||
return runCatching {
|
return runCatching {
|
||||||
DATE_FORMATTER.parse(this)?.time ?: 0L
|
DATE_FORMATTER.parse(this)?.time ?: 0L
|
||||||
|
Loading…
x
Reference in New Issue
Block a user