Skip to content

Commit

Permalink
fix #583
Browse files Browse the repository at this point in the history
  • Loading branch information
olivia committed Feb 9, 2024
1 parent 6cce883 commit d17d1e8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion DubokuProvider/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// use an integer for version numbers
version = 2
version = 3


cloudstream {
Expand Down
49 changes: 28 additions & 21 deletions DubokuProvider/src/main/kotlin/com/hexated/DubokuProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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?,
)


Expand Down

0 comments on commit d17d1e8

Please sign in to comment.