mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
fix #494
This commit is contained in:
parent
fd5d4afc22
commit
1f461af2a1
4 changed files with 135 additions and 309 deletions
|
@ -21,7 +21,7 @@ class Samehadaku : MainAPI() {
|
||||||
TvType.AnimeMovie,
|
TvType.AnimeMovie,
|
||||||
TvType.OVA
|
TvType.OVA
|
||||||
)
|
)
|
||||||
private val interceptor = CloudflareKiller()
|
private val interceptor by lazy { CloudflareKiller() }
|
||||||
companion object {
|
companion object {
|
||||||
const val acefile = "https://acefile.co"
|
const val acefile = "https://acefile.co"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 20
|
version = 21
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
|
|
|
@ -1,220 +1,182 @@
|
||||||
package com.hexated
|
package com.hexated
|
||||||
|
|
||||||
import com.hexated.TimefourTvExtractor.getBaseUrl
|
|
||||||
import com.hexated.TimefourTvExtractor.getLink
|
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.M3u8Helper
|
import com.lagradost.cloudstream3.utils.M3u8Helper
|
||||||
import org.jsoup.Jsoup
|
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import java.net.URI
|
||||||
|
|
||||||
open class TimefourTv : MainAPI() {
|
class TimefourTv : MainAPI() {
|
||||||
final override var mainUrl = "https://time4tv.stream"
|
override var mainUrl = "https://dlhd.sx"
|
||||||
var daddyUrl = "https://daddylivehd.com"
|
|
||||||
override var name = "Time4tv"
|
override var name = "Time4tv"
|
||||||
override val hasDownloadSupport = false
|
override val hasDownloadSupport = false
|
||||||
override val hasMainPage = true
|
override val hasMainPage = true
|
||||||
private val time4tvPoster = "$mainUrl/images/logo.png"
|
|
||||||
override val supportedTypes = setOf(
|
override val supportedTypes = setOf(
|
||||||
TvType.Live
|
TvType.Live
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val homePoster =
|
||||||
|
"https://cdn.discordapp.com/attachments/1109266606292488297/1193060449193840681/Screenshot_2024-01-06_at_12-14-16_Logo_Maker_Used_By_2.3_Million_Startups.png"
|
||||||
|
private val detailPoster =
|
||||||
|
"https://cdn.discordapp.com/attachments/1109266606292488297/1193060448929595454/Screenshot_2024-01-06_at_12-13-02_Logo_Maker_Used_By_2.3_Million_Startups.png"
|
||||||
|
|
||||||
override val mainPage = mainPageOf(
|
override val mainPage = mainPageOf(
|
||||||
// "$mainUrl/tv-channels" to "All Channels",
|
"$mainUrl/24-7-channels.php" to "24/7 Channels",
|
||||||
// "$mainUrl/usa-channels" to "USA Channels",
|
"$mainUrl/schedule/schedule-generated.json" to "Schedule Channels"
|
||||||
// "$mainUrl/uk-channels" to "UK Channels",
|
|
||||||
// "$mainUrl/sports-channels" to "Sport Channels",
|
|
||||||
// "$mainUrl/live-sports-streams" to "Live Sport Channels",
|
|
||||||
// "$mainUrl/news-channels" to "News Channels",
|
|
||||||
// "$mainUrl/schedule.php" to "Schedule",
|
|
||||||
"$daddyUrl/24-7-channels.php" to "DaddyHD Channels"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun fixDetailLink(link: String?): String? {
|
|
||||||
if (link == null) return null
|
|
||||||
return if (link.startsWith("/")) "$daddyUrl$link" else link
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun getMainPage(
|
override suspend fun getMainPage(
|
||||||
page: Int,
|
page: Int,
|
||||||
request: MainPageRequest
|
request: MainPageRequest
|
||||||
): HomePageResponse {
|
): HomePageResponse {
|
||||||
val items = mutableListOf<HomePageList>()
|
val items = mutableListOf<HomePageList>()
|
||||||
val nonPaged = request.name != "All Channels" && page <= 1
|
if (request.name == "24/7 Channels") {
|
||||||
if (nonPaged) {
|
val req = app.get(request.data)
|
||||||
val res = app.get("${request.data}.php").document
|
mainUrl = getBaseUrl(req.url)
|
||||||
val home = res.select("div.tab-content ul li").mapNotNull {
|
val res = req.document
|
||||||
it.toSearchResult()
|
val channels = res.select("div.grid-container div.grid-item").mapNotNull {
|
||||||
|
it.toSearchResponse()
|
||||||
}
|
}
|
||||||
if (home.isNotEmpty()) items.add(HomePageList(request.name, home, true))
|
if (channels.isNotEmpty()) items.add(HomePageList(request.name, channels, true))
|
||||||
}
|
} else {
|
||||||
if (request.name == "All Channels") {
|
val res = app.get(request.data).parsedSafe<Map<String, Map<String, ArrayList<Items>>>>()
|
||||||
val res = if (page == 1) {
|
res?.forEach { tag ->
|
||||||
app.get("${request.data}.php").document
|
val header = tag.key
|
||||||
} else {
|
val channels = tag.value.mapNotNull {
|
||||||
app.get("${request.data}${page.minus(1)}.php").document
|
LiveSearchResponse(
|
||||||
|
it.key,
|
||||||
|
Item(it.key, items = it.value.toJson()).toJson(),
|
||||||
|
this@TimefourTv.name,
|
||||||
|
TvType.Live,
|
||||||
|
posterUrl = homePoster,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (channels.isNotEmpty()) items.add(HomePageList(header, channels, true))
|
||||||
}
|
}
|
||||||
val home = res.select("div.tab-content ul li").mapNotNull {
|
|
||||||
it.toSearchResult()
|
|
||||||
}
|
|
||||||
if (home.isNotEmpty()) items.add(HomePageList(request.name, home, true))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nonPaged && request.name == "DaddyHD Channels") {
|
return newHomePageResponse(items, false)
|
||||||
val res = app.get(request.data).document
|
|
||||||
val channelDaddy = res.select("div.grid-container div.grid-item").mapNotNull {
|
|
||||||
it.toSearchDaddy()
|
|
||||||
}
|
|
||||||
if (channelDaddy.isNotEmpty()) items.add(HomePageList(request.name, channelDaddy, true))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nonPaged && request.name == "Schedule") {
|
|
||||||
val res = app.get(request.data).document
|
|
||||||
val schedule = res.select("div.search_p h1,div.search_p h2").mapNotNull {
|
|
||||||
it.toSearchSchedule()
|
|
||||||
}
|
|
||||||
if (schedule.isNotEmpty()) items.add(HomePageList(request.name, schedule, true))
|
|
||||||
}
|
|
||||||
|
|
||||||
return newHomePageResponse(items)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Element.toSearchDaddy(): LiveSearchResponse? {
|
private fun Element.toSearchResponse(): LiveSearchResponse {
|
||||||
|
val title = this.select("strong").text()
|
||||||
|
val href = fixUrl(this.select("a").attr("href"))
|
||||||
return LiveSearchResponse(
|
return LiveSearchResponse(
|
||||||
this.select("strong").text() ?: return null,
|
title,
|
||||||
fixDetailLink(this.select("a").attr("href")) ?: return null,
|
Item(title, href).toJson(),
|
||||||
this@TimefourTv.name,
|
this@TimefourTv.name,
|
||||||
TvType.Live,
|
TvType.Live,
|
||||||
posterUrl = time4tvPoster
|
posterUrl = homePoster,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Element.toSearchSchedule(): LiveSearchResponse? {
|
|
||||||
return LiveSearchResponse(
|
|
||||||
this.text() ?: return null,
|
|
||||||
this.text(),
|
|
||||||
this@TimefourTv.name,
|
|
||||||
TvType.Live,
|
|
||||||
posterUrl = time4tvPoster
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun Element.toSearchResult(): LiveSearchResponse? {
|
|
||||||
return LiveSearchResponse(
|
|
||||||
this.selectFirst("div.channelName")?.text() ?: return null,
|
|
||||||
fixUrl(this.selectFirst("a")!!.attr("href")),
|
|
||||||
this@TimefourTv.name,
|
|
||||||
TvType.Live,
|
|
||||||
fixUrlNull(this.selectFirst("img")?.attr("src")),
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun search(query: String): List<SearchResponse> {
|
override suspend fun search(query: String): List<SearchResponse> {
|
||||||
val document = app.get("$daddyUrl/24-7-channels.php").document
|
val document = app.get("$mainUrl/24-7-channels.php").document
|
||||||
return document.select("div.grid-container div.grid-item:contains($query)").mapNotNull {
|
return document.select("div.grid-container div.grid-item:contains($query)").mapNotNull {
|
||||||
it.toSearchDaddy()
|
it.toSearchResponse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun loadSchedule(url: String): LoadResponse {
|
|
||||||
val name = url.removePrefix("$mainUrl/")
|
override suspend fun load(url: String): LoadResponse {
|
||||||
val doc = app.get("$mainUrl/schedule.php").document
|
val data = AppUtils.parseJson<Item>(url)
|
||||||
val episode = mutableListOf<Episode>()
|
val episodes = if (data.items.isNullOrEmpty()) {
|
||||||
doc.selectFirst("div.search_p h2:contains($name)")?.nextElementSiblings()?.toString()
|
listOf(Episode(arrayListOf(Channels(data.title, data.url)).toJson()))
|
||||||
?.substringBefore("<h2")?.split("<br>")?.map {
|
} else {
|
||||||
val desc = it.substringBefore("<span").replace(Regex("</?strong>"), "").replace("<p>", "")
|
val items = AppUtils.parseJson<ArrayList<Items>>(data.items)
|
||||||
Jsoup.parse(it).select("span").map { ele ->
|
items.mapNotNull {
|
||||||
val title = ele.select("a").text()
|
Episode(
|
||||||
val href = ele.select("a").attr("href")
|
data = it.channels?.toJson() ?: return@mapNotNull null,
|
||||||
episode.add(
|
name = "${it.event} - Live",
|
||||||
Episode(
|
description = it.time,
|
||||||
href,
|
posterUrl = detailPoster,
|
||||||
title,
|
)
|
||||||
description = desc,
|
|
||||||
posterUrl = time4tvPoster
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return newTvSeriesLoadResponse(name, url, TvType.TvSeries, episode) {
|
|
||||||
}
|
}
|
||||||
}
|
return newTvSeriesLoadResponse(
|
||||||
|
data.title ?: "",
|
||||||
override suspend fun load(url: String): LoadResponse? {
|
url,
|
||||||
|
TvType.TvSeries,
|
||||||
val res = app.get(url)
|
episodes = episodes
|
||||||
daddyUrl = getBaseUrl(res.url)
|
) {
|
||||||
if (!res.isSuccessful) return loadSchedule(url)
|
posterUrl = homePoster
|
||||||
|
|
||||||
val document = res.document
|
|
||||||
val title =
|
|
||||||
document.selectFirst("div.channelHeading h1")?.text() ?: document.selectFirst("title")
|
|
||||||
?.text()?.substringBefore("HD")?.trim() ?: return null
|
|
||||||
val poster =
|
|
||||||
fixUrlNull(document.selectFirst("meta[property=\"og:image\"]")?.attr("content")) ?: time4tvPoster
|
|
||||||
val description = document.selectFirst("div.tvText")?.text()
|
|
||||||
?: document.selectFirst("meta[name=description]")?.attr("content") ?: return null
|
|
||||||
val episodes = document.selectFirst("div.playit")?.attr("onclick")?.substringAfter("open('")
|
|
||||||
?.substringBefore("',")?.let { link ->
|
|
||||||
val doc = app.get(link).document.selectFirst("div.tv_palyer iframe")?.attr("src")
|
|
||||||
?.let { iframe ->
|
|
||||||
app.get(fixUrl(iframe), referer = link).document
|
|
||||||
}
|
|
||||||
if (doc?.select("div.stream_button").isNullOrEmpty()) {
|
|
||||||
doc?.select("iframe")?.mapIndexed { eps, ele ->
|
|
||||||
Episode(
|
|
||||||
fixUrl(ele.attr("src")),
|
|
||||||
"Server ${eps.plus(1)}"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
doc?.select("div.stream_button a")?.map {
|
|
||||||
Episode(
|
|
||||||
fixUrl(it.attr("href")),
|
|
||||||
it.text()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} ?: listOf(
|
|
||||||
newEpisode(
|
|
||||||
document.selectFirst("div#content iframe#thatframe")?.attr("src") ?: return null
|
|
||||||
) {
|
|
||||||
this.name = title
|
|
||||||
}
|
|
||||||
) ?: throw ErrorLoadingException("Refresh page")
|
|
||||||
return newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes) {
|
|
||||||
this.posterUrl = poster
|
|
||||||
this.plot = description
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun loadLinks(
|
override suspend fun loadLinks(
|
||||||
data: String,
|
data: String,
|
||||||
isCasting: Boolean,
|
isCasting: Boolean,
|
||||||
subtitleCallback: (SubtitleFile) -> Unit,
|
subtitleCallback: (SubtitleFile) -> Unit,
|
||||||
callback: (ExtractorLink) -> Unit
|
callback: (ExtractorLink) -> Unit
|
||||||
): Boolean {
|
): Boolean {
|
||||||
|
|
||||||
val link = when {
|
val json = AppUtils.parseJson<ArrayList<Channels>>(data)
|
||||||
data.contains("/channel") -> app.get(data).document.selectFirst("div.tv_palyer iframe")
|
|
||||||
?.attr("src")
|
json.apmap {
|
||||||
data.startsWith(mainUrl) -> app.get(
|
val iframe = app.get(
|
||||||
data,
|
fixChannelUrl(
|
||||||
allowRedirects = false
|
it.channel_id ?: return@apmap
|
||||||
).document.selectFirst("iframe")?.attr("src")
|
)
|
||||||
else -> data
|
).document.selectFirst("iframe#thatframe")?.attr("src")
|
||||||
} ?: throw ErrorLoadingException()
|
?: throw ErrorLoadingException("No Iframe Found")
|
||||||
getLink(fixUrl(link))?.let { m3uLink ->
|
val host = getBaseUrl(iframe)
|
||||||
val url = app.get(m3uLink, referer = "$mainServer/")
|
val video = extractVideo(iframe)
|
||||||
|
|
||||||
M3u8Helper.generateM3u8(
|
M3u8Helper.generateM3u8(
|
||||||
this.name,
|
it.channel_name ?: return@apmap,
|
||||||
url.url,
|
video ?: return@apmap,
|
||||||
"$mainServer/",
|
"$host/",
|
||||||
).forEach(callback)
|
).forEach(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun extractVideo(url: String): String? {
|
||||||
|
val res = app.get(url, referer = mainUrl)
|
||||||
|
return Regex("""source:['"](\S+.m3u8)['"],""").find(res.text)?.groupValues?.getOrNull(
|
||||||
|
1
|
||||||
|
) ?: run {
|
||||||
|
val scriptData =
|
||||||
|
res.document.selectFirst("div#player")?.nextElementSibling()?.data()
|
||||||
|
?.substringAfterLast("return(")?.substringBefore(".join")
|
||||||
|
scriptData?.removeSurrounding("[", "]")?.replace("\"", "")?.split(",")
|
||||||
|
?.joinToString("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun fixChannelUrl(url: String): String {
|
||||||
|
return if (url.startsWith(mainUrl)) {
|
||||||
|
url
|
||||||
|
} else {
|
||||||
|
"$mainUrl/stream/stream-$url.php"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getBaseUrl(url: String): String {
|
||||||
|
return URI(url).let {
|
||||||
|
"${it.scheme}://${it.host}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data class Item(
|
||||||
|
val title: String? = null,
|
||||||
|
val url: String? = null,
|
||||||
|
val items: String? = null,
|
||||||
|
)
|
||||||
|
|
||||||
|
data class Items(
|
||||||
|
val time: String? = null,
|
||||||
|
val event: String? = null,
|
||||||
|
val channels: ArrayList<Channels>? = arrayListOf(),
|
||||||
|
)
|
||||||
|
|
||||||
|
data class Channels(
|
||||||
|
val channel_name: String? = null,
|
||||||
|
val channel_id: String? = null,
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,136 +0,0 @@
|
||||||
package com.hexated
|
|
||||||
|
|
||||||
import com.lagradost.cloudstream3.app
|
|
||||||
import com.lagradost.cloudstream3.fixUrl
|
|
||||||
import com.lagradost.cloudstream3.utils.getAndUnpack
|
|
||||||
import com.lagradost.nicehttp.NiceResponse
|
|
||||||
import java.net.URI
|
|
||||||
|
|
||||||
var mainServer: String? = null
|
|
||||||
|
|
||||||
object TimefourTvExtractor : TimefourTv() {
|
|
||||||
|
|
||||||
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 daddyHost = daddyUrl.getHost()
|
|
||||||
|
|
||||||
if(url.contains(daddyHost, true)) {
|
|
||||||
mainServer = getBaseUrl(url)
|
|
||||||
return getFinalLink(app.get(url, referer = daddyUrl))
|
|
||||||
}
|
|
||||||
|
|
||||||
val (channel, iframe) = if (url.contains("width=") || url.contains("/link")) {
|
|
||||||
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 = if(iframe.contains(daddyHost)) "${iframe.substringAfter("?")}$channel.php" else "$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 getFinalLink(docThird)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getFinalLink(res: NiceResponse): String? {
|
|
||||||
return Regex("""source:['|"](\S+.m3u8)['|"],""").find(res.text)?.groupValues?.getOrNull(
|
|
||||||
1
|
|
||||||
) ?: run {
|
|
||||||
val scriptData =
|
|
||||||
res.document.selectFirst("div#player")?.nextElementSibling()?.data()
|
|
||||||
?.substringAfterLast("return(")?.substringBefore(".join")
|
|
||||||
scriptData?.removeSurrounding("[", "]")?.replace("\"", "")?.split(",")
|
|
||||||
?.joinToString("")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun String.getHost(): String {
|
|
||||||
return URI(this).host.substringBeforeLast(".").substringAfterLast(".")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue