mirror of
https://github.com/recloudstream/cloudstream-extensions-multilingual.git
synced 2024-08-15 03:15:14 +00:00
StarLive fix
This commit is contained in:
parent
96dc0371c4
commit
50d25fdef0
1 changed files with 62 additions and 53 deletions
|
@ -3,20 +3,34 @@ package com.lagradost
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.utils.*
|
import com.lagradost.cloudstream3.utils.*
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
||||||
import org.jsoup.nodes.Element
|
|
||||||
|
|
||||||
|
|
||||||
class StarLiveProvider : MainAPI() {
|
class StarLiveProvider : MainAPI() {
|
||||||
override var lang = "it"
|
|
||||||
override var mainUrl = "https://starlive.xyz"
|
override var mainUrl = "https://starlive.xyz"
|
||||||
override var name = "StarLive"
|
override var name = "StarLive"
|
||||||
override val hasMainPage = true
|
override val hasMainPage = true
|
||||||
|
override var lang = "it"
|
||||||
override val hasChromecastSupport = true
|
override val hasChromecastSupport = true
|
||||||
override val supportedTypes = setOf(
|
override val supportedTypes = setOf(TvType.Live)
|
||||||
TvType.Live,
|
|
||||||
|
private data class LinkParser(
|
||||||
|
@JsonProperty("link") val link: String,
|
||||||
|
@JsonProperty("lang") val language: String,
|
||||||
|
@JsonProperty("name") val name: String
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private data class MatchDataParser(
|
||||||
|
@JsonProperty("time") val time: String,
|
||||||
|
@JsonProperty("poster") val poster: String
|
||||||
|
)
|
||||||
|
|
||||||
|
private data class MatchParser(
|
||||||
|
@JsonProperty("linkData") val linkData: List<LinkParser>,
|
||||||
|
@JsonProperty("matchData") val MatchData: MatchDataParser
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
|
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
|
||||||
val document = app.get(mainUrl).document
|
val document = app.get(mainUrl).document
|
||||||
val sections = document.select("div.panel")
|
val sections = document.select("div.panel")
|
||||||
|
@ -25,24 +39,34 @@ class StarLiveProvider : MainAPI() {
|
||||||
return HomePageResponse(sections.map { sport ->
|
return HomePageResponse(sections.map { sport ->
|
||||||
val dayMatch = sport.previousElementSiblings().toList().first { it.`is`("h3") }.text()
|
val dayMatch = sport.previousElementSiblings().toList().first { it.`is`("h3") }.text()
|
||||||
val categoryName = sport.selectFirst("h4")?.text() ?: "Other"
|
val categoryName = sport.selectFirst("h4")?.text() ?: "Other"
|
||||||
val showsList = sport.select("tr").takeWhile { it.text().contains("Player").not() }.filter { it.hasAttr("class")}.drop(1)
|
|
||||||
val shows = showsList.groupBy { it.text().substringBeforeLast(" ")}.map { matchs ->
|
|
||||||
val posterUrl = fixUrl(sport.selectFirst("h4")?.attr("style")?.substringAfter("(")?.substringBefore(")")?:"")
|
|
||||||
val href = mutableListOf<String>()
|
|
||||||
val hasDate = matchs.key.contains(":")
|
|
||||||
val matchName = if (hasDate){matchs.key.substringAfter(" ")} else{matchs.key}
|
|
||||||
|
|
||||||
matchs.value.map { match ->
|
val showsList = sport.select("tr").takeWhile { it.text().contains("Player").not() }
|
||||||
|
.filter { it.hasAttr("class") }.drop(1)
|
||||||
|
|
||||||
|
val shows = showsList.groupBy { it.text().substringBeforeLast(" ") }.map { matchs ->
|
||||||
|
val posterUrl = fixUrl(
|
||||||
|
sport.selectFirst("h4")?.attr("style")
|
||||||
|
?.substringAfter("(")?.substringBefore(")") ?: ""
|
||||||
|
)
|
||||||
|
val hasDate = matchs.key.contains(":")
|
||||||
|
val matchName = if (hasDate) { matchs.key.substringAfter(" ")}
|
||||||
|
else { matchs.key }
|
||||||
|
|
||||||
|
val href = matchs.value.map { match ->
|
||||||
val linkUrl = fixUrl(match.selectFirst("a")?.attr("href") ?: "")
|
val linkUrl = fixUrl(match.selectFirst("a")?.attr("href") ?: "")
|
||||||
val lang = match.attr("class")
|
val lang = match.attr("class")
|
||||||
href.add( "{\"link\": \"$linkUrl\", \"lang\":\"$lang\", \"name\": \"$matchName\"}")
|
LinkParser(linkUrl, lang, matchName)
|
||||||
}
|
}
|
||||||
|
|
||||||
val date = if (hasDate){dayMatch + " - " + matchs.key.substringBefore(" ")} else{dayMatch}
|
val date = if (hasDate) {
|
||||||
|
dayMatch + " - " + matchs.key.substringBefore(" ")
|
||||||
|
} else {
|
||||||
|
dayMatch
|
||||||
|
}
|
||||||
|
|
||||||
LiveSearchResponse(
|
LiveSearchResponse(
|
||||||
matchName,
|
matchName,
|
||||||
"{\"linkData\": $href , \"matchData\":{\"time\": \"$date\", \"poster\":\"$posterUrl\"}}",
|
MatchParser(href, MatchDataParser(date, posterUrl)).toJson(),
|
||||||
this@StarLiveProvider.name,
|
this@StarLiveProvider.name,
|
||||||
TvType.Live,
|
TvType.Live,
|
||||||
posterUrl,
|
posterUrl,
|
||||||
|
@ -57,62 +81,47 @@ class StarLiveProvider : MainAPI() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private data class LinkParser(
|
|
||||||
@JsonProperty("link") val link: String,
|
|
||||||
@JsonProperty("lang") val language: String,
|
|
||||||
@JsonProperty("name") val name: String
|
|
||||||
)
|
|
||||||
private data class MatchDataParser(
|
|
||||||
@JsonProperty("time") val time: String,
|
|
||||||
@JsonProperty("poster") val poster: String
|
|
||||||
)
|
|
||||||
private data class MatchParser(
|
|
||||||
@JsonProperty("linkData") val linkData: List<LinkParser>,
|
|
||||||
@JsonProperty("matchData") val MatchData: MatchDataParser
|
|
||||||
)
|
|
||||||
|
|
||||||
override suspend fun load(url: String): LoadResponse {
|
override suspend fun load(url: String): LoadResponse {
|
||||||
val matchdata = tryParseJson<MatchParser>(url)
|
val matchdata = tryParseJson<MatchParser>(url)
|
||||||
val poster = matchdata?.MatchData?.poster
|
val poster = matchdata?.MatchData?.poster
|
||||||
val Matchstart = matchdata?.MatchData?.time
|
val matchstart = matchdata?.MatchData?.time
|
||||||
return LiveStreamLoadResponse(
|
return LiveStreamLoadResponse(
|
||||||
dataUrl = url,
|
dataUrl = url,
|
||||||
url = matchdata?.linkData?.firstOrNull()?.link ?: mainUrl,
|
url = matchdata?.linkData?.firstOrNull()?.link ?: mainUrl,
|
||||||
name = matchdata?.linkData?.firstOrNull()?.name ?: mainUrl,
|
name = matchdata?.linkData?.firstOrNull()?.name ?: mainUrl,
|
||||||
posterUrl = poster,
|
posterUrl = poster,
|
||||||
plot = Matchstart,
|
plot = matchstart,
|
||||||
apiName = this@StarLiveProvider.name
|
apiName = this@StarLiveProvider.name
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private suspend fun extractVideoLinks(
|
private suspend fun extractVideoLinks(
|
||||||
data: LinkParser,
|
data: LinkParser,
|
||||||
callback: (ExtractorLink) -> Unit
|
callback: (ExtractorLink) -> Unit
|
||||||
) {
|
) {
|
||||||
val linktoStream = "https:"+app.get(data.link).document.selectFirst("iframe")!!.attr("src")
|
val linktoStream = fixUrl(app.get(data.link).document.selectFirst("iframe")!!.attr("src"))
|
||||||
|
|
||||||
val referrerLink = if (linktoStream.contains("starlive")) {
|
val referrerLink = if (linktoStream.contains("starlive")) {
|
||||||
app.get(linktoStream, referer = data.link).document.selectFirst("iframe")?.attr("src")?:""
|
app.get(linktoStream, referer = data.link).document.selectFirst("iframe")?.attr("src")
|
||||||
}
|
?: ""
|
||||||
else{
|
} else {
|
||||||
linktoStream
|
linktoStream
|
||||||
}
|
}
|
||||||
val packed = when (linktoStream.contains("starlive")) {
|
val packed = when (linktoStream.contains("starlive")) {
|
||||||
true -> app.get(referrerLink, referer = linktoStream).document.select("script")[6].childNodes()[0].toString()
|
true -> app.get(
|
||||||
false -> app.get(linktoStream, referer = data.link).document.select("script").select("script")[6].childNodes()[0].toString()
|
referrerLink,
|
||||||
|
referer = linktoStream
|
||||||
|
).document.select("script").toString()
|
||||||
|
false -> app.get(linktoStream, referer = data.link).document.select("script")
|
||||||
|
.select("script").toString()
|
||||||
}
|
}
|
||||||
val streamurl = getAndUnpack(packed).substringAfter("var src=\"").substringBefore("\"")
|
val streamUrl = getAndUnpack(packed).substringAfter("var src=\"").substringBefore("\"")
|
||||||
callback(
|
callback(
|
||||||
ExtractorLink(
|
ExtractorLink(
|
||||||
source = this.name,
|
source = this.name,
|
||||||
name = data.name + " - " + data.language,
|
name = data.name + " - " + data.language,
|
||||||
url = streamurl,
|
url = streamUrl,
|
||||||
quality = 0,
|
quality = Qualities.Unknown.value,
|
||||||
referer = referrerLink,
|
referer = referrerLink,
|
||||||
isM3u8 = true
|
isM3u8 = true
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue