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

61 lines
1.8 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
2022-08-09 15:19:26 +00:00
import com.fasterxml.jackson.annotation.JsonProperty
2022-08-09 08:33:16 +00:00
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")
2022-08-09 15:19:26 +00:00
element.sourcePlugin = this.__filename
2022-08-09 08:33:16 +00:00
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")
2022-08-09 15:19:26 +00:00
element.sourcePlugin = this.__filename
2022-08-09 08:33:16 +00:00
extractorApis.add(element)
}
2022-08-06 15:48:00 +00:00
class Manifest {
2022-08-09 15:19:26 +00:00
@JsonProperty("name") var name: String? = null
@JsonProperty("pluginClassName") var pluginClassName: String? = null
@JsonProperty("version") var version: 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
}