fix provider

This commit is contained in:
sora 2023-08-02 06:30:41 +07:00
parent a61bbf7dab
commit 74e1b57559
4 changed files with 75 additions and 90 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers
version = 3
version = 4
cloudstream {

View file

@ -0,0 +1,65 @@
package com.hexated
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.fixTitle
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.fixUrl
import com.lagradost.cloudstream3.utils.getAndUnpack
import com.lagradost.cloudstream3.utils.getQualityFromName
open class Streampai : ExtractorApi() {
override val name = "Streampai"
override val mainUrl = "https://streampai.my.id"
override val requiresReferer = true
override suspend fun getUrl(
url: String,
referer: String?,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
) {
val res = app.get(url, referer = referer).text
val data = getAndUnpack(res)
val sources = data.substringAfter("sources:[").substringBefore("]").replace("\'", "\"")
val tracks = data.substringAfter("\"tracks\":[").substringBefore("]")
tryParseJson<List<Responses>>("[$sources]")?.forEach {
callback.invoke(
ExtractorLink(
this.name,
this.name,
fixUrl(it.file),
"$mainUrl/",
getQualityFromName(it.label),
headers = mapOf(
"Accept" to "video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5",
"Range" to "bytes=0-",
"Sec-Fetch-Dest" to "video",
"Sec-Fetch-Mode" to "no-cors",
)
)
)
}
tryParseJson<List<Responses>>("[$tracks]")?.forEach {
subtitleCallback.invoke(
SubtitleFile(
fixTitle(it.label ?: ""),
fixUrl(it.file),
)
)
}
}
data class Responses(
@JsonProperty("file") val file: String,
@JsonProperty("type") val type: String?,
@JsonProperty("label") val label: String?
)
}

View file

@ -3,7 +3,6 @@ package com.hexated
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
import java.net.URLDecoder
@ -21,15 +20,6 @@ class Minioppai : MainAPI() {
)
companion object {
const val libPaistream = "https://lb.paistream.my.id"
const val paistream = "https://paistream.my.id"
fun getType(t: String): TvType {
return if (t.contains("OVA", true) || t.contains("Special")) TvType.OVA
else if (t.contains("Movie", true)) TvType.AnimeMovie
else TvType.Anime
}
fun getStatus(t: String?): ShowStatus {
return when (t) {
"Completed" -> ShowStatus.Completed
@ -37,7 +27,6 @@ class Minioppai : MainAPI() {
else -> ShowStatus.Completed
}
}
}
override val mainPage = mainPageOf(
@ -138,93 +127,23 @@ class Minioppai : MainAPI() {
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
val document = app.get(data).document
document.select("div.server ul.mirror li a").mapNotNull {
fixUrl(
Jsoup.parse(base64Decode(it.attr("data-em"))).select("iframe").attr("src")
) to it.text()
}.apmap { (link, server) ->
if (link.startsWith(paistream)) {
invokeLocal(link, server, subtitleCallback, callback)
} else {
loadExtractor(fixUrl(decode(link.substringAfter("data="))), mainUrl, subtitleCallback, callback)
}
Jsoup.parse(base64Decode(it.attr("data-em"))).select("iframe").attr("src")
}.apmap { link ->
loadExtractor(
fixUrl(decode(link.substringAfter("data="))),
mainUrl,
subtitleCallback,
callback
)
}
return true
}
private suspend fun invokeLocal(
url: String,
server: String,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
) {
val script = getAndUnpack(app.get(url, referer="$mainUrl/").text)
val sources = script.substringAfter("sources:[").substringBefore("]").replace("'", "\"")
val subtitles = script.substringAfter("\"tracks\":[").substringBefore("]")
tryParseJson<List<Sources>>("[$sources]")?.map { source ->
val pStream = fixLink(source.file ?: return@map, paistream).takeIf {
app.get(
it,
referer = "$paistream/"
).isSuccessful
}
callback.invoke(
ExtractorLink(
server,
server,
pStream ?: fixLink(source.file ?: return@map, libPaistream),
"$paistream/",
getQualityFromName(source.label)
)
)
}
tryParseJson<List<Subtitles>>("[$subtitles]")?.map {
subtitleCallback.invoke(
SubtitleFile(
it.label ?: "",
fixLink(it.file ?: return@map, paistream)
)
)
}
}
private fun decode(input: String): String = URLDecoder.decode(input, "utf-8")
private fun fixLink(url: String, domain: String): String {
if (url.startsWith("http")) {
return url
}
if (url.isEmpty()) {
return ""
}
val startsWithNoHttp = url.startsWith("//")
if (startsWithNoHttp) {
return "https:$url"
} else {
if (url.startsWith('/')) {
return domain + url
}
return "$domain/$url"
}
}
data class Subtitles(
@JsonProperty("file") var file: String? = null,
@JsonProperty("label") var label: String? = null,
)
data class Sources(
@JsonProperty("label") var label: String? = null,
@JsonProperty("file") var file: String? = null,
)
data class SearchResponses(
@JsonProperty("post") var post: ArrayList<Post> = arrayListOf()
)

View file

@ -9,5 +9,6 @@ class MinioppaiPlugin: Plugin() {
override fun load(context: Context) {
// All providers should be added in this manner. Please don't edit the providers list directly.
registerMainAPI(Minioppai())
registerExtractorAPI(Streampai())
}
}