mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
72 lines
2.4 KiB
Kotlin
72 lines
2.4 KiB
Kotlin
|
package com.lagradost.cloudstream3.extractors
|
||
|
|
||
|
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
|
||
|
|
||
|
open 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<ResponseSource>().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<List<Tracks>>("[$subData]")?.map { subtitle ->
|
||
|
subtitleCallback.invoke(
|
||
|
SubtitleFile(
|
||
|
getLanguage(subtitle.label ?: ""),
|
||
|
subtitle.file
|
||
|
)
|
||
|
)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private fun getLanguage(str: String): String {
|
||
|
return when {
|
||
|
str.contains("indonesia", true) || str
|
||
|
.contains("bahasa", true) -> "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?,
|
||
|
)
|
||
|
}
|