refact: check if extractor class exist for v4.3.0

This commit is contained in:
int3debug 2024-03-26 23:11:17 +01:00
parent d540c0702c
commit 3567e61131

View file

@ -7,6 +7,17 @@ import android.content.Context
@CloudstreamPlugin @CloudstreamPlugin
class SoraStreamPlugin: Plugin() { class SoraStreamPlugin: Plugin() {
private fun classExist(className: String) : Boolean {
try {
Class.forName(className)
} catch (e: Exception) {
return false
}
return true
}
override fun load(context: Context) { override fun load(context: Context) {
// All providers should be added in this manner. Please don't edit the providers list directly. // All providers should be added in this manner. Please don't edit the providers list directly.
registerMainAPI(SoraStream()) registerMainAPI(SoraStream())
@ -19,7 +30,11 @@ class SoraStreamPlugin: Plugin() {
registerExtractorAPI(TravelR()) registerExtractorAPI(TravelR())
registerExtractorAPI(Playm4u()) registerExtractorAPI(Playm4u())
registerExtractorAPI(VCloud()) registerExtractorAPI(VCloud())
registerExtractorAPI(Pixeldra())
if (classExist("com.lagradost.cloudstream3.extractors.PixelDrain")) {
registerExtractorAPI(Pixeldra())
}
registerExtractorAPI(M4ufree()) registerExtractorAPI(M4ufree())
registerExtractorAPI(Streamruby()) registerExtractorAPI(Streamruby())
registerExtractorAPI(Streamwish()) registerExtractorAPI(Streamwish())