fixed TimefourTv

This commit is contained in:
hexated 2022-11-06 16:12:19 +07:00
parent d3d32f3366
commit 24d0975f5f
2 changed files with 7 additions and 11 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers // use an integer for version numbers
version = 5 version = 6
cloudstream { cloudstream {

View file

@ -67,7 +67,7 @@ open class TimefourTv : MainAPI() {
private fun Element.toSearchSchedule(): LiveSearchResponse? { private fun Element.toSearchSchedule(): LiveSearchResponse? {
return LiveSearchResponse( return LiveSearchResponse(
this.text() ?: return null, this.text() ?: return null,
Schedule(this.text()).toJson(), this.text(),
this@TimefourTv.name, this@TimefourTv.name,
TvType.Live, TvType.Live,
posterUrl = time4tvPoster posterUrl = time4tvPoster
@ -86,10 +86,11 @@ open class TimefourTv : MainAPI() {
} }
private suspend fun loadSchedule(url: String): LoadResponse { private suspend fun loadSchedule(url: String): LoadResponse {
val name = url.removePrefix("$mainUrl/")
val doc = app.get("$mainUrl/schedule.php").document val doc = app.get("$mainUrl/schedule.php").document
val episode = val episode =
doc.selectFirst("div.search_p h2:contains($url)")?.nextElementSibling()?.select("span") doc.selectFirst("div.search_p h2:contains($name)")?.nextElementSibling()?.select("span")
?.mapIndexedNotNull { index, ele -> ?.mapIndexedNotNull { index, ele ->
val title = ele.select("a").text() val title = ele.select("a").text()
val href = ele.select("a").attr("href") val href = ele.select("a").attr("href")
@ -102,16 +103,15 @@ open class TimefourTv : MainAPI() {
) )
} ?: throw ErrorLoadingException("Referest Page") } ?: throw ErrorLoadingException("Referest Page")
return newTvSeriesLoadResponse(url, url, TvType.TvSeries, episode) { return newTvSeriesLoadResponse(name, url, TvType.TvSeries, episode) {
} }
} }
override suspend fun load(url: String): LoadResponse? { override suspend fun load(url: String): LoadResponse? {
val data = AppUtils.parseJson<Schedule>(url)
if (data.name?.startsWith("http") == false) return loadSchedule(data.name)
val res = app.get(url) val res = app.get(url)
if (!res.isSuccessful) return loadSchedule(url)
val document = res.document val document = res.document
val title = document.selectFirst("div.channelHeading h1")?.text() ?: return null val title = document.selectFirst("div.channelHeading h1")?.text() ?: return null
val poster = val poster =
@ -176,8 +176,4 @@ open class TimefourTv : MainAPI() {
return true return true
} }
data class Schedule(
val name: String? = null
)
} }