mirror of
https://github.com/recloudstream/cloudstream-extensions.git
synced 2024-08-15 03:03:54 +00:00
add superembed
This commit is contained in:
parent
1da69244bc
commit
bfe6b1790f
4 changed files with 118 additions and 0 deletions
2
SuperembedProvider/src/main/AndroidManifest.xml
Normal file
2
SuperembedProvider/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest package="com.lagradost"/>
|
|
@ -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<TmdbLink>(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<ApiResponse>(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<ApiResultItem>
|
||||
)
|
||||
|
||||
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 = "<iframe[^+]+\\+(?:window\\.)?atob\\(['\"]([-A-Za-z0-9+/=]+)".toRegex()
|
||||
val encoded = regex.find(document)?.groupValues?.get(1) ?: return null
|
||||
return base64Decode(encoded)
|
||||
}
|
||||
|
||||
suspend fun toExtractorLink(): ExtractorLink? {
|
||||
val iframeLink = getIframeContents() ?: return null
|
||||
|
||||
return ExtractorLink(
|
||||
title,
|
||||
server,
|
||||
iframeLink,
|
||||
"",
|
||||
getQualityFromName(quality)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 SuperembedProviderPlugin: Plugin() {
|
||||
override fun load(context: Context) {
|
||||
// All providers should be added in this manner. Please don't edit the providers list directly.
|
||||
registerMainAPI(SuperembedProvider())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue