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..39fcec4625e 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt @@ -61,6 +61,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 +75,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, + @JsonProperty("internalName") @SerialName("internalName") val internalName: String, + @JsonProperty("url") @SerialName("url") val url: String?, + @JsonProperty("isOnline") @SerialName("isOnline") val isOnline: Boolean, + @JsonProperty("filePath") @SerialName("filePath") val filePath: String, + @JsonProperty("version") @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..4455a1d5e5e 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/plugins/RepositoryManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/plugins/RepositoryManager.kt @@ -19,6 +19,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 +30,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 + @JsonProperty("iconUrl") @SerialName("iconUrl") val iconUrl: String?, + @JsonProperty("name") @SerialName("name") val name: String, + @JsonProperty("description") @SerialName("description") val description: String?, + @JsonProperty("manifestVersion") @SerialName("manifestVersion") val manifestVersion: Int, + @JsonProperty("pluginLists") @SerialName("pluginLists") val pluginLists: List, ) /** @@ -44,36 +46,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, + @JsonProperty("url") @SerialName("url") val url: String, // Status to remotely disable the provider - @JsonProperty("status") val status: Int, + @JsonProperty("status") @SerialName("status") val status: Int, // Integer over 0, any change of this will trigger an auto update - @JsonProperty("version") val version: Int, + @JsonProperty("version") @SerialName("version") val version: Int, // Unused currently, used to make the api backwards compatible? // Set to 1 - @JsonProperty("apiVersion") val apiVersion: Int, + @JsonProperty("apiVersion") @SerialName("apiVersion") val apiVersion: Int, // Name to be shown in app - @JsonProperty("name") val name: String, + @JsonProperty("name") @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?, + @JsonProperty("internalName") @SerialName("internalName") val internalName: String, + @JsonProperty("authors") @SerialName("authors") val authors: List, + @JsonProperty("description") @SerialName("description") val description: String?, // Might be used to go directly to the plugin repo in the future - @JsonProperty("repositoryUrl") val repositoryUrl: String?, + @JsonProperty("repositoryUrl") @SerialName("repositoryUrl") val repositoryUrl: String?, // These types are yet to be mapped and used, ignore for now - @JsonProperty("tvTypes") val tvTypes: List?, + @JsonProperty("tvTypes") @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?, + @JsonProperty("language") @SerialName("language") val language: String?, + @JsonProperty("iconUrl") @SerialName("iconUrl") val iconUrl: String?, // Automatically generated by the gradle plugin - @JsonProperty("fileSize") val fileSize: Long?, - @JsonProperty("fileHash") val fileHash: String?, + @JsonProperty("fileSize") @SerialName("fileSize") val fileSize: Long?, + @JsonProperty("fileHash") @SerialName("fileHash") val fileHash: String?, ) - object RepositoryManager { const val ONLINE_PLUGINS_FOLDER = "Extensions" val PREBUILT_REPOSITORIES: Array by lazy { @@ -134,7 +136,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() } } @@ -153,7 +155,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 +165,6 @@ object RepositoryManager { }.flatten() } - suspend fun downloadPluginToFile( context: Context, pluginUrl: String, @@ -229,7 +230,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..0ceaa77e566 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/plugins/VotingApi.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/plugins/VotingApi.kt @@ -2,6 +2,7 @@ package com.lagradost.cloudstream3.plugins import android.util.Log import android.widget.Toast +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 @@ -11,9 +12,10 @@ 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 { - private const val LOGKEY = "VotingApi" private const val API_DOMAIN = "https://api.countify.xyz" @@ -91,8 +93,9 @@ object VotingApi { } } + @Serializable private data class CountifyResult( - val id: String? = null, - val count: Int? = null + @JsonProperty("id") @SerialName("id") val id: String? = null, + @JsonProperty("count") @SerialName("count") val count: Int? = null, ) }