Fix VidSrcTo extractor (#1198)

This commit is contained in:
RowdyRushya 2024-07-15 08:06:20 -07:00 committed by GitHub
parent 8be8e54746
commit febb843424
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 48 additions and 22 deletions

View file

@ -6,6 +6,7 @@ import com.lagradost.cloudstream3.extractors.helper.AesHelper.cryptoAESHandler
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper
import kotlin.run
class Moviesapi : Chillx() {
override val name = "Moviesapi"
@ -28,17 +29,22 @@ open class Chillx : ExtractorApi() {
override val requiresReferer = true
companion object {
private val keySource = "https://rowdy-avocado.github.io/multi-keys/"
private var key: String? = null
suspend fun fetchKey(): String {
return if (key != null) {
key!!
} else {
val fetch = app.get("https://raw.githubusercontent.com/rushi-chavan/multi-keys/keys/keys.json").parsedSafe<Keys>()?.key?.get(0) ?: throw ErrorLoadingException("Unable to get key")
key = fetch
key!!
}
private suspend fun fetchKey(): String {
return key
?: run {
val res =
app.get(keySource).parsedSafe<KeysData>()
?: throw ErrorLoadingException("Unable to get keys")
key = res.keys.get(0)
res.keys.get(0)
}
}
private data class KeysData(@JsonProperty("chillx") val keys: List<String>)
}
@Suppress("NAME_SHADOWING")
@ -97,11 +103,4 @@ open class Chillx : ExtractorApi() {
it.groupValues[1].toInt(16).toChar().toString()
}
}
data class Keys(
@JsonProperty("chillx") val key: List<String>
)
}

View file

@ -26,7 +26,13 @@ class VidSrcTo : ExtractorApi() {
callback: (ExtractorLink) -> Unit
) {
val mediaId = app.get(url).document.selectFirst("ul.episodes li a")?.attr("data-id") ?: return
val res = app.get("$mainUrl/ajax/embed/episode/$mediaId/sources").parsedSafe<VidsrctoEpisodeSources>() ?: return
val subtitlesLink = "$mainUrl/ajax/embed/episode/$mediaId/subtitles"
val subRes = app.get(subtitlesLink).parsedSafe<Array<VidsrctoSubtitles>>()
subRes?.forEach {
if (it.kind.equals("captions")) subtitleCallback.invoke(SubtitleFile(it.label, it.file))
}
val sourcesLink = "$mainUrl/ajax/embed/episode/$mediaId/sources"
val res = app.get(sourcesLink).parsedSafe<VidsrctoEpisodeSources>() ?: return
if (res.status != 200) return
res.result?.amap { source ->
try {
@ -68,5 +74,11 @@ class VidSrcTo : ExtractorApi() {
@JsonProperty("result") val result: VidsrctoUrl
)
data class VidsrctoSubtitles(
@JsonProperty("file") val file: String,
@JsonProperty("label") val label: String,
@JsonProperty("kind") val kind: String
)
data class VidsrctoUrl(@JsonProperty("url") val encUrl: String)
}

View file

@ -1,6 +1,7 @@
package com.lagradost.cloudstream3.extractors
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.ErrorLoadingException
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.base64Encode
@ -9,6 +10,7 @@ import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper
import javax.crypto.Cipher
import javax.crypto.spec.SecretKeySpec
import kotlin.run
// Code found in https://github.com/KillerDogeEmpire/vidplay-keys
// special credits to @KillerDogeEmpire for providing key
@ -35,8 +37,25 @@ open class Vidplay : ExtractorApi() {
override val name = "Vidplay"
override val mainUrl = "https://vidplay.site"
override val requiresReferer = true
open val key =
"https://raw.githubusercontent.com/KillerDogeEmpire/vidplay-keys/keys/keys.json"
companion object {
private val keySource = "https://rowdy-avocado.github.io/multi-keys/"
private var keys: List<String>? = null
private suspend fun getKeys(): List<String> {
return keys
?: run {
val res =
app.get(keySource).parsedSafe<KeysData>()
?: throw ErrorLoadingException("Unable to get keys")
keys = res.keys
res.keys
}
}
private data class KeysData(@JsonProperty("vidplay") val keys: List<String>)
}
override suspend fun getUrl(
url: String,
@ -70,10 +89,6 @@ open class Vidplay : ExtractorApi() {
}
private suspend fun getKeys(): List<String> {
return app.get(key).parsed()
}
private suspend fun callFutoken(id: String, url: String): String? {
val script = app.get("$mainUrl/futoken", referer = url).text
val k = "k='(\\S+)'".toRegex().find(script)?.groupValues?.get(1) ?: return null