From f511569c342031822b0597c696af9d69a2742919 Mon Sep 17 00:00:00 2001 From: hexated Date: Sat, 2 Sep 2023 05:48:35 +0700 Subject: [PATCH] fix #254 --- Gomov/build.gradle.kts | 2 +- .../src/main/kotlin/com/hexated/Extractors.kt | 9 +- .../main/kotlin/com/hexated/GomovPlugin.kt | 1 + .../src/main/kotlin/com/hexated/Nodrakorid.kt | 38 +++++-- IdlixProvider/build.gradle.kts | 2 +- .../main/kotlin/com/hexated/IdlixProvider.kt | 102 ++++++++++++++++-- LayarKacaProvider/build.gradle.kts | 2 +- .../kotlin/com/hexated/LayarKacaProvider.kt | 14 ++- 8 files changed, 137 insertions(+), 33 deletions(-) diff --git a/Gomov/build.gradle.kts b/Gomov/build.gradle.kts index b66e81e1..000dde9a 100644 --- a/Gomov/build.gradle.kts +++ b/Gomov/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 8 +version = 9 cloudstream { diff --git a/Gomov/src/main/kotlin/com/hexated/Extractors.kt b/Gomov/src/main/kotlin/com/hexated/Extractors.kt index 7017d7fa..aa629966 100644 --- a/Gomov/src/main/kotlin/com/hexated/Extractors.kt +++ b/Gomov/src/main/kotlin/com/hexated/Extractors.kt @@ -1,8 +1,11 @@ package com.hexated -import com.lagradost.cloudstream3.extractors.Filesim -import com.lagradost.cloudstream3.extractors.Gdriveplayer -import com.lagradost.cloudstream3.extractors.StreamSB +import com.lagradost.cloudstream3.extractors.* + +class Doods : DoodLaExtractor() { + override var name = "Doods" + override var mainUrl = "https://doods.pro" +} class Dutamovie21 : StreamSB() { override var name = "Dutamovie21" diff --git a/Gomov/src/main/kotlin/com/hexated/GomovPlugin.kt b/Gomov/src/main/kotlin/com/hexated/GomovPlugin.kt index 975337d4..be1f392c 100644 --- a/Gomov/src/main/kotlin/com/hexated/GomovPlugin.kt +++ b/Gomov/src/main/kotlin/com/hexated/GomovPlugin.kt @@ -18,6 +18,7 @@ class GomovPlugin: Plugin() { registerExtractorAPI(DbGdriveplayer()) registerExtractorAPI(Dutamovie21()) registerExtractorAPI(Embedwish()) + registerExtractorAPI(Doods()) registerExtractorAPI(Lylxan()) } } \ No newline at end of file diff --git a/Gomov/src/main/kotlin/com/hexated/Nodrakorid.kt b/Gomov/src/main/kotlin/com/hexated/Nodrakorid.kt index c65d6b2f..846c6ee0 100644 --- a/Gomov/src/main/kotlin/com/hexated/Nodrakorid.kt +++ b/Gomov/src/main/kotlin/com/hexated/Nodrakorid.kt @@ -26,16 +26,30 @@ class Nodrakorid : DutaMovie() { is TvSeriesLoadResponse -> { val doc = app.get(url).document this.comingSoon = false - this.episodes = doc.select("div.entry-content p:contains(Episode)").distinctBy { - it.text() - }.map { eps -> - val num = eps.text() - val endSibling = eps.nextElementSiblings().select("p:contains(Episode)").firstOrNull() ?: eps.nextElementSiblings().select("div.content-moviedata").firstOrNull() - val siblings = eps.nextElementSiblingsUntil(endSibling).map { ele -> - ele.ownText().filter { it.isDigit() }.toIntOrNull() to ele.select("a") - .map { it.attr("href") to it.text() } - }.filter { it.first != null } - Episode(siblings.toJson(), episode = Regex("Episode\\s?([0-9]+)").find(num)?.groupValues?.getOrNull(1)?.toIntOrNull()) + this.episodes = when { + doc.select("div.vid-episodes a, div.gmr-listseries a").isNotEmpty() -> this.episodes + doc.select("div#download").isEmpty() -> { + doc.select("div.entry-content p:contains(Episode)").distinctBy { + it.text() + }.mapNotNull { eps -> + val endSibling = eps.nextElementSiblings().select("p:contains(Episode)").firstOrNull() ?: eps.nextElementSiblings().select("div.content-moviedata").firstOrNull() + val siblings = eps.nextElementSiblingsUntil(endSibling).map { ele -> + ele.ownText().filter { it.isDigit() }.toIntOrNull() to ele.select("a") + .map { it.attr("href") to it.text() } + }.filter { it.first != null } + Episode(siblings.toJson(), episode = eps.text().toEpisode()) + } + } + else -> { + doc.select("div#download h3.title-download").mapNotNull { eps -> + val siblings = eps.nextElementSibling()?.select("li")?.map { ele -> + ele.text().filter { it.isDigit() }.toIntOrNull() to ele.select("a").map { + it.attr("href") to it.text().split(" ").first() + } + }?.filter { it.first != null } + Episode(siblings?.toJson() ?: return@mapNotNull null, episode = eps.text().toEpisode()) + } + } } } } @@ -83,6 +97,10 @@ class Nodrakorid : DutaMovie() { } } + private fun String.toEpisode() : Int? { + return Regex("(?i)Episode\\s?([0-9]+)").find(this)?.groupValues?.getOrNull(1)?.toIntOrNull() + } + private fun getBaseUrl(url: String): String { return URI(url).let { "${it.scheme}://${it.host}" diff --git a/IdlixProvider/build.gradle.kts b/IdlixProvider/build.gradle.kts index 13421dec..63fef982 100644 --- a/IdlixProvider/build.gradle.kts +++ b/IdlixProvider/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 14 +version = 15 cloudstream { diff --git a/IdlixProvider/src/main/kotlin/com/hexated/IdlixProvider.kt b/IdlixProvider/src/main/kotlin/com/hexated/IdlixProvider.kt index 2763d98b..cacd8e54 100644 --- a/IdlixProvider/src/main/kotlin/com/hexated/IdlixProvider.kt +++ b/IdlixProvider/src/main/kotlin/com/hexated/IdlixProvider.kt @@ -5,8 +5,12 @@ import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.LoadResponse.Companion.addActors import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer import com.lagradost.cloudstream3.mvvm.safeApiCall +import com.lagradost.cloudstream3.network.CloudflareKiller import com.lagradost.cloudstream3.utils.* import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson +import okhttp3.Interceptor +import okhttp3.Response +import org.jsoup.Jsoup import org.jsoup.nodes.Element import java.net.URI @@ -17,6 +21,8 @@ class IdlixProvider : MainAPI() { override val hasMainPage = true override var lang = "id" override val hasDownloadSupport = true + private val cloudflareKiller by lazy { CloudflareKiller() } + private val interceptor by lazy { CloudflareInterceptor(cloudflareKiller) } override val supportedTypes = setOf( TvType.Movie, TvType.TvSeries, @@ -50,9 +56,9 @@ class IdlixProvider : MainAPI() { val url = request.data.split("?") val nonPaged = request.name == "Featured" && page <= 1 val req = if (nonPaged) { - app.get(request.data) + app.get(request.data, interceptor = interceptor) } else { - app.get("${url.first()}$page/?${url.lastOrNull()}") + app.get("${url.first()}$page/?${url.lastOrNull()}", interceptor = interceptor) } mainUrl = getBaseUrl(req.url) val document = req.document @@ -92,12 +98,13 @@ class IdlixProvider : MainAPI() { return newMovieSearchResponse(title, href, TvType.Movie) { this.posterUrl = posterUrl this.quality = quality + posterHeaders = cloudflareKiller.getCookieHeaders(mainUrl).toMap() } } override suspend fun search(query: String): List { - val req = app.get("$mainUrl/search/$query") + val req = app.get("$mainUrl/search/$query", interceptor = interceptor) mainUrl = getBaseUrl(req.url) val document = req.document return document.select("div.result-item").map { @@ -107,12 +114,13 @@ class IdlixProvider : MainAPI() { val posterUrl = it.selectFirst("img")!!.attr("src").toString() newMovieSearchResponse(title, href, TvType.TvSeries) { this.posterUrl = posterUrl + posterHeaders = cloudflareKiller.getCookieHeaders(mainUrl).toMap() } } } override suspend fun load(url: String): LoadResponse { - val request = app.get(url) + val request = app.get(url, interceptor = interceptor, referer = "$directUrl/") directUrl = getBaseUrl(request.url) val document = request.document val title = @@ -141,6 +149,7 @@ class IdlixProvider : MainAPI() { val recPosterUrl = it.selectFirst("img")?.attr("src").toString() newTvSeriesSearchResponse(recName, recHref, TvType.TvSeries) { this.posterUrl = recPosterUrl + posterHeaders = cloudflareKiller.getCookieHeaders(mainUrl).toMap() } } @@ -170,6 +179,7 @@ class IdlixProvider : MainAPI() { addActors(actors) this.recommendations = recommendations addTrailer(trailer) + posterHeaders = cloudflareKiller.getCookieHeaders(mainUrl).toMap() } } else { newMovieLoadResponse(title, url, TvType.Movie, url) { @@ -181,6 +191,7 @@ class IdlixProvider : MainAPI() { addActors(actors) this.recommendations = recommendations addTrailer(trailer) + posterHeaders = cloudflareKiller.getCookieHeaders(mainUrl).toMap() } } } @@ -192,7 +203,7 @@ class IdlixProvider : MainAPI() { callback: (ExtractorLink) -> Unit ): Boolean { - val document = app.get(data).document + val document = app.get(data, interceptor = interceptor, referer = "$directUrl/").document val id = document.select("meta#dooplay-ajax-counter").attr("data-postid") val type = if (data.contains("/movie/")) "movie" else "tv" @@ -203,15 +214,17 @@ class IdlixProvider : MainAPI() { val source = app.post( url = "$directUrl/wp-admin/admin-ajax.php", data = mapOf( "action" to "doo_player_ajax", "post" to id, "nume" to nume, "type" to type - ), headers = mapOf("X-Requested-With" to "XMLHttpRequest"), referer = data + ), headers = mapOf("X-Requested-With" to "XMLHttpRequest"), referer = data, interceptor = interceptor ).let { tryParseJson(it.text) } ?: return@safeApiCall - var decrypted = AesHelper.cryptoAESHandler(source.embed_url,key.toByteArray(), false)?.fixBloat() ?: return@safeApiCall + val password = if(source.key?.startsWith("\\x") == true) source.key else key + var decrypted = AesHelper.cryptoAESHandler(source.embed_url, password.toByteArray(), false)?.fixBloat() ?: return@safeApiCall if (decrypted.startsWith("https://uservideo.xyz")) { decrypted = app.get(decrypted).document.select("iframe").attr("src") } - loadExtractor(decrypted, "$directUrl/", subtitleCallback, callback) + + getUrl(decrypted, "$directUrl/", subtitleCallback, callback) } } @@ -219,13 +232,84 @@ class IdlixProvider : MainAPI() { return true } + class CloudflareInterceptor(private val cloudflareKiller: CloudflareKiller): Interceptor { + override fun intercept(chain: Interceptor.Chain): Response { + val request = chain.request() + val response = chain.proceed(request) + val doc = Jsoup.parse(response.peekBody(1024 * 1024).string()) + if (doc.select("title").text() == "Just a moment...") { + return cloudflareKiller.intercept(chain) + } + return response + } + } + private fun String.fixBloat() : String { return this.replace("\"", "").replace("\\", "") } + private suspend fun getUrl( + url: String, + referer: String?, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ) { + val document = app.get(url, referer = "$mainUrl/").document + val hash = url.split("/").last().substringAfter("data=") + + val m3uLink = app.post( + url = "$mainUrl/player/index.php?data=$hash&do=getVideo", + data = mapOf("hash" to hash, "r" to "$referer"), + referer = referer, + headers = mapOf("X-Requested-With" to "XMLHttpRequest") + ).parsed().videoSource + + M3u8Helper.generateM3u8( + this.name, + m3uLink, + "$referer", + ).forEach(callback) + + + document.select("script").map { script -> + if (script.data().contains("eval(function(p,a,c,k,e,d)")) { + val subData = + getAndUnpack(script.data()).substringAfter("\"tracks\":[").substringBefore("],") + tryParseJson>("[$subData]")?.map { subtitle -> + subtitleCallback.invoke( + SubtitleFile( + getLanguage(subtitle.label ?: ""), + subtitle.file + ) + ) + } + } + } + } + + private fun getLanguage(str: String): String { + return when { + str.contains("indonesia", true) || str + .contains("bahasa", true) -> "Indonesian" + else -> str + } + } + + data class ResponseSource( + @JsonProperty("hls") val hls: Boolean, + @JsonProperty("videoSource") val videoSource: String, + @JsonProperty("securedLink") val securedLink: String?, + ) + + data class Tracks( + @JsonProperty("kind") val kind: String?, + @JsonProperty("file") val file: String, + @JsonProperty("label") val label: String?, + ) + data class ResponseHash( @JsonProperty("embed_url") val embed_url: String, - @JsonProperty("key") val key: String, + @JsonProperty("key") val key: String?, @JsonProperty("type") val type: String?, ) diff --git a/LayarKacaProvider/build.gradle.kts b/LayarKacaProvider/build.gradle.kts index 7ec4087a..0be264f6 100644 --- a/LayarKacaProvider/build.gradle.kts +++ b/LayarKacaProvider/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 15 +version = 16 cloudstream { diff --git a/LayarKacaProvider/src/main/kotlin/com/hexated/LayarKacaProvider.kt b/LayarKacaProvider/src/main/kotlin/com/hexated/LayarKacaProvider.kt index a4055e54..cbccb55d 100644 --- a/LayarKacaProvider/src/main/kotlin/com/hexated/LayarKacaProvider.kt +++ b/LayarKacaProvider/src/main/kotlin/com/hexated/LayarKacaProvider.kt @@ -9,7 +9,7 @@ import org.jsoup.nodes.Element import java.net.URLDecoder class LayarKacaProvider : MainAPI() { - override var mainUrl = "https://tv1.lk21official.pro" + override var mainUrl = "https://tv3.lk21official.pro" private var seriesUrl = "https://tv1.nontondrama.click" override var name = "LayarKaca" override val hasMainPage = true @@ -72,11 +72,11 @@ class LayarKacaProvider : MainAPI() { } override suspend fun search(query: String): List { - val document = app.get("$mainUrl/?s=$query").document - return document.select("div.search-item").map { - val title = it.selectFirst("h2 > a")!!.text().trim() - val href = fixUrl(it.selectFirst("a")!!.attr("href")) - val posterUrl = fixUrl(it.selectFirst("img.img-thumbnail")?.attr("src").toString()) + val document = app.get("$mainUrl/search.php?s=$query").document + return document.select("div.search-item").mapNotNull { + val title = it.selectFirst("a")?.attr("title") ?: "" + val href = fixUrl(it.selectFirst("a")?.attr("href") ?: return@mapNotNull null) + val posterUrl = fixUrlNull(it.selectFirst("img.img-thumbnail")?.attr("src")) newTvSeriesSearchResponse(title, href, TvType.TvSeries) { this.posterUrl = posterUrl } @@ -172,8 +172,6 @@ class LayarKacaProvider : MainAPI() { return app.get(this, referer = "$seriesUrl/").document.select("div.embed iframe").attr("src") } - private fun decode(input: String): String = URLDecoder.decode(input, "utf-8").replace(" ", "%20") - } open class Emturbovid : ExtractorApi() {