mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Update StreamoUpload.kt
This commit is contained in:
parent
c71e7b915b
commit
52d3c5068a
1 changed files with 17 additions and 15 deletions
|
@ -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,
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue