mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
fixed some sources TimefourTv
This commit is contained in:
parent
5feaa12f44
commit
b911503a6c
3 changed files with 125 additions and 52 deletions
|
@ -1,5 +1,5 @@
|
|||
// use an integer for version numbers
|
||||
version = 3
|
||||
version = 4
|
||||
|
||||
|
||||
cloudstream {
|
||||
|
|
|
@ -4,10 +4,9 @@ import com.lagradost.cloudstream3.*
|
|||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.Qualities
|
||||
import org.jsoup.nodes.Element
|
||||
import java.net.URI
|
||||
|
||||
class TimefourTv : MainAPI() {
|
||||
override var mainUrl = "https://time4tv.stream"
|
||||
open class TimefourTv : MainAPI() {
|
||||
final override var mainUrl = "https://time4tv.stream"
|
||||
override var name = "Time4tv"
|
||||
override val hasDownloadSupport = false
|
||||
override val hasMainPage = true
|
||||
|
@ -30,7 +29,7 @@ class TimefourTv : MainAPI() {
|
|||
): HomePageResponse {
|
||||
val items = mutableListOf<HomePageList>()
|
||||
val nonPaged = request.name != "All Channels" && page <= 1
|
||||
if(nonPaged) {
|
||||
if (nonPaged) {
|
||||
val res = app.get("${request.data}.php").document
|
||||
val home = res.select("div.tab-content ul li").mapNotNull {
|
||||
it.toSearchResult()
|
||||
|
@ -97,51 +96,6 @@ class TimefourTv : MainAPI() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun getBaseUrl(url: String): String {
|
||||
return URI(url).let {
|
||||
"${it.scheme}://${it.host}"
|
||||
}
|
||||
}
|
||||
|
||||
private var mainServer: String? = null
|
||||
private suspend fun getLink(url: String): String? {
|
||||
val (channel, iframe) = if (url.contains("width=")) {
|
||||
val doc = app.get(url, referer = "$mainUrl/").document
|
||||
val tempIframe = doc.selectFirst("iframe")?.attr("src") ?: return null
|
||||
val doctwo = app.get(fixUrl(tempIframe), referer = url).text
|
||||
listOf(
|
||||
tempIframe.split("?").last().removePrefix("id=").replace(".php", ""),
|
||||
doctwo.substringAfterLast("<iframe src=\"").substringBefore("'+")
|
||||
)
|
||||
} else {
|
||||
val doc = app.get(url, referer = "$mainUrl/").text
|
||||
listOf(
|
||||
url.split("?").last().removePrefix("id=").replace(".php", ""),
|
||||
doc.substringAfterLast("<iframe src=\"").substringBefore("'+")
|
||||
)
|
||||
}
|
||||
|
||||
val linkFirst = "$iframe$channel.php"
|
||||
val refFirst = getBaseUrl(url)
|
||||
val docSecond = app.get(fixUrl(linkFirst), referer = refFirst).document
|
||||
val iframeSecond = docSecond.select("iframe:last-child, iframe#thatframe").attr("src")
|
||||
|
||||
val refSecond = getBaseUrl(linkFirst)
|
||||
val docThird = app.get(fixUrl(iframeSecond), referer = "$refSecond/")
|
||||
mainServer = getBaseUrl(iframeSecond)
|
||||
|
||||
return Regex("""source:['|"](\S+.m3u8)['|"],""").find(docThird.text)?.groupValues?.getOrNull(
|
||||
1
|
||||
) ?: run {
|
||||
val scriptData =
|
||||
docThird.document.selectFirst("div#player")?.nextElementSibling()?.data()
|
||||
?.substringAfterLast("return(")?.substringBefore(".join")
|
||||
scriptData?.removeSurrounding("[", "]")?.replace("\"", "")?.split(",")
|
||||
?.joinToString("")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override suspend fun loadLinks(
|
||||
data: String,
|
||||
isCasting: Boolean,
|
||||
|
@ -154,7 +108,7 @@ class TimefourTv : MainAPI() {
|
|||
} else {
|
||||
data
|
||||
} ?: throw ErrorLoadingException()
|
||||
getLink(fixUrl(link))?.let { m3uLink ->
|
||||
TimefourTvExtractor().getLink(fixUrl(link))?.let { m3uLink ->
|
||||
callback.invoke(
|
||||
ExtractorLink(
|
||||
this.name,
|
||||
|
@ -162,7 +116,7 @@ class TimefourTv : MainAPI() {
|
|||
m3uLink,
|
||||
referer = "$mainServer/",
|
||||
quality = Qualities.Unknown.value,
|
||||
isM3u8 = true
|
||||
isM3u8 = true,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
119
TimefourTv/src/main/kotlin/com/hexated/TimefourTvExtractor.kt
Normal file
119
TimefourTv/src/main/kotlin/com/hexated/TimefourTvExtractor.kt
Normal file
|
@ -0,0 +1,119 @@
|
|||
package com.hexated
|
||||
|
||||
import com.lagradost.cloudstream3.app
|
||||
import com.lagradost.cloudstream3.fixUrl
|
||||
import com.lagradost.cloudstream3.utils.getAndUnpack
|
||||
import java.net.URI
|
||||
|
||||
var mainServer: String? = null
|
||||
|
||||
class TimefourTvExtractor : TimefourTv() {
|
||||
|
||||
private fun getBaseUrl(url: String): String {
|
||||
return URI(url).let {
|
||||
"${it.scheme}://${it.host}"
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun getSportLink(url: String): String? {
|
||||
val iframe = app.get(url, referer = "$mainUrl/").document.select("iframe").attr("src")
|
||||
.let { fixUrl(it) }
|
||||
val ref = getBaseUrl(url)
|
||||
val data = app.get(iframe, referer = ref).document.select("script")
|
||||
.find { it.data().contains("eval(function(p,a,c,k,e,d)") }?.data()
|
||||
.let { getAndUnpack(it.toString()) }
|
||||
|
||||
mainServer = getBaseUrl(iframe)
|
||||
|
||||
return Regex("var\\ssrc=['|\"](.*?.m3u8.*?)['|\"];").find(data)?.groupValues?.get(1)
|
||||
|
||||
}
|
||||
|
||||
private suspend fun getCricfreeLink(url: String, ref: String): String? {
|
||||
val doc = app.get(url, referer = ref).document
|
||||
val iframe = doc.select("iframe").attr("src")
|
||||
val channel = iframe.split("/").last().removeSuffix(".php")
|
||||
val refTwo = getBaseUrl(url)
|
||||
|
||||
val docTwo =
|
||||
app.get(fixUrl(iframe), referer = refTwo).document.selectFirst("script[src*=embed.]")
|
||||
?.attr("src")
|
||||
val refThree = getBaseUrl(iframe)
|
||||
val linkTwo = fixUrl("${docTwo?.replace(".js", ".php")}?player=desktop&live=$channel")
|
||||
|
||||
val docThree = app.get(
|
||||
linkTwo,
|
||||
referer = "$refThree/",
|
||||
)
|
||||
mainServer = getBaseUrl(linkTwo)
|
||||
|
||||
val scriptData = docThree.document.selectFirst("div#player")?.nextElementSibling()?.data()
|
||||
?.substringAfterLast("return(")?.substringBefore(".join")
|
||||
val link = scriptData?.removeSurrounding("[", "]")?.replace("\"", "")?.split(",")
|
||||
?.joinToString("") ?: return null
|
||||
return app.get(link, referer = "$mainUrl/").url
|
||||
}
|
||||
|
||||
private suspend fun getFootyhunter(url: String, ref: String): String? {
|
||||
val doc = app.get(url, referer = ref).document
|
||||
val iframe = doc.selectFirst("iframe")?.attr("src") ?: return null
|
||||
val referer = getBaseUrl(url)
|
||||
val docTwo = app.get(fixUrl(iframe), referer = "$referer/").text
|
||||
mainServer = getBaseUrl(iframe)
|
||||
val link = Regex("""source:['|"](\S+.m3u8)['|"],""").find(docTwo)?.groupValues?.getOrNull(1)
|
||||
?: return null
|
||||
return app.get(link, referer = "$mainUrl/").url
|
||||
}
|
||||
|
||||
suspend fun getLink(url: String): String? {
|
||||
|
||||
if (url.contains("sportzonline") || url.contains("sportsonline")) {
|
||||
return getSportLink(url)
|
||||
}
|
||||
|
||||
val (channel, iframe) = if (url.contains("width=")) {
|
||||
val doc = app.get(url, referer = "$mainUrl/").document
|
||||
val tempIframe = doc.selectFirst("iframe")?.attr("src") ?: return null
|
||||
|
||||
if (tempIframe.contains("cricfree")) {
|
||||
return getCricfreeLink(tempIframe, getBaseUrl(url))
|
||||
}
|
||||
if (tempIframe.contains("footyhunter")) {
|
||||
return getFootyhunter(tempIframe, getBaseUrl(url))
|
||||
}
|
||||
|
||||
val doctwo = app.get(fixUrl(tempIframe), referer = url).text
|
||||
listOf(
|
||||
tempIframe.split("?").last().removePrefix("id=").replace(".php", ""),
|
||||
doctwo.substringAfterLast("<iframe src=\"").substringBefore("'+")
|
||||
)
|
||||
} else {
|
||||
val doc = app.get(url, referer = "$mainUrl/").text
|
||||
listOf(
|
||||
url.split("?").last().removePrefix("id=").replace(".php", ""),
|
||||
doc.substringAfterLast("<iframe src=\"").substringBefore("'+")
|
||||
)
|
||||
}
|
||||
|
||||
val linkFirst = "$iframe$channel.php"
|
||||
val refFirst = getBaseUrl(url)
|
||||
|
||||
val docSecond = app.get(fixUrl(linkFirst), referer = refFirst).document
|
||||
val iframeSecond = docSecond.select("iframe:last-child, iframe#thatframe").attr("src")
|
||||
|
||||
val refSecond = getBaseUrl(linkFirst)
|
||||
val docThird = app.get(fixUrl(iframeSecond), referer = "$refSecond/")
|
||||
mainServer = getBaseUrl(iframeSecond)
|
||||
|
||||
return Regex("""source:['|"](\S+.m3u8)['|"],""").find(docThird.text)?.groupValues?.getOrNull(
|
||||
1
|
||||
) ?: run {
|
||||
val scriptData =
|
||||
docThird.document.selectFirst("div#player")?.nextElementSibling()?.data()
|
||||
?.substringAfterLast("return(")?.substringBefore(".join")
|
||||
scriptData?.removeSurrounding("[", "]")?.replace("\"", "")?.split(",")
|
||||
?.joinToString("")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue