Update StreamoUpload.kt

This commit is contained in:
Mater Yoda 2023-07-12 20:36:35 +05:30 committed by GitHub
parent c71e7b915b
commit 52d3c5068a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,11 +1,11 @@
package com.lagradost.cloudstream3.extractors
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper
import java.util.regex.Matcher
import java.util.regex.Pattern
class StreamoUpload1 : StreamoUpload() {
override val mainUrl = "https://streamoupload.xyz"
@ -18,25 +18,27 @@ open class StreamoUpload : ExtractorApi() {
override suspend fun getUrl(url: String, referer: String?): List<ExtractorLink> {
val sources = mutableListOf<ExtractorLink>()
app.get(url, referer = referer).document.select("script").map { script ->
if (script.data().contains("jwplayer(\"vplayer\").setup(")) {
val data = script.data().substringAfter("sources: [")
.substringBefore("],").replace("file", "\"file\"").trim()
tryParseJson<File>(data)?.let {
M3u8Helper.generateM3u8(
name,
it.file,
"$mainUrl/",
).forEach { m3uData -> sources.add(m3uData) }
}
val response = app.get(url, referer = referer)
val scriptPattern: Pattern = Pattern.compile("jwplayer\\(\"vplayer\"\\)\\.setup\\((.*?)\\);", Pattern.DOTALL)
val filePattern: Pattern = Pattern.compile("\"file\"\\s*:\\s*\"(.*?)\"")
val scriptMatcher: Matcher = scriptPattern.matcher(response.body)
while (scriptMatcher.find()) {
val scriptData = scriptMatcher.group(1)
val fileMatcher: Matcher = filePattern.matcher(scriptData)
while (fileMatcher.find()) {
val fileUrl = fileMatcher.group(1)
val videoUrl = "$mainUrl$fileUrl"
sources.add(ExtractorLink(videoUrl))
}
}
return sources
}
private data class File(
@JsonProperty("file") val file: String,
)
}