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 // use an integer for version numbers
version = 2 version = 3
cloudstream { cloudstream {

View File

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