Intial DRM support

This commit is contained in:
KingLucius 2023-09-07 02:51:00 +03:00
parent aefdee3cf1
commit 386e266679

View file

@ -4,9 +4,12 @@ import android.icu.util.Calendar
import android.util.Log import android.util.Log
import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.ui.player.RepoLinkGenerator
import com.lagradost.cloudstream3.utils.AppUtils.parseJson import com.lagradost.cloudstream3.utils.AppUtils.parseJson
import com.lagradost.cloudstream3.utils.AppUtils.toJson import com.lagradost.cloudstream3.utils.AppUtils.toJson
import com.lagradost.cloudstream3.utils.DrmExtractorLink
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.INFER_TYPE
import com.lagradost.cloudstream3.utils.Qualities import com.lagradost.cloudstream3.utils.Qualities
import com.lagradost.nicehttp.requestCreator import com.lagradost.nicehttp.requestCreator
@ -26,7 +29,6 @@ class ElOstoraTV : MainAPI() {
//override val mainPage = generateHomePage() //override val mainPage = generateHomePage()
override val mainPage = generateServersHomePage() override val mainPage = generateServersHomePage()
private fun generateServersHomePage() : List<MainPageData> { private fun generateServersHomePage() : List<MainPageData> {
val homepage = mutableListOf<MainPageData>() val homepage = mutableListOf<MainPageData>()
val data = mapOf( val data = mapOf(
"main" to "1", "main" to "1",
@ -120,20 +122,50 @@ class ElOstoraTV : MainAPI() {
): Boolean { ): Boolean {
Log.d("King", "loadLinks:$data") Log.d("King", "loadLinks:$data")
val data = parseJson<Data>(data) val data = parseJson<Data>(data)
callback.invoke(
ExtractorLink( var fullUrl = fixUrl(data.channel_url)
source = data.channel_title, var key: String = ""
name = data.channel_title, var kid: String = ""
url = fixurl(data.channel_url), val encrypted : Boolean = fullUrl.contains("###")
referer = "",
quality = Qualities.Unknown.value, Log.d("King", "fullUrl:$fullUrl")
isM3u8 = true, if (encrypted)
) {
Log.d("King", "encrypted")
val suffix = fullUrl.split("###")[1].split(":")
key = suffix[0]
kid = suffix[1]
fullUrl = fullUrl.split("###")[0]
Log.d("King", "fullUrl:$fullUrl")
Log.d("King", "key:$key")
Log.d("King", "kid:$kid")
DrmExtractorLink(
source = data.channel_title,
name = data.channel_title,
url = fullUrl,
referer = "",
quality = Qualities.Unknown.value,
key = key,
kid = kid,
kty = "oct",
type = INFER_TYPE,
) )
return true
}
callback.invoke(
ExtractorLink(
source = data.channel_title,
name = data.channel_title,
url = fullUrl,
referer = "",
quality = Qualities.Unknown.value,
type = INFER_TYPE,
)
)
return true return true
} }
private fun fixurl(url: String): String { private fun fixUrl(url: String): String {
return url.substring(url.lastIndexOf("http")) return url.substring(url.lastIndexOf("http"))
} }
private fun getDecoded(payload: Map<String, String>): String { private fun getDecoded(payload: Map<String, String>): String {