2022-08-20 07:46:57 +00:00
|
|
|
package com.lagradost.cloudstream3.extractors
|
|
|
|
|
|
|
|
import com.lagradost.cloudstream3.SubtitleFile
|
2022-10-31 00:16:15 +00:00
|
|
|
import com.lagradost.cloudstream3.amap
|
2022-08-20 07:46:57 +00:00
|
|
|
import com.lagradost.cloudstream3.app
|
|
|
|
import com.lagradost.cloudstream3.mvvm.suspendSafeApiCall
|
|
|
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
2023-09-03 21:32:43 +00:00
|
|
|
import com.lagradost.cloudstream3.utils.INFER_TYPE
|
2022-08-20 07:46:57 +00:00
|
|
|
import com.lagradost.cloudstream3.utils.extractorApis
|
|
|
|
import com.lagradost.cloudstream3.utils.getQualityFromName
|
|
|
|
import com.lagradost.cloudstream3.utils.loadExtractor
|
|
|
|
import org.jsoup.Jsoup
|
|
|
|
|
|
|
|
/**
|
|
|
|
* overrideMainUrl is necessary for for other vidstream clones like vidembed.cc
|
|
|
|
* If they diverge it'd be better to make them separate.
|
|
|
|
* */
|
2022-11-06 11:13:45 +00:00
|
|
|
open class Pelisplus(val mainUrl: String) {
|
2022-08-20 07:46:57 +00:00
|
|
|
val name: String = "Vidstream"
|
|
|
|
|
|
|
|
private fun getExtractorUrl(id: String): String {
|
|
|
|
return "$mainUrl/play?id=$id"
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun getDownloadUrl(id: String): String {
|
|
|
|
return "$mainUrl/download?id=$id"
|
|
|
|
}
|
|
|
|
|
|
|
|
private val normalApis = arrayListOf(MultiQuality())
|
|
|
|
|
|
|
|
// https://gogo-stream.com/streaming.php?id=MTE3NDg5
|
|
|
|
suspend fun getUrl(
|
|
|
|
id: String,
|
|
|
|
isCasting: Boolean = false,
|
|
|
|
subtitleCallback: (SubtitleFile) -> Unit,
|
|
|
|
callback: (ExtractorLink) -> Unit
|
|
|
|
): Boolean {
|
|
|
|
try {
|
2022-10-31 00:16:15 +00:00
|
|
|
normalApis.amap { api ->
|
2022-08-20 07:46:57 +00:00
|
|
|
val url = api.getExtractorUrl(id)
|
|
|
|
api.getSafeUrl(url, subtitleCallback = subtitleCallback, callback = callback)
|
|
|
|
}
|
|
|
|
val extractorUrl = getExtractorUrl(id)
|
|
|
|
|
|
|
|
/** Stolen from GogoanimeProvider.kt extractor */
|
|
|
|
suspendSafeApiCall {
|
|
|
|
val link = getDownloadUrl(id)
|
|
|
|
println("Generated vidstream download link: $link")
|
|
|
|
val page = app.get(link, referer = extractorUrl)
|
|
|
|
|
|
|
|
val pageDoc = Jsoup.parse(page.text)
|
|
|
|
val qualityRegex = Regex("(\\d+)P")
|
|
|
|
|
|
|
|
//a[download]
|
2022-10-31 00:16:15 +00:00
|
|
|
pageDoc.select(".dowload > a")?.amap { element ->
|
|
|
|
val href = element.attr("href") ?: return@amap
|
2022-08-20 07:46:57 +00:00
|
|
|
val qual = if (element.text()
|
|
|
|
.contains("HDP")
|
|
|
|
) "1080" else qualityRegex.find(element.text())?.destructured?.component1()
|
|
|
|
.toString()
|
|
|
|
|
|
|
|
if (!loadExtractor(href, link, subtitleCallback, callback)) {
|
|
|
|
callback.invoke(
|
|
|
|
ExtractorLink(
|
|
|
|
this.name,
|
|
|
|
name = this.name,
|
|
|
|
href,
|
|
|
|
page.url,
|
|
|
|
getQualityFromName(qual),
|
2023-09-03 21:32:43 +00:00
|
|
|
type = INFER_TYPE
|
2022-08-20 07:46:57 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
with(app.get(extractorUrl)) {
|
|
|
|
val document = Jsoup.parse(this.text)
|
|
|
|
val primaryLinks = document.select("ul.list-server-items > li.linkserver")
|
|
|
|
//val extractedLinksList: MutableList<ExtractorLink> = mutableListOf()
|
|
|
|
|
|
|
|
// All vidstream links passed to extractors
|
|
|
|
primaryLinks.distinctBy { it.attr("data-video") }.forEach { element ->
|
|
|
|
val link = element.attr("data-video")
|
|
|
|
//val name = element.text()
|
|
|
|
|
|
|
|
// Matches vidstream links with extractors
|
2022-10-31 00:16:15 +00:00
|
|
|
extractorApis.filter { !it.requiresReferer || !isCasting }.amap { api ->
|
2022-08-20 07:46:57 +00:00
|
|
|
if (link.startsWith(api.mainUrl)) {
|
|
|
|
api.getSafeUrl(link, extractorUrl, subtitleCallback, callback)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
} catch (e: Exception) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|