This commit is contained in:
Olivia 2024-02-09 16:45:04 +07:00
parent 6cce88370a
commit d17d1e870a
2 changed files with 29 additions and 22 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers
version = 2
version = 3
cloudstream {

View file

@ -10,6 +10,7 @@ import java.net.URLDecoder
class DubokuProvider : MainAPI() {
override var mainUrl = "https://www.duboku.tv"
private var serverUrl = "https://w.duboku.io"
override var name = "Duboku"
override val hasMainPage = true
override var lang = "zh"
@ -106,35 +107,41 @@ class DubokuProvider : MainAPI() {
callback: (ExtractorLink) -> Unit
): Boolean {
app.get(data).document.select("script").map { script ->
if (script.data().contains("var player_data={")) {
val dataJson =
script.data().substringAfter("var player_data={").substringBefore("}")
val source = tryParseJson<Sources>("{$dataJson}")
callback.invoke(
ExtractorLink(
this.name,
this.name,
decode(base64Decode(source?.url ?: return@map)),
"https://w.duboku.io/",
Qualities.Unknown.value,
INFER_TYPE,
headers = mapOf(
"Accept-Language" to "en-US,en;q=0.5",
"Origin" to "https://w.duboku.io"
),
)
)
}
}
val dataJson =
app.get(data).document.selectFirst("script:containsData(var player_data={)")?.data()
?.substringAfter("var player_data={")?.substringBefore("}")
?: throw IllegalArgumentException()
val source = tryParseJson<Sources>("{$dataJson}")
callback.invoke(
ExtractorLink(
this.name,
this.name,
"${decode(base64Decode(source?.url ?: return false))}${getSign(source.from, data)}",
"$serverUrl/",
Qualities.Unknown.value,
INFER_TYPE,
headers = mapOf(
"Accept-Language" to "en-US,en;q=0.5",
"Origin" to serverUrl
),
)
)
return true
}
private suspend fun getSign(server: String? = "vidjs24", ref: String): String {
return app.get(
"$serverUrl/static/player/$server.php",
referer = ref
).text.substringAfter("PlayUrl+'").substringBefore("'")
}
private fun decode(input: String): String = URLDecoder.decode(input, "utf-8")
data class Sources(
@JsonProperty("url") val url: String?,
@JsonProperty("from") val from: String?,
)