Skip to content
Merged
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
91 changes: 33 additions & 58 deletions app/src/main/java/com/lagradost/cloudstream3/AcraApplication.kt
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to note/provide some background/rational for changes here: the way the wrappers are here now is how it was when I first changed it to CloudStreamApp, however in d43a371 I changed it because CloudStreamApp didn't exist on stable so had some crash issues. Now that CloudStreamApp does exist on stable as well, we can now do this with wrappers around CloudStreamApp methods again, which removes setting AcraApplication.context from CloudStreamApp and thus easier if/when AcraApplication is fully removed as well as more easily manage any future changes with less code duplication.

Original file line number Diff line number Diff line change
@@ -1,103 +1,78 @@
package com.lagradost.cloudstream3

import android.content.Context
import com.lagradost.api.setContext
import com.lagradost.cloudstream3.utils.DataStore.getKey
import com.lagradost.cloudstream3.utils.DataStore.removeKeys
import com.lagradost.cloudstream3.utils.DataStore.setKey
import java.lang.ref.WeakReference

/**
* Deprecated alias for CloudStreamApp for backwards compatibility with plugins.
* Use CloudStreamApp instead.
*/
// Deprecate after next stable
/*@Deprecated(
@Deprecated(
message = "AcraApplication is deprecated, use CloudStreamApp instead",
replaceWith = ReplaceWith("com.lagradost.cloudstream3.CloudStreamApp"),
level = DeprecationLevel.WARNING
)*/
)
class AcraApplication {
// All methods here can be changed to be a wrapper around CloudStream app
// without a seperate deprecation after next stable. All methods should
// also be deprecated at that time.
companion object {

// This can be removed without deprecation after next stable
private var _context: WeakReference<Context>? = null
/*@Deprecated(
@Deprecated(
message = "AcraApplication is deprecated, use CloudStreamApp instead",
replaceWith = ReplaceWith("com.lagradost.cloudstream3.CloudStreamApp.context"),
level = DeprecationLevel.WARNING
)*/
var context
get() = _context?.get()
internal set(value) {
_context = WeakReference(value)
setContext(WeakReference(value))
}
)
val context get() = CloudStreamApp.context

/*@Deprecated(
@Deprecated(
message = "AcraApplication is deprecated, use CloudStreamApp instead",
replaceWith = ReplaceWith("com.lagradost.cloudstream3.CloudStreamApp.removeKeys(folder)"),
level = DeprecationLevel.WARNING
)*/
fun removeKeys(folder: String): Int? {
return context?.removeKeys(folder)
}
)
fun removeKeys(folder: String): Int? =
CloudStreamApp.removeKeys(folder)

/*@Deprecated(
@Deprecated(
message = "AcraApplication is deprecated, use CloudStreamApp instead",
replaceWith = ReplaceWith("com.lagradost.cloudstream3.CloudStreamApp.setKey(path, value)"),
level = DeprecationLevel.WARNING
)*/
fun <T> setKey(path: String, value: T) {
context?.setKey(path, value)
}
)
fun <T> setKey(path: String, value: T) =
CloudStreamApp.setKey(path, value)

/*@Deprecated(
@Deprecated(
message = "AcraApplication is deprecated, use CloudStreamApp instead",
replaceWith = ReplaceWith("com.lagradost.cloudstream3.CloudStreamApp.setKey(folder, path, value)"),
level = DeprecationLevel.WARNING
)*/
fun <T> setKey(folder: String, path: String, value: T) {
context?.setKey(folder, path, value)
}
)
fun <T> setKey(folder: String, path: String, value: T) =
CloudStreamApp.setKey(folder, path, value)

/*@Deprecated(
@Deprecated(
message = "AcraApplication is deprecated, use CloudStreamApp instead",
replaceWith = ReplaceWith("com.lagradost.cloudstream3.CloudStreamApp.getKey(path, defVal)"),
level = DeprecationLevel.WARNING
)*/
inline fun <reified T : Any> getKey(path: String, defVal: T?): T? {
return context?.getKey(path, defVal)
}
)
inline fun <reified T : Any> getKey(path: String, defVal: T?): T? =
CloudStreamApp.getKey(path, defVal)

/*@Deprecated(
@Deprecated(
message = "AcraApplication is deprecated, use CloudStreamApp instead",
replaceWith = ReplaceWith("com.lagradost.cloudstream3.CloudStreamApp.getKey(path)"),
level = DeprecationLevel.WARNING
)*/
inline fun <reified T : Any> getKey(path: String): T? {
return context?.getKey(path)
}
)
inline fun <reified T : Any> getKey(path: String): T? =
CloudStreamApp.getKey(path)

/*@Deprecated(
@Deprecated(
message = "AcraApplication is deprecated, use CloudStreamApp instead",
replaceWith = ReplaceWith("com.lagradost.cloudstream3.CloudStreamApp.getKey(folder, path)"),
level = DeprecationLevel.WARNING
)*/
inline fun <reified T : Any> getKey(folder: String, path: String): T? {
return context?.getKey(folder, path)
}
)
inline fun <reified T : Any> getKey(folder: String, path: String): T? =
CloudStreamApp.getKey(folder, path)

/*@Deprecated(
@Deprecated(
message = "AcraApplication is deprecated, use CloudStreamApp instead",
replaceWith = ReplaceWith("com.lagradost.cloudstream3.CloudStreamApp.getKey(folder, path, defVal)"),
level = DeprecationLevel.WARNING
)*/
inline fun <reified T : Any> getKey(folder: String, path: String, defVal: T?): T? {
return context?.getKey(folder, path, defVal)
}
)
inline fun <reified T : Any> getKey(folder: String, path: String, defVal: T?): T? =
CloudStreamApp.getKey(folder, path, defVal)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class ExceptionHandler(
}
}

@Prerelease
class CloudStreamApp : Application(), SingletonImageLoader.Factory {

override fun onCreate() {
Expand All @@ -90,8 +89,6 @@ class CloudStreamApp : Application(), SingletonImageLoader.Factory {
override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)
context = base
// This can be removed without deprecation after next stable
AcraApplication.context = context
}

override fun newImageLoader(context: PlatformContext): ImageLoader {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,6 @@ suspend fun newSubtitleFile(
* @property headers Optional headers for the audio file request.
* @see newAudioFile
* */
@Prerelease
@ConsistentCopyVisibility
data class AudioFile internal constructor(
var url: String,
Expand All @@ -1171,7 +1170,6 @@ data class AudioFile internal constructor(
* @param initializer Lambda to configure additional properties like headers.
* @return Configured AudioFile instance.
* */
@Prerelease
suspend fun newAudioFile(
url: String,
initializer: suspend AudioFile.() -> Unit = { }
Expand Down Expand Up @@ -1786,7 +1784,6 @@ interface LoadResponse {
var posterHeaders: Map<String, String>?
var backgroundPosterUrl: String?

@Prerelease
var logoUrl: String?
var contentRating: String?

Expand Down Expand Up @@ -1893,7 +1890,6 @@ interface LoadResponse {
this.addSimklId(SimklSyncServices.Mal, id.toString())
}

@Prerelease
fun LoadResponse.addKitsuId(id: Int?) {
this.syncData[kitsuIdPrefix] = (id ?: return).toString()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.lagradost.cloudstream3.extractors

import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.Prerelease
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.base64DecodeArray
Expand All @@ -15,31 +14,26 @@ import javax.crypto.Cipher
import javax.crypto.spec.GCMParameterSpec
import javax.crypto.spec.SecretKeySpec

@Prerelease
class Bysezejataos : ByseSX() {
override var name = "Bysezejataos"
override var mainUrl = "https://bysezejataos.com"
}

@Prerelease
class ByseBuho : ByseSX() {
override var name = "ByseBuho"
override var mainUrl = "https://bysebuho.com"
}

@Prerelease
class ByseVepoin : ByseSX() {
override var name = "ByseVepoin"
override var mainUrl = "https://bysevepoin.com"
}

@Prerelease
class ByseQekaho : ByseSX() {
override var name = "ByseQekaho"
override var mainUrl = "https://byseqekaho.com"
}

@Prerelease
open class ByseSX : ExtractorApi() {
override var name = "Byse"
override var mainUrl = "https://byse.sx"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.lagradost.cloudstream3.extractors

import com.lagradost.api.Log
import com.lagradost.cloudstream3.Prerelease
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.amap
import com.lagradost.cloudstream3.app
Expand All @@ -12,7 +11,6 @@ import com.lagradost.cloudstream3.utils.loadExtractor
import com.lagradost.cloudstream3.utils.newExtractorLink
import java.net.URI

@Prerelease
class HubCloud : ExtractorApi() {
override val name = "Hub-Cloud"
override val mainUrl = "https://hubcloud.*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package com.lagradost.cloudstream3.extractors

import com.lagradost.cloudstream3.Prerelease

open class OkRuSSL : Odnoklassniki() {
override var name = "OkRuSSL"
override var mainUrl = "https://ok.ru"
Expand All @@ -14,12 +12,10 @@ open class OkRuHTTP : Odnoklassniki() {
override var mainUrl = "http://ok.ru"
}

@Prerelease
class OkRuSSLMobile : OkRuSSL() {
override var mainUrl = "https://m.ok.ru"
}

@Prerelease
class OkRuHTTPMobile : OkRuHTTP() {
override var mainUrl = "http://m.ok.ru"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package com.lagradost.cloudstream3.extractors
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.*

@Prerelease
class PixelDrainDev : PixelDrain() {
override var mainUrl = "https://pixeldrain.dev"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Made by @kraptor123 for cs-kraptor
package com.lagradost.cloudstream3.extractors

import com.lagradost.cloudstream3.Prerelease
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.utils.ExtractorApi
Expand All @@ -10,7 +9,6 @@ import com.lagradost.cloudstream3.utils.ExtractorLinkType
import com.lagradost.cloudstream3.utils.getQualityFromName
import com.lagradost.cloudstream3.utils.newExtractorLink

@Prerelease
open class VkExtractor : ExtractorApi() {
override val name = "Vk"
override val mainUrl = "https://vkvideo.ru"
Expand Down