package com.hexated import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.* import org.jsoup.nodes.Element open class Filemoon : ExtractorApi() { override val name = "Filemoon" override val mainUrl = "https://filemoon.sx" override val requiresReferer = true override suspend fun getUrl( url: String, referer: String?, subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit ) { val doc = app.get(url).document val link = unpackJs(doc)?.substringAfter("file:\"")?.substringBefore("\"") M3u8Helper.generateM3u8( name, link ?: return, "$mainUrl/", ).forEach(callback) } private fun unpackJs(script: Element): String? { return script.select("script").find { it.data().contains("eval(function(p,a,c,k,e,d)") } ?.data()?.let { getAndUnpack(it) } } }