animepahe: fix getting details and links
This commit is contained in:
@ -5,7 +5,7 @@ ext {
|
|||||||
extName = 'AnimePahe'
|
extName = 'AnimePahe'
|
||||||
pkgNameSuffix = 'en.animepahe'
|
pkgNameSuffix = 'en.animepahe'
|
||||||
extClass = '.AnimePahe'
|
extClass = '.AnimePahe'
|
||||||
extVersionCode = 13
|
extVersionCode = 14
|
||||||
libVersion = '12'
|
libVersion = '12'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.animeextension.en.animepahe
|
|||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
import android.util.Log
|
||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import androidx.preference.SwitchPreferenceCompat
|
import androidx.preference.SwitchPreferenceCompat
|
||||||
@ -76,16 +77,19 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
override val client: OkHttpClient = network.cloudflareClient
|
override val client: OkHttpClient = network.cloudflareClient
|
||||||
|
|
||||||
override fun animeDetailsRequest(anime: SAnime): Request {
|
override fun animeDetailsRequest(anime: SAnime): Request {
|
||||||
val responseString = runBlocking {
|
val animeId = anime.url.substringAfterLast("?anime_id=")
|
||||||
|
val session = getSession(anime.title, animeId)
|
||||||
|
return GET("$baseUrl/anime/$session?anime_id=$animeId")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getSession(title: String, animeId: String): String {
|
||||||
|
return runBlocking {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
client.newCall(GET("$baseUrl/api?m=search&q=${anime.title}"))
|
client.newCall(GET("$baseUrl/api?m=search&q=$title"))
|
||||||
.execute().body!!.string()
|
.execute().body!!.string()
|
||||||
}
|
}
|
||||||
}
|
}.substringAfter("\"id\":$animeId")
|
||||||
val animeId = anime.url.substringAfterLast("?anime_id=")
|
|
||||||
val session = responseString.substringAfter("\"id\":$animeId")
|
|
||||||
.substringAfter("\"session\":\"").substringBefore("\"")
|
.substringAfter("\"session\":\"").substringBefore("\"")
|
||||||
return GET("$baseUrl/anime/$session?anime_id=$animeId")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun animeDetailsParse(response: Response): SAnime {
|
override fun animeDetailsParse(response: Response): SAnime {
|
||||||
@ -170,7 +174,9 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
|
|
||||||
override fun episodeListRequest(anime: SAnime): Request {
|
override fun episodeListRequest(anime: SAnime): Request {
|
||||||
val animeId = anime.url.substringAfterLast("?anime_id=")
|
val animeId = anime.url.substringAfterLast("?anime_id=")
|
||||||
return GET("$baseUrl/api?m=release&id=$animeId&sort=episode_desc&page=1")
|
val session = getSession(anime.title, animeId)
|
||||||
|
Log.i("bruh", session)
|
||||||
|
return GET("$baseUrl/api?m=release&id=$session&sort=episode_desc&page=1")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun episodeListParse(response: Response): List<SEpisode> {
|
override fun episodeListParse(response: Response): List<SEpisode> {
|
||||||
@ -224,16 +230,16 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
val videos = mutableListOf<Video>()
|
val videos = mutableListOf<Video>()
|
||||||
for (item in array) {
|
for (item in array) {
|
||||||
val quality = item.jsonObject.keys.first()
|
val quality = item.jsonObject.keys.first()
|
||||||
val adflyLink = item.jsonObject[quality]!!.jsonObject["kwik_pahewin"]!!.jsonPrimitive.content
|
val paheWinLink = item.jsonObject[quality]!!.jsonObject["kwik_pahewin"]!!.jsonPrimitive.content
|
||||||
val kwikLink = item.jsonObject[quality]!!.jsonObject["kwik"]!!.jsonPrimitive.content
|
val kwikLink = item.jsonObject[quality]!!.jsonObject["kwik"]!!.jsonPrimitive.content
|
||||||
val audio = item.jsonObject[quality]!!.jsonObject["audio"]!!
|
val audio = item.jsonObject[quality]!!.jsonObject["audio"]!!
|
||||||
val qualityString = if (audio is JsonNull) "${quality}p" else "${quality}p (" + audio.jsonPrimitive.content + " audio)"
|
val qualityString = if (audio is JsonNull) "${quality}p" else "${quality}p (" + audio.jsonPrimitive.content + " audio)"
|
||||||
videos.add(getVideo(adflyLink, kwikLink, qualityString))
|
videos.add(getVideo(paheWinLink, kwikLink, qualityString))
|
||||||
}
|
}
|
||||||
return videos
|
return videos
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getVideo(adflyUrl: String, kwikUrl: String, quality: String): Video {
|
private fun getVideo(paheUrl: String, kwikUrl: String, quality: String): Video {
|
||||||
return if (preferences.getBoolean("preferred_link_type", false)) {
|
return if (preferences.getBoolean("preferred_link_type", false)) {
|
||||||
val videoUrl = KwikExtractor(client).getHlsStreamUrl(kwikUrl, referer = baseUrl)
|
val videoUrl = KwikExtractor(client).getHlsStreamUrl(kwikUrl, referer = baseUrl)
|
||||||
Video(
|
Video(
|
||||||
@ -241,7 +247,7 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
Headers.headersOf("referer", "https://kwik.cx")
|
Headers.headersOf("referer", "https://kwik.cx")
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
val videoUrl = KwikExtractor(client).getStreamUrlFromKwik(adflyUrl)
|
val videoUrl = KwikExtractor(client).getStreamUrlFromKwik(paheUrl)
|
||||||
Video(videoUrl, quality, videoUrl, null)
|
Video(videoUrl, quality, videoUrl, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,13 +53,19 @@ class KwikExtractor(private val client: OkHttpClient) {
|
|||||||
val urlParts = substring.split("|").reversed()
|
val urlParts = substring.split("|").reversed()
|
||||||
assert(urlParts.lastIndex == 8)
|
assert(urlParts.lastIndex == 8)
|
||||||
return urlParts[0] + "://" + urlParts[1] + "-" + urlParts[2] + "." + urlParts[3] + "." +
|
return urlParts[0] + "://" + urlParts[1] + "-" + urlParts[2] + "." + urlParts[3] + "." +
|
||||||
urlParts[4] + "." + urlParts[5] + "/" + urlParts[6] + "/" + urlParts[7] + "/" +
|
urlParts[4] + "." + urlParts[5] + "/" + urlParts[6] + "/" + urlParts[7] + "/" +
|
||||||
urlParts[8] + "/uwu.m3u8"
|
urlParts[8] + "/uwu.m3u8"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getStreamUrlFromKwik(adflyUri: String): String {
|
fun getStreamUrlFromKwik(paheUrl: String): String {
|
||||||
|
val noRedirects = client.newBuilder()
|
||||||
|
.followRedirects(false)
|
||||||
|
.followSslRedirects(false)
|
||||||
|
.build()
|
||||||
|
val kwikUrl = "https://" + noRedirects.newCall(GET("$paheUrl/i")).execute()
|
||||||
|
.header("location")!!.substringAfterLast("https://")
|
||||||
val fContent =
|
val fContent =
|
||||||
client.newCall(GET(adflyUri, Headers.headersOf("referer", "https://kwik.cx/"))).execute()
|
client.newCall(GET(kwikUrl, Headers.headersOf("referer", "https://kwik.cx/"))).execute()
|
||||||
cookies += (fContent.header("set-cookie")!!)
|
cookies += (fContent.header("set-cookie")!!)
|
||||||
val fContentString = fContent.body!!.string()
|
val fContentString = fContent.body!!.string()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user