From bfe6b1790fc0cf5de0cef5c32adafc6573276f2d Mon Sep 17 00:00:00 2001
From: Cloudburst <18114966+C10udburst@users.noreply.github.com>
Date: Thu, 8 Sep 2022 17:39:49 +0200
Subject: [PATCH] add superembed
---
SuperembedProvider/build.gradle.kts | 26 +++++++
.../src/main/AndroidManifest.xml | 2 +
.../com/lagradost/SuperembedProvider.kt | 76 +++++++++++++++++++
.../com/lagradost/SuperembedProviderPlugin.kt | 14 ++++
4 files changed, 118 insertions(+)
create mode 100644 SuperembedProvider/build.gradle.kts
create mode 100644 SuperembedProvider/src/main/AndroidManifest.xml
create mode 100644 SuperembedProvider/src/main/kotlin/com/lagradost/SuperembedProvider.kt
create mode 100644 SuperembedProvider/src/main/kotlin/com/lagradost/SuperembedProviderPlugin.kt
diff --git a/SuperembedProvider/build.gradle.kts b/SuperembedProvider/build.gradle.kts
new file mode 100644
index 0000000..3378ffc
--- /dev/null
+++ b/SuperembedProvider/build.gradle.kts
@@ -0,0 +1,26 @@
+// use an integer for version numbers
+version = 3
+
+
+cloudstream {
+ language = "en"
+ // All of these properties are optional, you can safely remove them
+
+ description = "Uses TMDB"
+ authors = listOf("Cloudburst")
+
+ /**
+ * Status int as the following:
+ * 0: Down
+ * 1: Ok
+ * 2: Slow
+ * 3: Beta only
+ * */
+ status = 0 // will be 3 if unspecified
+ tvTypes = listOf(
+ "TvSeries",
+ "Movie",
+ )
+
+ iconUrl = "https://www.google.com/s2/favicons?domain=www.superembed.stream&sz=%size%"
+}
\ No newline at end of file
diff --git a/SuperembedProvider/src/main/AndroidManifest.xml b/SuperembedProvider/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..29aec9d
--- /dev/null
+++ b/SuperembedProvider/src/main/AndroidManifest.xml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/SuperembedProvider/src/main/kotlin/com/lagradost/SuperembedProvider.kt b/SuperembedProvider/src/main/kotlin/com/lagradost/SuperembedProvider.kt
new file mode 100644
index 0000000..cf8ce5c
--- /dev/null
+++ b/SuperembedProvider/src/main/kotlin/com/lagradost/SuperembedProvider.kt
@@ -0,0 +1,76 @@
+package com.lagradost
+
+import android.util.Log
+import com.lagradost.cloudstream3.SubtitleFile
+import com.lagradost.cloudstream3.TvType
+import com.lagradost.cloudstream3.app
+import com.lagradost.cloudstream3.base64Decode
+import com.lagradost.cloudstream3.metaproviders.TmdbLink
+import com.lagradost.cloudstream3.metaproviders.TmdbProvider
+import com.lagradost.cloudstream3.network.WebViewResolver
+import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
+import com.lagradost.cloudstream3.utils.ExtractorLink
+import com.lagradost.cloudstream3.utils.Qualities
+import com.lagradost.cloudstream3.utils.getQualityFromName
+
+class SuperembedProvider : TmdbProvider() {
+ override var mainUrl = "https://seapi.link"
+ override val apiName = "Superembed"
+ override var name = "Superembed"
+ override val instantLinkLoading = true
+ override val useMetaLoadResponse = true
+ override val supportedTypes = setOf(TvType.TvSeries, TvType.Movie)
+
+ override suspend fun loadLinks(
+ data: String,
+ isCasting: Boolean,
+ subtitleCallback: (SubtitleFile) -> Unit,
+ callback: (ExtractorLink) -> Unit
+ ): Boolean {
+ val mappedData = tryParseJson(data)
+ val tmdbId = mappedData?.tmdbID ?: return false
+
+ val document = app.get("https://seapi.link/?type=tmdb&id=${tmdbId}&max_results=1").text
+ val response = tryParseJson(document) ?: return false
+
+ response.results.forEach {
+ it.toExtractorLink()?.let { it1 ->
+ Log.d("supaembed", it1.url)
+ callback.invoke(it1)
+ }
+ }
+
+ return true
+ }
+
+ private data class ApiResponse(
+ val results: List
+ )
+
+ private data class ApiResultItem(
+ val server: String,
+ val title: String,
+ val quality: String,
+ val size: Int,
+ val url: String
+ ) {
+ private suspend fun getIframeContents(): String? {
+ val document = app.get(url).text
+ val regex = "