Update and rename AnimeKaiExtractor.kt to AnimeKaiMegaUpExtractor.kt

This commit is contained in:
Arkai1 2025-04-12 19:54:46 +05:30 committed by GitHub
parent b83bf76512
commit 7ef90f4e28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,8 @@ package eu.kanade.tachiyomi.animeextension.en.animekai.extractors
import eu.kanade.tachiyomi.animeextension.en.animekai.AnimekaiDecoder import eu.kanade.tachiyomi.animeextension.en.animekai.AnimekaiDecoder
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import okhttp3.Headers import okhttp3.Headers
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
@ -11,38 +13,34 @@ import uy.kohesive.injekt.injectLazy
class MegaUpExtractor { class MegaUpExtractor {
private val client: OkHttpClient by injectLazy() private val client: OkHttpClient by injectLazy()
private val decoder = AnimekaiDecoder()
fun getVideoList(url: String): List<Video> { fun getVideoList(url: String): List<Video> {
val mediaUrl = url.replace("/e/", "/media/").replace("/e2/", "/media/") val mediaUrl = url.replace("/e/", "/media/").replace("/e2/", "/media/")
val encodedResult = runCatching { val encodedResult = runCatching {
val response = client.newCall(GET(mediaUrl)).execute().body.string() val response = client.newCall(GET(mediaUrl)).execute().body?.string().orEmpty()
Jsoup.parse(response).selectFirst("body")?.text()?.let { json -> Jsoup.parse(response).selectFirst("body")?.text()?.let { json ->
json.substringAfter("\"result\":\"").substringBefore("\",\"status\"") json.substringAfter("\"result\":\"").substringBefore("\",\"status\"")
} }
}.getOrNull() ?: return emptyList() }.getOrNull() ?: return emptyList()
val decryptSteps = runCatching { val decryptSteps = runCatching {
val json = client.newCall(GET(KEYS_URL)).execute().body.string() val json = client.newCall(GET(KEYS_URL)).execute().body?.string().orEmpty()
Json.decodeFromString(AnimeKaiKey.serializer(), json).megaup.decrypt Json.decodeFromString<AnimeKaiKey>(json).megaup.decrypt
}.getOrNull() ?: return emptyList() }.getOrNull() ?: return emptyList()
val decodedJson = runCatching { val decodedJson = runCatching {
AnimekaiDecoder().decode(encodedResult, decryptSteps).replace("\\", "") decoder.decode(encodedResult, decryptSteps).replace("\\", "")
}.getOrNull() ?: return emptyList() }.getOrNull() ?: return emptyList()
val m3u8Data = runCatching { val m3u8Data = runCatching {
Json.decodeFromString(M3U8.serializer(), decodedJson) Json.decodeFromString<M3U8>(decodedJson)
}.getOrNull() ?: return emptyList() }.getOrNull() ?: return emptyList()
val videoList = mutableListOf<Video>() return m3u8Data.sources.map {
Video(it.file, "MegaUp - Auto", it.file)
m3u8Data.sources.forEach { source ->
val quality = "MegaUp - Auto"
videoList.add(Video(source.file, quality, source.file))
} }
return videoList
} }
companion object { companion object {