From 9b35c6acd73b64c7e3fa2fbdacb98e2232f533ad Mon Sep 17 00:00:00 2001 From: Hexated <37908684+hexated@users.noreply.github.com> Date: Fri, 2 Sep 2022 04:26:24 +0700 Subject: [PATCH] added Useetv (#9) * add Useetv * fixes --- UseeTv/build.gradle.kts | 25 +++++ UseeTv/src/main/AndroidManifest.xml | 2 + .../src/main/kotlin/com/lagradost/UseeTv.kt | 93 +++++++++++++++++++ .../main/kotlin/com/lagradost/UseeTvPlugin.kt | 14 +++ 4 files changed, 134 insertions(+) create mode 100644 UseeTv/build.gradle.kts create mode 100644 UseeTv/src/main/AndroidManifest.xml create mode 100644 UseeTv/src/main/kotlin/com/lagradost/UseeTv.kt create mode 100644 UseeTv/src/main/kotlin/com/lagradost/UseeTvPlugin.kt diff --git a/UseeTv/build.gradle.kts b/UseeTv/build.gradle.kts new file mode 100644 index 0000000..31e67a1 --- /dev/null +++ b/UseeTv/build.gradle.kts @@ -0,0 +1,25 @@ +// 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( + "Live", + ) + + iconUrl = "https://www.google.com/s2/favicons?domain=useetv.com&sz=%size%" +} diff --git a/UseeTv/src/main/AndroidManifest.xml b/UseeTv/src/main/AndroidManifest.xml new file mode 100644 index 0000000..29aec9d --- /dev/null +++ b/UseeTv/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/UseeTv/src/main/kotlin/com/lagradost/UseeTv.kt b/UseeTv/src/main/kotlin/com/lagradost/UseeTv.kt new file mode 100644 index 0000000..cbb7af9 --- /dev/null +++ b/UseeTv/src/main/kotlin/com/lagradost/UseeTv.kt @@ -0,0 +1,93 @@ +package com.lagradost + +import com.lagradost.cloudstream3.* +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.M3u8Helper +import org.jsoup.nodes.Element + +class UseeTv : MainAPI() { + override var mainUrl = "https://www.useetv.com" + override var name = "Useetv" + override var lang = "id" + override val hasDownloadSupport = false + override val hasMainPage = true + override val supportedTypes = setOf( + TvType.Live + ) + + companion object { + private const val mainLink = "https://streaming.useetv.com" + } + + override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse { + val document = app.get("$mainUrl/tv/live").document + + val home = listOf( + Pair("col-xs-4", "Semua"), + Pair("local", "Local"), + Pair("news", "News"), + ).map { (soap,name) -> + val home = document.select("div#channelContainer div.col-channel").mapNotNull { it }.filter { + it.attr("class").contains(soap, true) + }.mapNotNull { + it.toSearchResult() + } + HomePageList(name, home) + }.filter { it.list.isNotEmpty() } + return HomePageResponse(home) + + } + + private fun Element.toSearchResult(): LiveSearchResponse? { + return LiveSearchResponse( + this.selectFirst("a")?.attr("data-name") ?: return null, + fixUrl(this.selectFirst("a")!!.attr("href")), + this@UseeTv.name, + TvType.Live, + fixUrlNull(this.select("img").attr("data-src")), + ) + + } + + override suspend fun search(query: String): List { + return app.get("$mainUrl/tv/live").document.select("div#channelContainer div.col-channel").mapNotNull { + it + }.filter { it.select("a").attr("data-name").contains(query, true) }.mapNotNull { + it.toSearchResult() + } + } + + override suspend fun load(url: String): LoadResponse? { + val document = app.get(url).document + val content = document.selectFirst("div.d-flex.video-schedule-time p")?.text()?.split("•") + val link = document.select("script").findLast { it.data().contains("\$('.live').last()") }?.data()?.let{ + Regex("'$mainLink(.*)';var").find(it)?.groupValues?.getOrNull(1) + } + return LiveStreamLoadResponse( + content?.firstOrNull()?.trim() ?: return null, + url, + this.name, + "$mainLink$link", + fixUrlNull(document.selectFirst("div.row.video-schedule img")?.attr("src")), + plot = document.selectFirst("title")?.text() + ) + } + + override suspend fun loadLinks( + data: String, + isCasting: Boolean, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ): Boolean { + + M3u8Helper.generateM3u8( + this.name, + data, + mainUrl + ).forEach(callback) + + return true + + } + +} \ No newline at end of file diff --git a/UseeTv/src/main/kotlin/com/lagradost/UseeTvPlugin.kt b/UseeTv/src/main/kotlin/com/lagradost/UseeTvPlugin.kt new file mode 100644 index 0000000..7184a89 --- /dev/null +++ b/UseeTv/src/main/kotlin/com/lagradost/UseeTvPlugin.kt @@ -0,0 +1,14 @@ + +package com.lagradost + +import com.lagradost.cloudstream3.plugins.CloudstreamPlugin +import com.lagradost.cloudstream3.plugins.Plugin +import android.content.Context + +@CloudstreamPlugin +class UseeTvPlugin: Plugin() { + override fun load(context: Context) { + // All providers should be added in this manner. Please don't edit the providers list directly. + registerMainAPI(UseeTv()) + } +} \ No newline at end of file