Skip to content
Open
19 changes: 3 additions & 16 deletions ExampleProvider/src/main/kotlin/com/example/ExamplePlugin.kt
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
package com.example

import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
import com.lagradost.cloudstream3.plugins.Plugin
import android.content.Context

@CloudstreamPlugin
class ExamplePlugin: Plugin() {
private var activity: AppCompatActivity? = null

class ExamplePlugin : Plugin() {
override fun load(context: Context) {
activity = context as? AppCompatActivity

// All providers should be added in this manner
registerMainAPI(ExampleProvider())

openSettings = {
val frag = BlankFragment(this)
activity?.let {
frag.show(it.supportFragmentManager, "Frag")
}
}
}
}
}
55 changes: 41 additions & 14 deletions ExampleProvider/src/main/kotlin/com/example/ExampleProvider.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,48 @@
package com.example

import com.lagradost.cloudstream3.MainAPI
import com.lagradost.cloudstream3.SearchResponse
import com.lagradost.cloudstream3.TvType
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.*
import org.jsoup.nodes.Element

class ExampleProvider : MainAPI() { // All providers must be an instance of MainAPI
override var mainUrl = "https://example.com/"
override var name = "Example provider"
override val supportedTypes = setOf(TvType.Movie)

override var lang = "en"

// Enable this when your provider has a main page
class ExampleProvider : MainAPI() {
override var mainUrl = "https://protonmovies.com"
override var name = "ProtonMovies"
override val hasMainPage = true
override val supportedTypes = setOf(TvType.Movie, TvType.TvSeries)

// This function gets called when you search for something
override suspend fun search(query: String): List<SearchResponse> {
return listOf()
val url = "$mainUrl/search/$query"
val document = app.get(url).document

return document.select(".iq-card").mapNotNull {
it.toSearchResult()
}
}

private fun Element.toSearchResult(): SearchResponse? {
val title = this.selectFirst(".iq-title a")?.text() ?: return null
val href = fixUrl(this.selectFirst(".iq-title a")?.attr("href") ?: return null)
val posterUrl = this.selectFirst("img")?.attr("src")

return newMovieSearchResponse(title, href, TvType.Movie) {
this.posterUrl = posterUrl
}
}

override suspend fun load(url: String): LoadResponse? {
// TODO: Implement movie/series page loading
return null
}

override suspend fun loadLinks(
data: String,
isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
// TODO: Implement link extraction
return false
}
}
}


4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ buildscript {
classpath("com.android.tools.build:gradle:8.7.3")
// Cloudstream gradle plugin which makes everything work and builds plugins
classpath("com.github.recloudstream:gradle:-SNAPSHOT")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.3.0")
}
}

Expand Down Expand Up @@ -88,4 +88,4 @@ subprojects {

task<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
systemProp.com.lagradost.cloudstream3.app.testmode=true