small fix Kickassanime

This commit is contained in:
hexated 2023-01-18 13:19:40 +07:00
parent 1a3cedc0f9
commit e61f39b11f

View file

@ -6,6 +6,7 @@ import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId
import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
import com.lagradost.cloudstream3.utils.* import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import org.jsoup.Jsoup
import java.net.URI import java.net.URI
import java.net.URLDecoder import java.net.URLDecoder
@ -155,8 +156,8 @@ class Kickassanime : MainAPI() {
val sourceName = fixTitle(name ?: this.name) val sourceName = fixTitle(name ?: this.name)
val link = httpsify(iframe ?: return@apmap null) val link = httpsify(iframe ?: return@apmap null)
when { when {
name?.contains(Regex("(?i)(KICKASSANIMEV2|ORIGINAL-QUALITY-V2|BETA-SERVER)")) == true -> { name?.contains(Regex("(?i)(KICKASSANIMEV2|ORIGINAL-QUALITY-V2|BETA-SERVER|DAILYMOTION)")) == true -> {
invokeAlpha(sourceName, link, callback) invokeAlpha(sourceName, link, subtitleCallback, callback)
} }
name?.contains(Regex("(?i)(BETAPLAYER)")) == true -> { name?.contains(Regex("(?i)(BETAPLAYER)")) == true -> {
invokeBeta(sourceName, link, callback) invokeBeta(sourceName, link, callback)
@ -177,16 +178,22 @@ class Kickassanime : MainAPI() {
private suspend fun invokeAlpha( private suspend fun invokeAlpha(
name: String, name: String,
url: String? = null, url: String? = null,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
) { ) {
val fixUrl = url?.replace(Regex("(player|embed)\\.php"), "pref.php") val fixUrl = url?.replace(Regex("(player|embed)\\.php"), "pref.php")
app.get( val data = app.get(
fixUrl ?: return, fixUrl ?: return,
referer = kaast referer = kaast
).document.selectFirst("script:containsData(Base64.decode)")?.data() ).document.selectFirst("script:containsData(Base64.decode)")?.data()
?.substringAfter("Base64.decode(\"")?.substringBefore("\")")?.let { base64Decode(it) } ?.substringAfter("Base64.decode(\"")?.substringBefore("\")")?.let { base64Decode(it) } ?: return
?.substringAfter("sources: [")?.substringBefore("],")
?.let { tryParseJson<List<AlphaSources>>("[$it]") }?.map { if(url.contains("/dailymotion/")) {
val iframe = Jsoup.parse(data).select("iframe").attr("src")
loadExtractor(iframe, mainUrl, subtitleCallback, callback)
} else {
val json = data.substringAfter("sources: [").substringBefore("],")
tryParseJson<List<AlphaSources>>("[$json]")?.map {
callback.invoke( callback.invoke(
ExtractorLink( ExtractorLink(
name, name,
@ -197,6 +204,8 @@ class Kickassanime : MainAPI() {
) )
) )
} }
}
} }
private suspend fun invokeBeta( private suspend fun invokeBeta(