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.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper import com.lagradost.cloudstream3.utils.M3u8Helper
import kotlin.run
class Moviesapi : Chillx() { class Moviesapi : Chillx() {
override val name = "Moviesapi" override val name = "Moviesapi"
@ -28,17 +29,22 @@ open class Chillx : ExtractorApi() {
override val requiresReferer = true override val requiresReferer = true
companion object { companion object {
private val keySource = "https://rowdy-avocado.github.io/multi-keys/"
private var key: String? = null private var key: String? = null
suspend fun fetchKey(): String { private suspend fun fetchKey(): String {
return if (key != null) { return key
key!! ?: run {
} else { val res =
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") app.get(keySource).parsedSafe<KeysData>()
key = fetch ?: throw ErrorLoadingException("Unable to get keys")
key!! key = res.keys.get(0)
res.keys.get(0)
} }
} }
private data class KeysData(@JsonProperty("chillx") val keys: List<String>)
} }
@Suppress("NAME_SHADOWING") @Suppress("NAME_SHADOWING")
@ -97,11 +103,4 @@ open class Chillx : ExtractorApi() {
it.groupValues[1].toInt(16).toChar().toString() 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 callback: (ExtractorLink) -> Unit
) { ) {
val mediaId = app.get(url).document.selectFirst("ul.episodes li a")?.attr("data-id") ?: return 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 if (res.status != 200) return
res.result?.amap { source -> res.result?.amap { source ->
try { try {
@ -68,5 +74,11 @@ class VidSrcTo : ExtractorApi() {
@JsonProperty("result") val result: VidsrctoUrl @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) data class VidsrctoUrl(@JsonProperty("url") val encUrl: String)
} }

View file

@ -1,6 +1,7 @@
package com.lagradost.cloudstream3.extractors package com.lagradost.cloudstream3.extractors
import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.ErrorLoadingException
import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.base64Encode import com.lagradost.cloudstream3.base64Encode
@ -9,6 +10,7 @@ import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper import com.lagradost.cloudstream3.utils.M3u8Helper
import javax.crypto.Cipher import javax.crypto.Cipher
import javax.crypto.spec.SecretKeySpec import javax.crypto.spec.SecretKeySpec
import kotlin.run
// Code found in https://github.com/KillerDogeEmpire/vidplay-keys // Code found in https://github.com/KillerDogeEmpire/vidplay-keys
// special credits to @KillerDogeEmpire for providing key // special credits to @KillerDogeEmpire for providing key
@ -35,8 +37,25 @@ open class Vidplay : ExtractorApi() {
override val name = "Vidplay" override val name = "Vidplay"
override val mainUrl = "https://vidplay.site" override val mainUrl = "https://vidplay.site"
override val requiresReferer = true 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( override suspend fun getUrl(
url: String, 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? { private suspend fun callFutoken(id: String, url: String): String? {
val script = app.get("$mainUrl/futoken", referer = url).text val script = app.get("$mainUrl/futoken", referer = url).text
val k = "k='(\\S+)'".toRegex().find(script)?.groupValues?.get(1) ?: return null val k = "k='(\\S+)'".toRegex().find(script)?.groupValues?.get(1) ?: return null