cloudstream/app/src/main/java/com/lagradost/cloudstream3/plugins/Plugin.kt

60 lines
1.7 KiB
Kotlin
Raw Normal View History

2022-08-06 15:48:00 +00:00
package com.lagradost.cloudstream3.plugins
2022-08-04 10:51:11 +00:00
2022-08-06 15:48:00 +00:00
import android.content.Context
import android.content.res.Resources
import kotlin.Throws
2022-08-09 08:33:16 +00:00
import com.lagradost.cloudstream3.MainAPI
import com.lagradost.cloudstream3.APIHolder
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.extractorApis
import android.util.Log
const val PLUGIN_TAG = "PluginInstance"
2022-08-04 10:51:11 +00:00
2022-08-06 15:48:00 +00:00
abstract class Plugin {
2022-08-04 10:51:11 +00:00
/**
* Called when your Plugin is loaded
* @param context Context
*/
2022-08-06 15:48:00 +00:00
@Throws(Throwable::class)
2022-08-07 23:03:54 +00:00
open fun load(context: Context) {
2022-08-04 10:51:11 +00:00
}
2022-08-09 08:33:16 +00:00
/**
* Called when your Plugin is being unloaded
*/
@Throws(Throwable::class)
open fun beforeUnload() {
}
/**
* Used to register providers instances of MainAPI
* @param element MainAPI provider you want to register
*/
fun registerMainAPI(element: MainAPI) {
Log.i(PLUGIN_TAG, "Adding ${element.name} (${element.mainUrl}) MainAPI")
element.sourcePlugin = this.`__filename`
APIHolder.allProviders.add(element)
APIHolder.addPluginMapping(element)
2022-08-09 08:33:16 +00:00
}
/**
* Used to register extractor instances of ExtractorApi
* @param element ExtractorApi provider you want to register
*/
fun registerExtractorAPI(element: ExtractorApi) {
Log.i(PLUGIN_TAG, "Adding ${element.name} (${element.mainUrl}) ExtractorApi")
element.sourcePlugin = this.`__filename`
extractorApis.add(element)
}
2022-08-06 15:48:00 +00:00
class Manifest {
var name: String? = null
var pluginClassName: String? = null
var pluginVersion: Int? = null
2022-08-06 15:48:00 +00:00
}
2022-08-04 10:51:11 +00:00
2022-08-06 15:48:00 +00:00
var resources: Resources? = null
var needsResources = false
var __filename: String? = null
2022-08-04 10:51:11 +00:00
}