From 19b6780d58890358c21cd68f765af4f1a330ab01 Mon Sep 17 00:00:00 2001 From: hexated Date: Tue, 4 Oct 2022 22:03:18 +0700 Subject: [PATCH] fixed missing server TimefourTv --- TimefourTv/build.gradle.kts | 2 +- .../src/main/kotlin/com/hexated/TimefourTv.kt | 29 +++++++++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/TimefourTv/build.gradle.kts b/TimefourTv/build.gradle.kts index 68be48c6..813f95b5 100644 --- a/TimefourTv/build.gradle.kts +++ b/TimefourTv/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 2 +version = 3 cloudstream { diff --git a/TimefourTv/src/main/kotlin/com/hexated/TimefourTv.kt b/TimefourTv/src/main/kotlin/com/hexated/TimefourTv.kt index dcd34925..2b9aa943 100644 --- a/TimefourTv/src/main/kotlin/com/hexated/TimefourTv.kt +++ b/TimefourTv/src/main/kotlin/com/hexated/TimefourTv.kt @@ -73,13 +73,22 @@ class TimefourTv : MainAPI() { ?.substringBefore("',")?.let { link -> val doc = app.get(link).document.selectFirst("div.tv_palyer iframe")?.attr("src") ?.let { iframe -> - app.get(fixUrl(iframe), allowRedirects = false).document + 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() + ) } - doc?.select("div.stream_button a")?.map { - Episode( - fixUrl(it.attr("href")), - it.text() - ) } } ?: throw ErrorLoadingException("Refresh page") return newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes) { @@ -140,9 +149,11 @@ class TimefourTv : MainAPI() { callback: (ExtractorLink) -> Unit ): Boolean { - val document = app.get(data, allowRedirects = false).document - val link = document.selectFirst("iframe")?.attr("src") - ?: throw ErrorLoadingException() + val link = if (data.startsWith(mainUrl)) { + app.get(data, allowRedirects = false).document.selectFirst("iframe")?.attr("src") + } else { + data + } ?: throw ErrorLoadingException() getLink(fixUrl(link))?.let { m3uLink -> callback.invoke( ExtractorLink(