diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/StreamoUpload.kt b/app/src/main/java/com/lagradost/cloudstream3/extractors/StreamoUpload.kt index fb43141d..c3368560 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/StreamoUpload.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/extractors/StreamoUpload.kt @@ -6,6 +6,9 @@ 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 +import org.jsoup.select.Elements class StreamoUpload1 : StreamoUpload() { override val mainUrl = "https://streamoupload.xyz" @@ -18,25 +21,30 @@ open class StreamoUpload : ExtractorApi() { override suspend fun getUrl(url: String, referer: String?): List { val sources = mutableListOf() - app.get(url, referer = referer).document.select("script").map { script -> + val response = app.get(url, referer = referer) + val scriptElements: Elements = response.document.select("script") + val scriptPattern: Pattern = Pattern.compile("jwplayer\\(\"vplayer\"\\).setup\\((.*?)\\);", Pattern.DOTALL) + val filePattern: Pattern = Pattern.compile("\"file\"\\s*:\\s*\"(.*?)\"") + + for (script in scriptElements) { if (script.data().contains("jwplayer(\"vplayer\").setup(")) { - val data = script.data().substringAfter("sources: [") - .substringBefore("],").replace("file", "\"file\"").trim() - tryParseJson(data)?.let { - M3u8Helper.generateM3u8( - name, - it.file, - "$mainUrl/", - ).forEach { m3uData -> sources.add(m3uData) } + val dataMatcher: Matcher = scriptPattern.matcher(script.data()) + if (dataMatcher.find()) { + val data = dataMatcher.group(1) + val fileMatcher: Matcher = filePattern.matcher(data) + + while (fileMatcher.find()) { + val fileUrl = fileMatcher.group(1) + sources.add(ExtractorLink(fileUrl)) + } } } } + return sources } private data class File( @JsonProperty("file") val file: String, ) - - -} +} \ No newline at end of file