From 61f7e7fff7a7f2690b6b0e54a4190fafabe6260c Mon Sep 17 00:00:00 2001 From: darkdemon Date: Sun, 20 Nov 2022 14:56:47 +0530 Subject: [PATCH] feat: add NPJioTV+ --- NPJioTVProvider/build.gradle.kts | 24 ++++ NPJioTVProvider/src/main/AndroidManifest.xml | 2 + .../kotlin/com/darkdemon/NPJioTVPlugin.kt | 14 +++ .../kotlin/com/darkdemon/NPJioTVProvider.kt | 103 ++++++++++++++++++ 4 files changed, 143 insertions(+) create mode 100644 NPJioTVProvider/build.gradle.kts create mode 100644 NPJioTVProvider/src/main/AndroidManifest.xml create mode 100644 NPJioTVProvider/src/main/kotlin/com/darkdemon/NPJioTVPlugin.kt create mode 100644 NPJioTVProvider/src/main/kotlin/com/darkdemon/NPJioTVProvider.kt diff --git a/NPJioTVProvider/build.gradle.kts b/NPJioTVProvider/build.gradle.kts new file mode 100644 index 0000000..4f699ed --- /dev/null +++ b/NPJioTVProvider/build.gradle.kts @@ -0,0 +1,24 @@ +version = 1 + + +cloudstream { + language = "hi" + // All of these properties are optional, you can safely remove them + + description = "JioTV Plus channels" + authors = listOf("darkdemon") + + /** + * Status int as the following: + * 0: Down + * 1: Ok + * 2: Slow + * 3: Beta only + * */ + status = 1 // will be 3 if unspecified + tvTypes = listOf( + "Live", + ) + + iconUrl = "https://www.google.com/s2/favicons?domain=nayeemparvez.chadasaniya.cf&sz=%size%" +} diff --git a/NPJioTVProvider/src/main/AndroidManifest.xml b/NPJioTVProvider/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7fbfe5f --- /dev/null +++ b/NPJioTVProvider/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/NPJioTVProvider/src/main/kotlin/com/darkdemon/NPJioTVPlugin.kt b/NPJioTVProvider/src/main/kotlin/com/darkdemon/NPJioTVPlugin.kt new file mode 100644 index 0000000..9982619 --- /dev/null +++ b/NPJioTVProvider/src/main/kotlin/com/darkdemon/NPJioTVPlugin.kt @@ -0,0 +1,14 @@ +package com.darkdemon + +import com.lagradost.cloudstream3.plugins.CloudstreamPlugin +import com.lagradost.cloudstream3.plugins.Plugin +import android.content.Context + +@CloudstreamPlugin +class NPJioTVPlugin: Plugin() { + override fun load(context: Context) { + // All providers should be added in this manner. Please don't edit the providers list directly. + registerMainAPI(NPJioTVProvider()) + + } +} diff --git a/NPJioTVProvider/src/main/kotlin/com/darkdemon/NPJioTVProvider.kt b/NPJioTVProvider/src/main/kotlin/com/darkdemon/NPJioTVProvider.kt new file mode 100644 index 0000000..0a993e8 --- /dev/null +++ b/NPJioTVProvider/src/main/kotlin/com/darkdemon/NPJioTVProvider.kt @@ -0,0 +1,103 @@ +package com.darkdemon + +import com.lagradost.cloudstream3.* +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.Qualities + +class NPJioTVProvider : MainAPI() { // all providers must be an instance of MainAPI + override var mainUrl = "https://nayeemparvez.chadasaniya.cf" + override var name = "NPJioTV+" + override val hasMainPage = true + override var lang = "hi" + override val hasDownloadSupport = false + override val supportedTypes = setOf( + TvType.Live, + ) + + override suspend fun getMainPage( + page: Int, + request: MainPageRequest + ): HomePageResponse { + val categories = listOf( + "Sports", + "Entertainment", + "Movies", + "News", + "Music", + "Kids", + "Infotainment", + "Lifestyle", + "Business", + "Devotional", + "Educational", + "JioDarshan", + "Shopping", + ) + val items = ArrayList() + val document = app.get(mainUrl).document + categories.forEach { cat -> + val results: MutableList = mutableListOf() + document.select(".card-parent .card:contains($cat)").mapNotNull { + val title = it.selectFirst("h5")?.text()?.trim() ?: return@mapNotNull + val posterUrl = fixUrlNull(it.selectFirst("img")?.attr("data-src")) + results.add( + newMovieSearchResponse(title, title, TvType.Live) { + this.posterUrl = posterUrl + } + ) + } + items.add( + HomePageList( + capitalizeString(cat), + results, + isHorizontalImages = true + ) + ) + } + return HomePageResponse(items) + } + + override suspend fun search(query: String): List { + val document = app.get(mainUrl).document + val elements = document.select(".card-parent .card h5:contains($query)").map { it.parent() + ?.parent() } + return elements.map { + val title = it?.selectFirst("h5")?.text()?.trim().toString() + val posterUrl = fixUrlNull(it?.selectFirst("img")?.attr("data-src")) + newMovieSearchResponse(title, title, TvType.Live) { + this.posterUrl = posterUrl + } + } + } + + override suspend fun load(url: String): LoadResponse { + val document = app.get(mainUrl).document.selectFirst(".card:contains(${url.substringAfterLast("/")})") + val title = url.substringAfterLast("/") + val poster = fixUrlNull(document?.select("img")?.attr("data-src")) + val href = fixUrl("$mainUrl/" + document?.selectFirst("a")?.attr("href").toString()) + return newMovieLoadResponse(title, url, TvType.Live, href) { + this.posterUrl = poster + } + } + + override suspend fun loadLinks( + data: String, + isCasting: Boolean, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ): Boolean { + val document = app.get(data).document + val link = "$mainUrl/${document.selectFirst("source")?.attr("src")}" + callback.invoke( + ExtractorLink( + this.name, + this.name, + link, + referer = "", + quality = Qualities.Unknown.value, + isM3u8 = true, + ) + ) + return true + } +} \ No newline at end of file