mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
33 lines
991 B
Kotlin
33 lines
991 B
Kotlin
|
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) }
|
||
|
}
|
||
|
|
||
|
}
|