Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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<String>
@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<String>,
)

/**
Expand All @@ -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<String>,
@JsonProperty("description") val description: String?,
@SerialName("internalName") val internalName: String,
@SerialName("authors") val authors: List<String>,
@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<String>?,
@SerialName("tvTypes") val tvTypes: List<String>?,
// 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<RepositoryData> by lazy {
Expand Down Expand Up @@ -134,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<Repository>()
}
}

Expand All @@ -153,7 +154,7 @@ object RepositoryManager {

/**
* Gets all plugins from repositories and pairs them with the repository url
* */
*/
suspend fun getRepoPlugins(repositoryUrl: String): List<Pair<String, SitePlugin>>? {
val repo = parseRepository(repositoryUrl) ?: return null
return repo.pluginLists.amap { url ->
Expand All @@ -163,7 +164,6 @@ object RepositoryManager {
}.flatten()
}


suspend fun downloadPluginToFile(
context: Context,
pluginUrl: String,
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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,
)
}