From 35ee3f206798482bbab71de113a6eff16d6d5df0 Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Thu, 4 Jun 2026 13:44:35 -0600 Subject: [PATCH 1/2] plugins: migrate to kotlinx serialization --- .../cloudstream3/plugins/PluginManager.kt | 14 ++--- .../cloudstream3/plugins/RepositoryManager.kt | 54 +++++++++---------- .../cloudstream3/plugins/VotingApi.kt | 7 ++- 3 files changed, 40 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt b/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt index debd3f0ebbd..2b252e46536 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt @@ -18,7 +18,6 @@ import androidx.core.app.ActivityCompat import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import androidx.fragment.app.FragmentActivity -import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.cloudstream3.APIHolder import com.lagradost.cloudstream3.APIHolder.removePluginMapping import com.lagradost.cloudstream3.AllLanguagesName @@ -61,6 +60,8 @@ import com.lagradost.cloudstream3.utils.txt import dalvik.system.PathClassLoader import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import java.io.File import java.io.InputStreamReader @@ -73,12 +74,13 @@ const val EXTENSIONS_CHANNEL_NAME = "Extensions" const val EXTENSIONS_CHANNEL_DESCRIPT = "Extension notification channel" // Data class for internal storage +@Serializable data class PluginData( - @JsonProperty("internalName") val internalName: String, - @JsonProperty("url") val url: String?, - @JsonProperty("isOnline") val isOnline: Boolean, - @JsonProperty("filePath") val filePath: String, - @JsonProperty("version") val version: Int, + @SerialName("internalName") val internalName: String, + @SerialName("url") val url: String?, + @SerialName("isOnline") val isOnline: Boolean, + @SerialName("filePath") val filePath: String, + @SerialName("version") val version: Int, ) { @WorkerThread fun toSitePlugin(): SitePlugin { diff --git a/app/src/main/java/com/lagradost/cloudstream3/plugins/RepositoryManager.kt b/app/src/main/java/com/lagradost/cloudstream3/plugins/RepositoryManager.kt index 07d6aaa37bc..1feccf9fbb2 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/plugins/RepositoryManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/plugins/RepositoryManager.kt @@ -2,7 +2,6 @@ package com.lagradost.cloudstream3.plugins import android.content.Context import androidx.annotation.WorkerThread -import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.cloudstream3.CloudStreamApp.Companion.context import com.lagradost.cloudstream3.CloudStreamApp.Companion.getKey import com.lagradost.cloudstream3.CloudStreamApp.Companion.setKey @@ -19,6 +18,8 @@ import com.lagradost.cloudstream3.ui.settings.extensions.RepositoryData import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import java.io.File import java.nio.file.AtomicMoveNotSupportedException import java.nio.file.Files @@ -28,14 +29,14 @@ import java.util.concurrent.atomic.AtomicInteger /** * Comes with the app, always available in the app, non removable. - * */ - + */ +@Serializable data class Repository( - @JsonProperty("iconUrl") val iconUrl: String?, - @JsonProperty("name") val name: String, - @JsonProperty("description") val description: String?, - @JsonProperty("manifestVersion") val manifestVersion: Int, - @JsonProperty("pluginLists") val pluginLists: List + @SerialName("iconUrl") val iconUrl: String?, + @SerialName("name") val name: String, + @SerialName("description") val description: String?, + @SerialName("manifestVersion") val manifestVersion: Int, + @SerialName("pluginLists") val pluginLists: List, ) /** @@ -44,36 +45,36 @@ data class Repository( * 1: Ok * 2: Slow * 3: Beta only - * */ + */ +@Serializable data class SitePlugin( // Url to the .cs3 file - @JsonProperty("url") val url: String, + @SerialName("url") val url: String, // Status to remotely disable the provider - @JsonProperty("status") val status: Int, + @SerialName("status") val status: Int, // Integer over 0, any change of this will trigger an auto update - @JsonProperty("version") val version: Int, + @SerialName("version") val version: Int, // Unused currently, used to make the api backwards compatible? // Set to 1 - @JsonProperty("apiVersion") val apiVersion: Int, + @SerialName("apiVersion") val apiVersion: Int, // Name to be shown in app - @JsonProperty("name") val name: String, + @SerialName("name") val name: String, // Name to be referenced internally. Separate to make name and url changes possible - @JsonProperty("internalName") val internalName: String, - @JsonProperty("authors") val authors: List, - @JsonProperty("description") val description: String?, + @SerialName("internalName") val internalName: String, + @SerialName("authors") val authors: List, + @SerialName("description") val description: String?, // Might be used to go directly to the plugin repo in the future - @JsonProperty("repositoryUrl") val repositoryUrl: String?, + @SerialName("repositoryUrl") val repositoryUrl: String?, // These types are yet to be mapped and used, ignore for now - @JsonProperty("tvTypes") val tvTypes: List?, + @SerialName("tvTypes") val tvTypes: List?, // Most often a language tag like "en" or "zh-TW" - @JsonProperty("language") val language: String?, - @JsonProperty("iconUrl") val iconUrl: String?, + @SerialName("language") val language: String?, + @SerialName("iconUrl") val iconUrl: String?, // Automatically generated by the gradle plugin - @JsonProperty("fileSize") val fileSize: Long?, - @JsonProperty("fileHash") val fileHash: String?, + @SerialName("fileSize") val fileSize: Long?, + @SerialName("fileHash") val fileHash: String?, ) - object RepositoryManager { const val ONLINE_PLUGINS_FOLDER = "Extensions" val PREBUILT_REPOSITORIES: Array by lazy { @@ -153,7 +154,7 @@ object RepositoryManager { /** * Gets all plugins from repositories and pairs them with the repository url - * */ + */ suspend fun getRepoPlugins(repositoryUrl: String): List>? { val repo = parseRepository(repositoryUrl) ?: return null return repo.pluginLists.amap { url -> @@ -163,7 +164,6 @@ object RepositoryManager { }.flatten() } - suspend fun downloadPluginToFile( context: Context, pluginUrl: String, @@ -229,7 +229,7 @@ object RepositoryManager { /** * Also deletes downloaded repository plugins - * */ + */ suspend fun removeRepository(context: Context, repository: RepositoryData) { val extensionsDir = File(context.filesDir, ONLINE_PLUGINS_FOLDER) diff --git a/app/src/main/java/com/lagradost/cloudstream3/plugins/VotingApi.kt b/app/src/main/java/com/lagradost/cloudstream3/plugins/VotingApi.kt index 85a806f0b12..a6f30267a37 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/plugins/VotingApi.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/plugins/VotingApi.kt @@ -11,6 +11,8 @@ import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.Coroutines.main import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable object VotingApi { @@ -91,8 +93,9 @@ object VotingApi { } } + @Serializable private data class CountifyResult( - val id: String? = null, - val count: Int? = null + @SerialName("id") val id: String? = null, + @SerialName("count") val count: Int? = null, ) } From 9526ba5d75dabde335cd30163d1cc1920ec86a15 Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Sat, 6 Jun 2026 13:27:33 -0600 Subject: [PATCH 2/2] Fix --- .../com/lagradost/cloudstream3/plugins/RepositoryManager.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/plugins/RepositoryManager.kt b/app/src/main/java/com/lagradost/cloudstream3/plugins/RepositoryManager.kt index 1feccf9fbb2..f7ca0f20235 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/plugins/RepositoryManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/plugins/RepositoryManager.kt @@ -135,7 +135,7 @@ object RepositoryManager { suspend fun parseRepository(url: String): Repository? { return safeAsync { // Take manifestVersion and such into account later - app.get(convertRawGitUrl(url)).parsedSafe() + app.get(convertRawGitUrl(url)).parsedSafe() } }