package com.hexated import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.* import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson class Jeniusplay : ExtractorApi() { override val name = "Jeniusplay" override val mainUrl = "https://jeniusplay.com" override val requiresReferer = true override suspend fun getUrl( url: String, referer: String?, subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit ) { val document = app.get(url, referer = "$mainUrl/").document val hash = url.split("/").last().substringAfter("data=") val m3uLink = app.post( url = "$mainUrl/player/index.php?data=$hash&do=getVideo", data = mapOf("hash" to hash, "r" to "$referer"), referer = url, headers = mapOf("X-Requested-With" to "XMLHttpRequest") ).parsed().videoSource M3u8Helper.generateM3u8( this.name, m3uLink, url, ).forEach(callback) document.select("script").map { script -> if (script.data().contains("eval(function(p,a,c,k,e,d)")) { val subData = getAndUnpack(script.data()).substringAfter("\"tracks\":[").substringBefore("],") tryParseJson>("[$subData]")?.map { subtitle -> subtitleCallback.invoke( SubtitleFile( getLanguage(subtitle.label.toString()), subtitle.file ) ) } } } } private fun getLanguage(str: String): String { return when { str.lowercase().contains("indonesia") || str.lowercase() .contains("bahasa") -> "Indonesian" else -> str } } data class ResponseSource( @JsonProperty("hls") val hls: Boolean, @JsonProperty("videoSource") val videoSource: String, @JsonProperty("securedLink") val securedLink: String?, ) data class Tracks( @JsonProperty("kind") val kind: String?, @JsonProperty("file") val file: String, @JsonProperty("label") val label: String?, ) }