mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
extractor: added Vidplay
This commit is contained in:
parent
962ff1c058
commit
4664674433
2 changed files with 94 additions and 0 deletions
|
@ -0,0 +1,92 @@
|
|||
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.base64Encode
|
||||
import com.lagradost.cloudstream3.utils.ExtractorApi
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.M3u8Helper
|
||||
import javax.crypto.Cipher
|
||||
import javax.crypto.spec.SecretKeySpec
|
||||
|
||||
// Code found in https://github.com/Claudemirovsky/worstsource-keys
|
||||
// special credits to @Claudemirovsky for providing key
|
||||
open class Vidplay : ExtractorApi() {
|
||||
override val name = "Vidplay"
|
||||
override val mainUrl = "https://vidplay.site"
|
||||
override val requiresReferer = true
|
||||
|
||||
override suspend fun getUrl(
|
||||
url: String,
|
||||
referer: String?,
|
||||
subtitleCallback: (SubtitleFile) -> Unit,
|
||||
callback: (ExtractorLink) -> Unit
|
||||
) {
|
||||
val id = url.substringAfter("/e/").substringBefore("?")
|
||||
val encodeId = encodeId(id, getKeys())
|
||||
val mediaUrl = callFutoken(encodeId, url)
|
||||
val res = app.get(
|
||||
"$mediaUrl", headers = mapOf(
|
||||
"Accept" to "application/json, text/javascript, */*; q=0.01",
|
||||
"X-Requested-With" to "XMLHttpRequest",
|
||||
), referer = url
|
||||
).parsedSafe<Response>()?.result?.sources
|
||||
|
||||
res?.map {
|
||||
M3u8Helper.generateM3u8(
|
||||
this.name,
|
||||
it.file ?: return@map,
|
||||
"$mainUrl/"
|
||||
).forEach(callback)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private suspend fun getKeys(): List<String> {
|
||||
return app.get("https://raw.githubusercontent.com/Claudemirovsky/worstsource-keys/keys/keys.json")
|
||||
.parsed()
|
||||
}
|
||||
|
||||
private suspend fun callFutoken(id: String, url: String): String? {
|
||||
val script = app.get("$mainUrl/futoken").text
|
||||
val k = "k='(\\S+)'".toRegex().find(script)?.groupValues?.get(1) ?: return null
|
||||
val a = mutableListOf(k)
|
||||
for (i in id.indices) {
|
||||
a.add((k[i % k.length].code + id[i].code).toString())
|
||||
}
|
||||
return "$mainUrl/mediainfo/${a.joinToString(",")}?${url.substringAfter("?")}"
|
||||
}
|
||||
|
||||
private fun encodeId(id: String, keyList: List<String>): String {
|
||||
val cipher1 = Cipher.getInstance("RC4")
|
||||
val cipher2 = Cipher.getInstance("RC4")
|
||||
cipher1.init(
|
||||
Cipher.DECRYPT_MODE,
|
||||
SecretKeySpec(keyList[0].toByteArray(), "RC4"),
|
||||
cipher1.parameters
|
||||
)
|
||||
cipher2.init(
|
||||
Cipher.DECRYPT_MODE,
|
||||
SecretKeySpec(keyList[1].toByteArray(), "RC4"),
|
||||
cipher2.parameters
|
||||
)
|
||||
var input = id.toByteArray()
|
||||
input = cipher1.doFinal(input)
|
||||
input = cipher2.doFinal(input)
|
||||
return base64Encode(input).replace("/", "_")
|
||||
}
|
||||
|
||||
data class Sources(
|
||||
@JsonProperty("file") val file: String? = null,
|
||||
)
|
||||
|
||||
data class Result(
|
||||
@JsonProperty("sources") val sources: ArrayList<Sources>? = arrayListOf(),
|
||||
)
|
||||
|
||||
data class Response(
|
||||
@JsonProperty("result") val result: Result? = null,
|
||||
)
|
||||
|
||||
}
|
|
@ -167,6 +167,7 @@ import com.lagradost.cloudstream3.extractors.Vidgomunimesb
|
|||
import com.lagradost.cloudstream3.extractors.Vidmoly
|
||||
import com.lagradost.cloudstream3.extractors.Vidmolyme
|
||||
import com.lagradost.cloudstream3.extractors.Vido
|
||||
import com.lagradost.cloudstream3.extractors.Vidplay
|
||||
import com.lagradost.cloudstream3.extractors.Vidstreamz
|
||||
import com.lagradost.cloudstream3.extractors.Vizcloud
|
||||
import com.lagradost.cloudstream3.extractors.Vizcloud2
|
||||
|
@ -793,6 +794,7 @@ val extractorApis: MutableList<ExtractorApi> = arrayListOf(
|
|||
VidSrcExtractor2(),
|
||||
PlayLtXyz(),
|
||||
AStreamHub(),
|
||||
Vidplay(),
|
||||
|
||||
Cda(),
|
||||
Dailymotion(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue