cloudstream-extensions-arabic/Shahid4uProvider/src/main/kotlin/com/shahid4u/JWPlayerExtractor.kt

67 lines
2.3 KiB
Kotlin

package com.shahid4u
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.getQualityFromName
open class JWPlayer : ExtractorApi() {
override val name = "JWPlayer"
override val mainUrl = "https://www.jwplayer.com"
override val requiresReferer = false
override suspend fun getUrl(url: String, referer: String?): List<ExtractorLink>? {
val sources = mutableListOf<ExtractorLink>()
with(app.get(url).document) {
val data = this.select("script").mapNotNull { script ->
if (script.data().contains("sources: [")) {
script.data().substringAfter("sources: [")
.substringBefore("],").replace("'", "\"")
} else if (script.data().contains("otakudesu('")) {
script.data().substringAfter("otakudesu('")
.substringBefore("');")
} else {
null
}
}
tryParseJson<List<ResponseSource>>("$data")?.map {
sources.add(
ExtractorLink(
name,
name,
it.file,
referer = url,
quality = getQualityFromName(
Regex("(\\d{3,4}p)").find(it.file)?.groupValues?.get(
1
)
)
)
)
}
}
return sources
}
private data class ResponseSource(
@JsonProperty("file") val file: String,
@JsonProperty("type") val type: String?,
@JsonProperty("label") val label: String?
)
}
class VidHD : JWPlayer() {
override val name = "VidHD"
override val mainUrl = "https://vidhd.fun"
}
class GoStream : JWPlayer() {
override val name = "GoStream"
override val mainUrl = "https://gostream.pro"
}
class Vidbom : JWPlayer() {
override val name = "Vidbom"
override val mainUrl = "https://vidbom.com"
}