From 2b3fb0e8e044dab423872b0b5384a666271561d5 Mon Sep 17 00:00:00 2001 From: hexated Date: Wed, 14 Jun 2023 14:26:12 +0700 Subject: [PATCH] added Ngefilm --- Ngefilm/build.gradle.kts | 27 +++ Ngefilm/src/main/AndroidManifest.xml | 2 + .../src/main/kotlin/com/hexated/Extractors.kt | 149 +++++++++++++++ .../src/main/kotlin/com/hexated/Ngefilm.kt | 176 ++++++++++++++++++ .../main/kotlin/com/hexated/NgefilmPlugin.kt | 21 +++ 5 files changed, 375 insertions(+) create mode 100644 Ngefilm/build.gradle.kts create mode 100644 Ngefilm/src/main/AndroidManifest.xml create mode 100644 Ngefilm/src/main/kotlin/com/hexated/Extractors.kt create mode 100644 Ngefilm/src/main/kotlin/com/hexated/Ngefilm.kt create mode 100644 Ngefilm/src/main/kotlin/com/hexated/NgefilmPlugin.kt diff --git a/Ngefilm/build.gradle.kts b/Ngefilm/build.gradle.kts new file mode 100644 index 00000000..bed0f1c3 --- /dev/null +++ b/Ngefilm/build.gradle.kts @@ -0,0 +1,27 @@ +// use an integer for version numbers +version = 1 + + +cloudstream { + language = "id" + // All of these properties are optional, you can safely remove them + + // description = "Lorem Ipsum" + authors = listOf("Hexated") + + /** + * Status int as the following: + * 0: Down + * 1: Ok + * 2: Slow + * 3: Beta only + * */ + status = 1 // will be 3 if unspecified + tvTypes = listOf( + "AsianDrama", + "TvSeries", + "Movie", + ) + + iconUrl = "https://www.google.com/s2/favicons?domain=ngefilm21.club&sz=%size%" +} \ No newline at end of file diff --git a/Ngefilm/src/main/AndroidManifest.xml b/Ngefilm/src/main/AndroidManifest.xml new file mode 100644 index 00000000..c98063f8 --- /dev/null +++ b/Ngefilm/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Ngefilm/src/main/kotlin/com/hexated/Extractors.kt b/Ngefilm/src/main/kotlin/com/hexated/Extractors.kt new file mode 100644 index 00000000..9730276b --- /dev/null +++ b/Ngefilm/src/main/kotlin/com/hexated/Extractors.kt @@ -0,0 +1,149 @@ +package com.hexated + +import com.fasterxml.jackson.annotation.JsonProperty +import com.lagradost.cloudstream3.* +import com.lagradost.cloudstream3.extractors.DoodLaExtractor +import com.lagradost.cloudstream3.extractors.Filesim +import com.lagradost.cloudstream3.extractors.StreamSB +import com.lagradost.cloudstream3.utils.AppUtils +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.Qualities +import java.net.URI +import javax.crypto.Cipher +import javax.crypto.SecretKeyFactory +import javax.crypto.spec.IvParameterSpec +import javax.crypto.spec.PBEKeySpec +import javax.crypto.spec.SecretKeySpec + +class Dooood : DoodLaExtractor() { + override var mainUrl = "https://dooood.com" +} + +class Guccihide : Filesim() { + override val name = "Guccihide" + override var mainUrl = "https://guccihide.com" +} + +class Ahvsh : Filesim() { + override val name = "Ahvsh" + override var mainUrl = "https://ahvsh.com" +} + +class Lvturbo : StreamSB() { + override var name = "Lvturbo" + override var mainUrl = "https://lvturbo.com" +} + +class Sbrapid : StreamSB() { + override var name = "Sbrapid" + override var mainUrl = "https://sbrapid.com" +} + +class Sbface : StreamSB() { + override var name = "Sbface" + override var mainUrl = "https://sbface.com" +} + +class Sbsonic : StreamSB() { + override var name = "Sbsonic" + override var mainUrl = "https://sbsonic.com" +} + +object LocalServer { + private const val KEY = "4VqE3#N7zt&HEP^a" + + private fun getBaseUrl(url: String): String { + return URI(url).let { + "${it.scheme}://${it.host}" + } + } + + suspend fun getUrl( + url: String, + referer: String?, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ) { + val mainUrl = getBaseUrl(url) + val master = Regex("MasterJS\\s*=\\s*'([^']+)").find( + app.get( + url, + referer = referer + ).text + )?.groupValues?.get(1) + val encData = AppUtils.tryParseJson(base64Decode(master ?: return)) + val decrypt = cryptoAESHandler(encData ?: return, KEY, false) + + val source = Regex(""""?file"?:\s*"([^"]+)""").find(decrypt)?.groupValues?.get(1) + + // required + val headers = mapOf( + "Accept" to "*/*", + "Connection" to "keep-alive", + "Sec-Fetch-Dest" to "empty", + "Sec-Fetch-Mode" to "cors", + "Sec-Fetch-Site" to "cross-site", + "Origin" to mainUrl, + ) + + callback.invoke( + ExtractorLink( + Ngefilm().name, + Ngefilm().name, + source ?: return, + "$mainUrl/", + Qualities.P1080.value, + headers = headers, + isM3u8 = true + ) + ) + + } + + private fun cryptoAESHandler( + data: AESData, + pass: String, + encrypt: Boolean = true + ): String { + val factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA512") + val spec = PBEKeySpec( + pass.toCharArray(), + data.salt?.hexToByteArray(), + data.iterations?.toIntOrNull() ?: 1, + 256 + ) + val key = factory.generateSecret(spec) + val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding") + return if (!encrypt) { + cipher.init( + Cipher.DECRYPT_MODE, + SecretKeySpec(key.encoded, "AES"), + IvParameterSpec(data.iv?.hexToByteArray()) + ) + String(cipher.doFinal(base64DecodeArray(data.ciphertext.toString()))) + } else { + cipher.init( + Cipher.ENCRYPT_MODE, + SecretKeySpec(key.encoded, "AES"), + IvParameterSpec(data.iv?.hexToByteArray()) + ) + base64Encode(cipher.doFinal(data.ciphertext?.toByteArray())) + } + } + + private fun String.hexToByteArray(): ByteArray { + check(length % 2 == 0) { "Must have an even length" } + return chunked(2) + .map { it.toInt(16).toByte() } + + .toByteArray() + } + + data class AESData( + @JsonProperty("ciphertext") val ciphertext: String? = null, + @JsonProperty("iv") val iv: String? = null, + @JsonProperty("salt") val salt: String? = null, + @JsonProperty("iterations") val iterations: String? = null, + ) + +} \ No newline at end of file diff --git a/Ngefilm/src/main/kotlin/com/hexated/Ngefilm.kt b/Ngefilm/src/main/kotlin/com/hexated/Ngefilm.kt new file mode 100644 index 00000000..5e5fcaed --- /dev/null +++ b/Ngefilm/src/main/kotlin/com/hexated/Ngefilm.kt @@ -0,0 +1,176 @@ +package com.hexated + +import com.lagradost.cloudstream3.* +import com.lagradost.cloudstream3.LoadResponse.Companion.addActors +import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.loadExtractor +import org.jsoup.nodes.Element + +class Ngefilm : MainAPI() { + override var mainUrl = "https://ngefilm21.club" + override var name = "Ngefilm" + override val hasMainPage = true + override var lang = "id" + override val hasDownloadSupport = true + override val supportedTypes = setOf( + TvType.Movie, + TvType.TvSeries, + TvType.AsianDrama + ) + + companion object { + private val localServer = arrayOf( + "https://bestx.stream", + "https://chillx.top", + "https://watchx.top", + ) + } + + override val mainPage = mainPageOf( + "?s&search=advanced&post_type=movie&index&orderby&genre&movieyear&country&quality=" to "Movies Terbaru", + "?s=&search=advanced&post_type=tv&index=&orderby=&genre=&movieyear=&country=&quality=" to "Series Terbaru", + "?s=&search=advanced&post_type=tv&index=&orderby=&genre=drakor&movieyear=&country=&quality=" to "Series Korea", + "?s=&search=advanced&post_type=tv&index=&orderby=&genre=&movieyear=&country=indonesia&quality=" to "Series Indonesia", + ) + + override suspend fun getMainPage( + page: Int, + request: MainPageRequest + ): HomePageResponse { + val document = app.get("$mainUrl/page/$page/${request.data}").document + val home = document.select("main#main article").mapNotNull { + it.toSearchResult() + } + return newHomePageResponse(request.name, home) + } + + override suspend fun search(query: String): List { + val link = "$mainUrl/?s=$query&post_type[]=post&post_type[]=tv" + val document = app.get(link).document + return document.select("main#main article").mapNotNull { + it.toSearchResult() + } + } + + override suspend fun load(url: String): LoadResponse { + val document = app.get(url).document + + val title = + document.selectFirst("h1.entry-title")?.text()?.substringBefore("Season")?.trim() ?: "" + val poster = fixUrlNull( + document.selectFirst("figure.pull-left > img")?.attr("src")?.fixImageQuality() + ) + val tags = document.select("span.gmr-movie-genre:contains(Genre:) > a").map { it.text() } + + val year = + document.select("span.gmr-movie-genre:contains(Year:) > a").text().trim().toIntOrNull() + val tvType = if (url.contains("/tv/")) TvType.TvSeries else TvType.Movie + val description = document.selectFirst("div[itemprop=description] > p")?.text()?.trim() + val trailer = document.selectFirst("ul.gmr-player-nav li a.gmr-trailer-popup")?.attr("href") + val rating = + document.selectFirst("div.gmr-meta-rating > span[itemprop=ratingValue]")?.text() + ?.toRatingInt() + val actors = document.select("div.gmr-moviedata").last()?.select("span[itemprop=actors]") + ?.map { it.select("a").text() } + + val recommendations = document.select("div.idmuvi-rp ul li").mapNotNull { + it.toRecommendResult() + } + + return if (tvType == TvType.TvSeries) { + val episodes = document.select("div.gmr-listseries > a") + .filter { element -> !element.text().contains("Pilih Episode", true) } + .map { eps -> + val href = fixUrl(eps.attr("href")) + val episode = eps.text().filter { it.isDigit() }.toIntOrNull() + val season = + eps.text().split(" ").first().substringAfter("S").toIntOrNull() ?: 1 + Episode( + href, + season = season, + episode = episode, + ) + } + newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes) { + this.posterUrl = poster + this.year = year + this.plot = description + this.tags = tags + this.rating = rating + addActors(actors) + this.recommendations = recommendations + addTrailer(trailer) + } + } else { + newMovieLoadResponse(title, url, TvType.Movie, url) { + this.posterUrl = poster + this.year = year + this.plot = description + this.tags = tags + this.rating = rating + addActors(actors) + this.recommendations = recommendations + addTrailer(trailer) + } + } + } + + override suspend fun loadLinks( + data: String, + isCasting: Boolean, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ): Boolean { + + val document = app.get(data).document + + document.select("ul.muvipro-player-tabs li a").apmap { server -> + val iframe = app.get(fixUrl(server.attr("href"))).document.selectFirst("div.gmr-embed-responsive iframe") + ?.attr("src")?.let { fixUrl(it) } ?: return@apmap + if (localServer.any { iframe.startsWith(it) }) { + LocalServer.getUrl(iframe, "$mainUrl/", subtitleCallback, callback) + } else { + loadExtractor(iframe, "$mainUrl/", subtitleCallback, callback) + } + } + + return true + + } + + private fun Element.toSearchResult(): SearchResponse? { + val title = this.selectFirst("h2.entry-title > a")?.text()?.trim() ?: return null + val href = fixUrl(this.selectFirst("a")?.attr("href") ?: return null) + val posterUrl = fixUrlNull(this.selectFirst("a > img")?.attr("src").fixImageQuality()) + val quality = this.select("div.gmr-quality-item > a").text().trim() + return if (quality.isEmpty()) { + val episode = + this.select("div.gmr-numbeps > span").text().filter { it.isDigit() }.toIntOrNull() + newAnimeSearchResponse(title, href, TvType.TvSeries) { + this.posterUrl = posterUrl + addSub(episode) + } + } else { + newMovieSearchResponse(title, href, TvType.Movie) { + this.posterUrl = posterUrl + addQuality(quality.replace("-", "")) + } + } + } + + private fun Element.toRecommendResult(): SearchResponse? { + val title = this.selectFirst("a > span.idmuvi-rp-title")?.text()?.trim() ?: return null + val href = this.selectFirst("a")!!.attr("href") + val posterUrl = fixUrlNull(this.selectFirst("a > img")?.attr("src").fixImageQuality()) + return newMovieSearchResponse(title, href, TvType.Movie) { + this.posterUrl = posterUrl + } + } + + private fun String?.fixImageQuality(): String? { + val quality = Regex("(-\\d*x\\d*)").find(this ?: return null)?.groupValues?.get(0) + return this.replace(quality ?: return null, "") + } + +} \ No newline at end of file diff --git a/Ngefilm/src/main/kotlin/com/hexated/NgefilmPlugin.kt b/Ngefilm/src/main/kotlin/com/hexated/NgefilmPlugin.kt new file mode 100644 index 00000000..cbf73937 --- /dev/null +++ b/Ngefilm/src/main/kotlin/com/hexated/NgefilmPlugin.kt @@ -0,0 +1,21 @@ + +package com.hexated + +import com.lagradost.cloudstream3.plugins.CloudstreamPlugin +import com.lagradost.cloudstream3.plugins.Plugin +import android.content.Context + +@CloudstreamPlugin +class NgefilmPlugin: Plugin() { + override fun load(context: Context) { + // All providers should be added in this manner. Please don't edit the providers list directly. + registerMainAPI(Ngefilm()) + registerExtractorAPI(Sbsonic()) + registerExtractorAPI(Sbface()) + registerExtractorAPI(Sbrapid()) + registerExtractorAPI(Lvturbo()) + registerExtractorAPI(Ahvsh()) + registerExtractorAPI(Guccihide()) + registerExtractorAPI(Dooood()) + } +} \ No newline at end of file