mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Update PluginManager.kt
This commit is contained in:
parent
39bc4f411d
commit
75968ff095
1 changed files with 25 additions and 16 deletions
|
@ -289,7 +289,7 @@ object PluginManager {
|
|||
* 2. Fetch all not downloaded plugins
|
||||
* 3. Download them and reload plugins
|
||||
**/
|
||||
fun downloadNotExistingPluginsAndLoad(activity: Activity) {
|
||||
fun downloadNotExistingPluginsAndLoad(activity: Activity, mode: AutoDownloadMode) {
|
||||
val newDownloadPlugins = mutableListOf<String>()
|
||||
val urls = (getKey<Array<RepositoryData>>(REPOSITORIES_KEY)
|
||||
?: emptyArray()) + PREBUILT_REPOSITORIES
|
||||
|
@ -303,6 +303,8 @@ object PluginManager {
|
|||
// Iterate online repos and returns not downloaded plugins
|
||||
val notDownloadedPlugins = onlinePlugins.mapNotNull { onlineData ->
|
||||
val sitePlugin = onlineData.second
|
||||
val tvtypes = sitePlugin.tvTypes ?: listOf()
|
||||
|
||||
//Don't include empty urls
|
||||
if (sitePlugin.url.isBlank()) {
|
||||
return@mapNotNull null
|
||||
|
@ -317,22 +319,29 @@ object PluginManager {
|
|||
return@mapNotNull null
|
||||
}
|
||||
|
||||
//Omit non-NSFW if mode is set to NSFW only
|
||||
if (mode == AutoDownloadMode.NsfwOnly) {
|
||||
if (tvtypes.contains(TvType.NSFW.name) == false) {
|
||||
return@mapNotNull null
|
||||
}
|
||||
}
|
||||
//Omit NSFW, if disabled
|
||||
if (!settingsForProvider.enableAdult) {
|
||||
if (tvtypes.contains(TvType.NSFW.name)) {
|
||||
return@mapNotNull null
|
||||
}
|
||||
}
|
||||
|
||||
//Omit lang not selected on language setting
|
||||
if (mode == AutoDownloadMode.FilterByLang) {
|
||||
val lang = sitePlugin.language ?: return@mapNotNull null
|
||||
//If set to 'universal', don't skip any language
|
||||
if (!providerLang.contains(AllLanguagesName) && !providerLang.contains(lang)) {
|
||||
return@mapNotNull null
|
||||
}
|
||||
//Log.i(TAG, "sitePlugin lang => $lang")
|
||||
}
|
||||
|
||||
//Omit NSFW, if disabled
|
||||
sitePlugin.tvTypes?.let { tvtypes ->
|
||||
if (!settingsForProvider.enableAdult) {
|
||||
if (tvtypes.contains(TvType.NSFW.name)) {
|
||||
return@mapNotNull null
|
||||
}
|
||||
}
|
||||
}
|
||||
val savedData = PluginData(
|
||||
url = sitePlugin.url,
|
||||
internalName = sitePlugin.internalName,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue