forked from recloudstream/cloudstream
Merge pull request #141 from LagradOst/zoro
added sub/dub servers to zoro
This commit is contained in:
commit
86e87fdef2
2 changed files with 54 additions and 20 deletions
|
@ -1,5 +1,6 @@
|
|||
package com.lagradost.cloudstream3.animeproviders
|
||||
|
||||
import androidx.core.net.toUri
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.fasterxml.jackson.module.kotlin.readValue
|
||||
import com.lagradost.cloudstream3.*
|
||||
|
@ -9,6 +10,7 @@ import com.lagradost.cloudstream3.movieproviders.SflixProvider.Companion.toSubti
|
|||
import com.lagradost.cloudstream3.network.WebViewResolver
|
||||
import com.lagradost.cloudstream3.network.get
|
||||
import com.lagradost.cloudstream3.network.text
|
||||
import com.lagradost.cloudstream3.network.url
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Element
|
||||
|
@ -247,6 +249,20 @@ class ZoroProvider : MainAPI() {
|
|||
)
|
||||
}
|
||||
|
||||
private fun getM3u8FromRapidCloud(url: String): String {
|
||||
return get(
|
||||
"$url&autoPlay=1&oa=0",
|
||||
headers = mapOf("Referer" to "https://zoro.to/", "User-Agent" to "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0"),
|
||||
interceptor = WebViewResolver(
|
||||
Regex("""/getSources""")
|
||||
)
|
||||
).text
|
||||
}
|
||||
|
||||
private data class rapidCloudResponse(
|
||||
@JsonProperty("link") val link: String
|
||||
)
|
||||
|
||||
override fun loadLinks(
|
||||
data: String,
|
||||
isCasting: Boolean,
|
||||
|
@ -256,15 +272,31 @@ class ZoroProvider : MainAPI() {
|
|||
|
||||
// Copy pasted from Sflix :)
|
||||
|
||||
val sources = get(
|
||||
val servers: List<Pair<DubStatus, String>> = Jsoup.parse(
|
||||
mapper.readValue<Response>(
|
||||
get("$mainUrl/ajax/v2/episode/servers?episodeId=" + data.split("=")[1]).text
|
||||
).html
|
||||
).select(".server-item[data-type][data-id]").map {
|
||||
Pair(if (it.attr("data-type") == "sub") DubStatus.Subbed else DubStatus.Dubbed, it.attr("data-id")!!)
|
||||
}
|
||||
|
||||
val res = get(
|
||||
data,
|
||||
interceptor = WebViewResolver(
|
||||
Regex("""/getSources""")
|
||||
)
|
||||
).text
|
||||
)
|
||||
|
||||
val mapped = mapper.readValue<SflixProvider.SourceObject>(sources)
|
||||
val recaptchaToken = res.request.url.queryParameter("_token")
|
||||
|
||||
val responses = servers.map {
|
||||
val link = "$mainUrl/ajax/v2/episode/sources?id=${it.second}&_token=$recaptchaToken"
|
||||
Pair(it.first, getM3u8FromRapidCloud(mapper.readValue<rapidCloudResponse>(get(link, res.request.headers.toMap()).text).link))
|
||||
}
|
||||
|
||||
responses.forEach {
|
||||
if (it.second.contains("<html")) return@forEach
|
||||
val mapped = mapper.readValue<SflixProvider.SourceObject>(it.second)
|
||||
val list = listOf(
|
||||
mapped.sources to "source 1",
|
||||
mapped.sources1 to "source 2",
|
||||
|
@ -273,16 +305,18 @@ class ZoroProvider : MainAPI() {
|
|||
)
|
||||
|
||||
list.forEach { subList ->
|
||||
subList.first?.forEach {
|
||||
it?.toExtractorLink(this, subList.second)?.forEach(callback)
|
||||
subList.first?.forEach { a ->
|
||||
a?.toExtractorLink(this, subList.second + " - ${it.first}")?.forEach(callback)
|
||||
}
|
||||
}
|
||||
|
||||
mapped.tracks?.forEach {
|
||||
it?.toSubtitleFile()?.let { subtitleFile ->
|
||||
mapped.tracks?.forEach { track ->
|
||||
track?.toSubtitleFile()?.let { subtitleFile ->
|
||||
subtitleCallback.invoke(subtitleFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ class WebViewResolver(val interceptUrl: Regex) : Interceptor {
|
|||
@SuppressLint("SetJavaScriptEnabled")
|
||||
suspend fun resolveUsingWebView(request: Request): Request? {
|
||||
val url = request.url.toString()
|
||||
val headers = request.headers
|
||||
println("Initial web-view request: $url")
|
||||
var webView: WebView? = null
|
||||
|
||||
|
@ -77,8 +78,7 @@ class WebViewResolver(val interceptUrl: Regex) : Interceptor {
|
|||
handler?.proceed() // Ignore ssl issues
|
||||
}
|
||||
}
|
||||
|
||||
webView?.loadUrl(url)
|
||||
webView?.loadUrl(url, headers.toMap())
|
||||
}
|
||||
|
||||
var loop = 0
|
||||
|
|
Loading…
Reference in a new issue