mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
688bbd5ec3
6 changed files with 153 additions and 17 deletions
123
.idea/codeStyles/Project.xml
Normal file
123
.idea/codeStyles/Project.xml
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<JetCodeStyleSettings>
|
||||||
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
|
</JetCodeStyleSettings>
|
||||||
|
<codeStyleSettings language="XML">
|
||||||
|
<option name="FORCE_REARRANGE_MODE" value="1" />
|
||||||
|
<indentOptions>
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
</indentOptions>
|
||||||
|
<arrangement>
|
||||||
|
<rules>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:android</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:id</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:name</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>name</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>style</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
</rules>
|
||||||
|
</arrangement>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="kotlin">
|
||||||
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
|
</codeStyleSettings>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||||
|
</state>
|
||||||
|
</component>
|
|
@ -8,6 +8,7 @@ import com.lagradost.cloudstream3.APIHolder
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorApi
|
import com.lagradost.cloudstream3.utils.ExtractorApi
|
||||||
import com.lagradost.cloudstream3.utils.extractorApis
|
import com.lagradost.cloudstream3.utils.extractorApis
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
|
||||||
const val PLUGIN_TAG = "PluginInstance"
|
const val PLUGIN_TAG = "PluginInstance"
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ abstract class Plugin {
|
||||||
*/
|
*/
|
||||||
fun registerMainAPI(element: MainAPI) {
|
fun registerMainAPI(element: MainAPI) {
|
||||||
Log.i(PLUGIN_TAG, "Adding ${element.name} (${element.mainUrl}) MainAPI")
|
Log.i(PLUGIN_TAG, "Adding ${element.name} (${element.mainUrl}) MainAPI")
|
||||||
element.sourcePlugin = this.`__filename`
|
element.sourcePlugin = this.__filename
|
||||||
APIHolder.allProviders.add(element)
|
APIHolder.allProviders.add(element)
|
||||||
APIHolder.addPluginMapping(element)
|
APIHolder.addPluginMapping(element)
|
||||||
}
|
}
|
||||||
|
@ -44,17 +45,17 @@ abstract class Plugin {
|
||||||
*/
|
*/
|
||||||
fun registerExtractorAPI(element: ExtractorApi) {
|
fun registerExtractorAPI(element: ExtractorApi) {
|
||||||
Log.i(PLUGIN_TAG, "Adding ${element.name} (${element.mainUrl}) ExtractorApi")
|
Log.i(PLUGIN_TAG, "Adding ${element.name} (${element.mainUrl}) ExtractorApi")
|
||||||
element.sourcePlugin = this.`__filename`
|
element.sourcePlugin = this.__filename
|
||||||
extractorApis.add(element)
|
extractorApis.add(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
class Manifest {
|
class Manifest {
|
||||||
var name: String? = null
|
@JsonProperty("name") var name: String? = null
|
||||||
var pluginClassName: String? = null
|
@JsonProperty("pluginClassName") var pluginClassName: String? = null
|
||||||
var pluginVersion: Int? = null
|
@JsonProperty("version") var version: Int? = null
|
||||||
|
@JsonProperty("requiresResources") var requiresResources: Boolean = false
|
||||||
}
|
}
|
||||||
|
|
||||||
var resources: Resources? = null
|
var resources: Resources? = null
|
||||||
var needsResources = false
|
|
||||||
var __filename: String? = null
|
var __filename: String? = null
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package com.lagradost.cloudstream3.plugins
|
package com.lagradost.cloudstream3.plugins
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import dalvik.system.PathClassLoader
|
import dalvik.system.PathClassLoader
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import android.content.res.AssetManager
|
import android.content.res.AssetManager
|
||||||
|
@ -24,6 +23,7 @@ import com.lagradost.cloudstream3.ui.settings.extensions.REPOSITORIES_KEY
|
||||||
import com.lagradost.cloudstream3.ui.settings.extensions.RepositoryData
|
import com.lagradost.cloudstream3.ui.settings.extensions.RepositoryData
|
||||||
import com.lagradost.cloudstream3.utils.VideoDownloadManager.sanitizeFilename
|
import com.lagradost.cloudstream3.utils.VideoDownloadManager.sanitizeFilename
|
||||||
import com.lagradost.cloudstream3.APIHolder
|
import com.lagradost.cloudstream3.APIHolder
|
||||||
|
import com.lagradost.cloudstream3.APIHolder.removePluginMapping
|
||||||
import com.lagradost.cloudstream3.MainAPI
|
import com.lagradost.cloudstream3.MainAPI
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorApi
|
import com.lagradost.cloudstream3.utils.ExtractorApi
|
||||||
import com.lagradost.cloudstream3.utils.extractorApis
|
import com.lagradost.cloudstream3.utils.extractorApis
|
||||||
|
@ -139,7 +139,7 @@ object PluginManager {
|
||||||
* 4. Else load the plugin normally
|
* 4. Else load the plugin normally
|
||||||
**/
|
**/
|
||||||
fun updateAllOnlinePluginsAndLoadThem(activity: Activity) {
|
fun updateAllOnlinePluginsAndLoadThem(activity: Activity) {
|
||||||
val urls = getKey<Array<RepositoryData>>(REPOSITORIES_KEY) ?: emptyArray()
|
val urls = (getKey<Array<RepositoryData>>(REPOSITORIES_KEY) ?: emptyArray()) + PREBUILT_REPOSITORIES
|
||||||
|
|
||||||
val onlinePlugins = urls.toList().apmap {
|
val onlinePlugins = urls.toList().apmap {
|
||||||
getRepoPlugins(it.url)?.toList() ?: emptyList()
|
getRepoPlugins(it.url)?.toList() ?: emptyList()
|
||||||
|
@ -236,7 +236,7 @@ object PluginManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
val name: String = manifest.name ?: "NO NAME"
|
val name: String = manifest.name ?: "NO NAME"
|
||||||
val version: Int = manifest.pluginVersion ?: PLUGIN_VERSION_NOT_SET
|
val version: Int = manifest.version ?: PLUGIN_VERSION_NOT_SET
|
||||||
val pluginClass: Class<*> =
|
val pluginClass: Class<*> =
|
||||||
loader.loadClass(manifest.pluginClassName) as Class<out Plugin?>
|
loader.loadClass(manifest.pluginClassName) as Class<out Plugin?>
|
||||||
val pluginInstance: Plugin =
|
val pluginInstance: Plugin =
|
||||||
|
@ -251,7 +251,8 @@ object PluginManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginInstance.__filename = fileName
|
pluginInstance.__filename = fileName
|
||||||
if (pluginInstance.needsResources) {
|
if (manifest.requiresResources) {
|
||||||
|
Log.d(TAG, "Loading resources for ${data.internalName}")
|
||||||
// based on https://stackoverflow.com/questions/7483568/dynamic-resource-loading-from-other-apk
|
// based on https://stackoverflow.com/questions/7483568/dynamic-resource-loading-from-other-apk
|
||||||
val assets = AssetManager::class.java.newInstance()
|
val assets = AssetManager::class.java.newInstance()
|
||||||
val addAssetPath =
|
val addAssetPath =
|
||||||
|
@ -280,6 +281,7 @@ object PluginManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun unloadPlugin(absolutePath: String) {
|
private suspend fun unloadPlugin(absolutePath: String) {
|
||||||
|
Log.i(TAG, "Unloading plugin: $absolutePath")
|
||||||
var plugin = plugins.get(absolutePath)
|
var plugin = plugins.get(absolutePath)
|
||||||
if (plugin == null) {
|
if (plugin == null) {
|
||||||
Log.w(TAG, "Couldn't find plugin $absolutePath")
|
Log.w(TAG, "Couldn't find plugin $absolutePath")
|
||||||
|
@ -293,8 +295,13 @@ object PluginManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove all registered apis
|
// remove all registered apis
|
||||||
APIHolder.allProviders.removeIf { provider: MainAPI -> provider.sourcePlugin == plugin.`__filename` }
|
APIHolder.apis.filter { it -> it.sourcePlugin == plugin.__filename }.forEach {
|
||||||
extractorApis.removeIf { provider: ExtractorApi -> provider.sourcePlugin == plugin.`__filename` }
|
removePluginMapping(it)
|
||||||
|
}
|
||||||
|
APIHolder.allProviders.removeIf { provider: MainAPI -> provider.sourcePlugin == plugin.__filename }
|
||||||
|
extractorApis.removeIf { provider: ExtractorApi -> provider.sourcePlugin == plugin.__filename }
|
||||||
|
|
||||||
|
classLoaders.values.removeIf { v -> v == plugin}
|
||||||
|
|
||||||
plugins.remove(absolutePath)
|
plugins.remove(absolutePath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,11 +62,11 @@ data class SitePlugin(
|
||||||
// Might be used to go directly to the plugin repo in the future
|
// Might be used to go directly to the plugin repo in the future
|
||||||
@JsonProperty("repositoryUrl") val repositoryUrl: String?,
|
@JsonProperty("repositoryUrl") val repositoryUrl: String?,
|
||||||
// These types are yet to be mapped and used, ignore for now
|
// These types are yet to be mapped and used, ignore for now
|
||||||
@JsonProperty("tvTypes") val tvTypes: List<String>?,
|
// @JsonProperty("tvTypes") val tvTypes: List<String>?,
|
||||||
@JsonProperty("language") val language: String?,
|
// @JsonProperty("language") val language: String?,
|
||||||
@JsonProperty("iconUrl") val iconUrl: String?,
|
// @JsonProperty("iconUrl") val iconUrl: String?,
|
||||||
// Set to true to get an 18+ symbol next to the plugin
|
// Set to true to get an 18+ symbol next to the plugin
|
||||||
@JsonProperty("isAdult") val isAdult: Boolean?,
|
@JsonProperty("adult") val adult: Boolean?,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ class PluginAdapter(
|
||||||
R.drawable.ic_baseline_delete_outline_24
|
R.drawable.ic_baseline_delete_outline_24
|
||||||
else R.drawable.netflix_download
|
else R.drawable.netflix_download
|
||||||
|
|
||||||
itemView.nsfw_marker?.isVisible = metadata.isAdult == true
|
itemView.nsfw_marker?.isVisible = metadata.adult == true
|
||||||
itemView.action_button?.setImageResource(drawableInt)
|
itemView.action_button?.setImageResource(drawableInt)
|
||||||
|
|
||||||
itemView.action_button?.setOnClickListener {
|
itemView.action_button?.setOnClickListener {
|
||||||
|
|
Loading…
Reference in a new issue