Fix many build warnings/deprecations (#1478)

This commit is contained in:
Luna712
2025-01-26 13:25:39 -07:00
committed by GitHub
parent 642004db5a
commit 679f3651f8
18 changed files with 265 additions and 138 deletions

View File

@ -150,8 +150,13 @@ class AcraApplication : Application(), SingletonImageLoader.Factory {
var exceptionHandler: ExceptionHandler? = null
/** Use to get activity from Context */
tailrec fun Context.getActivity(): Activity? = this as? Activity
?: (this as? ContextWrapper)?.baseContext?.getActivity()
tailrec fun Context.getActivity(): Activity? {
return when (this) {
is Activity -> this
is ContextWrapper -> baseContext.getActivity()
else -> null
}
}
private var _context: WeakReference<Context>? = null
var context
@ -225,4 +230,4 @@ class AcraApplication : Application(), SingletonImageLoader.Factory {
)
}
}
}
}

View File

@ -165,7 +165,8 @@ object CommonActivity {
val toast = Toast(act)
toast.duration = duration ?: Toast.LENGTH_SHORT
toast.setGravity(Gravity.CENTER_HORIZONTAL or Gravity.BOTTOM, 0, 5.toPx)
toast.view = binding.root //fixme Find an alternative using default Toasts since custom toasts are deprecated and won't appear with api30 set as minSDK version.
@Suppress("DEPRECATION")
toast.view = binding.root // FIXME Find an alternative using default Toasts since custom toasts are deprecated and won't appear with api30 set as minSDK version.
currentToast = toast
toast.show()
@ -193,7 +194,8 @@ object CommonActivity {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
context.createConfigurationContext(config)
resources.updateConfiguration(config, resources.displayMetrics)
@Suppress("DEPRECATION")
resources.updateConfiguration(config, resources.displayMetrics) // FIXME this should be replaced
}
fun Context.updateLocale() {
@ -255,10 +257,13 @@ object CommonActivity {
try {
enterPictureInPictureMode(PictureInPictureParams.Builder().build())
} catch (e: Exception) {
// Use fallback just in case
@Suppress("DEPRECATION")
enterPictureInPictureMode()
}
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
@Suppress("DEPRECATION")
enterPictureInPictureMode()
}
}
@ -626,4 +631,4 @@ object CommonActivity {
}
return null
}
}
}

View File

@ -1535,6 +1535,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
if (navDestination.matchDestination(R.id.navigation_home)) {
attachBackPressedCallback("MainActivity") {
showConfirmExitDialog(settingsManager)
@Suppress("DEPRECATION")
window?.navigationBarColor =
colorFromAttribute(R.attr.primaryGrayBackground)
updateLocale()
@ -1785,6 +1786,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
this,
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
@Suppress("DEPRECATION")
window?.navigationBarColor = colorFromAttribute(R.attr.primaryGrayBackground)
updateLocale()
@ -1819,4 +1821,4 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
false
}
}
}
}

View File

@ -5,6 +5,7 @@ import android.net.nsd.NsdManager
import android.net.nsd.NsdManager.ResolveListener
import android.net.nsd.NsdServiceInfo
import android.os.Build
import android.os.ext.SdkExtensions
import android.util.Log
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
@ -72,23 +73,52 @@ class FcastManager {
override fun onServiceFound(serviceInfo: NsdServiceInfo?) {
if (serviceInfo == null) return
nsdManager?.resolveService(serviceInfo, object : ResolveListener {
override fun onResolveFailed(serviceInfo: NsdServiceInfo?, errorCode: Int) {
}
override fun onServiceResolved(serviceInfo: NsdServiceInfo?) {
if (serviceInfo == null) return
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && SdkExtensions.getExtensionVersion(
Build.VERSION_CODES.TIRAMISU) >= 7) {
nsdManager?.registerServiceInfoCallback(serviceInfo,
Runnable::run,
object : NsdManager.ServiceInfoCallback {
override fun onServiceInfoCallbackRegistrationFailed(errorCode: Int) {
Log.e(tag, "Service registration failed: $errorCode")
}
override fun onServiceUpdated(serviceInfo: NsdServiceInfo) {
Log.d(tag,
"Service updated: ${serviceInfo.serviceName}," +
"Net: ${serviceInfo.hostAddresses.firstOrNull()?.hostAddress}"
)
synchronized(_currentDevices) {
_currentDevices.removeIf { it.rawName == serviceInfo.serviceName }
_currentDevices.add(PublicDeviceInfo(serviceInfo))
}
}
override fun onServiceLost() {
Log.d(tag, "Service lost: ${serviceInfo.serviceName},")
synchronized(_currentDevices) {
_currentDevices.removeIf { it.rawName == serviceInfo.serviceName }
}
}
override fun onServiceInfoCallbackUnregistered() {}
})
} else {
@Suppress("DEPRECATION")
nsdManager?.resolveService(serviceInfo, object : ResolveListener {
override fun onResolveFailed(serviceInfo: NsdServiceInfo?, errorCode: Int) {}
synchronized(_currentDevices) {
_currentDevices.add(PublicDeviceInfo(serviceInfo))
override fun onServiceResolved(serviceInfo: NsdServiceInfo?) {
if (serviceInfo == null) return
synchronized(_currentDevices) {
_currentDevices.add(PublicDeviceInfo(serviceInfo))
}
Log.d(
tag,
"Service found: ${serviceInfo.serviceName}, Net: ${serviceInfo.host.hostAddress}"
)
}
Log.d(
tag,
"Service found: ${serviceInfo.serviceName}, Net: ${serviceInfo.host.hostAddress}"
)
}
})
})
}
}
override fun onServiceLost(serviceInfo: NsdServiceInfo?) {
@ -135,6 +165,15 @@ class FcastManager {
class PublicDeviceInfo(serviceInfo: NsdServiceInfo) {
val rawName: String = serviceInfo.serviceName
val host: String? = serviceInfo.host.hostAddress
val host: String? = if (
Build.VERSION.SDK_INT >= Build.VERSION_CODES.R &&
SdkExtensions.getExtensionVersion(
Build.VERSION_CODES.TIRAMISU) >= 7
) {
serviceInfo.hostAddresses.firstOrNull()?.hostAddress
} else {
@Suppress("DEPRECATION")
serviceInfo.host.hostAddress
}
val name = rawName.replace("-", " ") + host?.let { " $it" }
}
}

View File

@ -54,6 +54,7 @@ open class TmdbProvider : MainAPI() {
}
private fun BaseTvShow.toSearchResponse(): TvSeriesSearchResponse {
@Suppress("DEPRECATION")
return TvSeriesSearchResponse(
this.name ?: this.original_name,
getUrl(id, true),
@ -71,6 +72,7 @@ open class TmdbProvider : MainAPI() {
}
private fun BaseMovie.toSearchResponse(): MovieSearchResponse {
@Suppress("DEPRECATION")
return MovieSearchResponse(
this.title ?: this.original_title,
getUrl(id, false),
@ -99,6 +101,7 @@ open class TmdbProvider : MainAPI() {
val episodes = this.seasons?.filter { !disableSeasonZero || (it.season_number ?: 0) != 0 }
?.mapNotNull { season ->
season.episodes?.map { episode ->
@Suppress("DEPRECATION")
Episode(
TmdbLink(
episode.external_ids?.imdb_id ?: this.external_ids?.imdb_id,
@ -116,6 +119,7 @@ open class TmdbProvider : MainAPI() {
episode.air_date?.time,
)
} ?: (1..(season.episode_count ?: 1)).map { episodeNum ->
@Suppress("DEPRECATION")
Episode(
episode = episodeNum,
data = TmdbLink(
@ -242,6 +246,7 @@ open class TmdbProvider : MainAPI() {
}
)
@Suppress("DEPRECATION")
return HomePageResponse(
listOf(
// HomePageList("Popular Series", popularSeries),
@ -387,4 +392,4 @@ open class TmdbProvider : MainAPI() {
it.movie?.toSearchResponse() ?: it.tvShow?.toSearchResponse()
}
}
}
}

View File

@ -228,6 +228,7 @@ open class TraktProvider : MainAPI() {
).toJson()
episodes.add(
@Suppress("DEPRECATION")
Episode(
data = linkData.toJson(),
name = episode.title,

View File

@ -19,6 +19,7 @@ import com.lagradost.cloudstream3.mvvm.safeApiCall
import com.lagradost.cloudstream3.utils.Coroutines.threadSafeListOf
import com.lagradost.cloudstream3.utils.ExtractorLink
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope.coroutineContext
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
@ -132,6 +133,7 @@ class APIRepository(val api: MainAPI) {
delay(delta)
}
@OptIn(DelicateCoroutinesApi::class)
suspend fun getMainPage(page: Int, nameIndex: Int? = null): Resource<List<HomePageResponse?>> {
return safeApiCall {
api.lastHomepageRequest = unixTimeMS

View File

@ -15,6 +15,7 @@ import androidx.appcompat.app.AlertDialog
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.kotlin.kotlinModule
import com.google.android.gms.cast.MediaLoadOptions
import com.google.android.gms.cast.MediaQueueItem
import com.google.android.gms.cast.MediaSeekOptions
import com.google.android.gms.cast.MediaStatus.REPEAT_MODE_REPEAT_OFF
@ -239,12 +240,22 @@ class SelectSourceController(val view: ImageView, val activity: ControllerActivi
loadMirror(index + 1)
}
} else {
awaitLinks(remoteMediaClient?.load(mediaItem, true, startAt)) {
val mediaLoadOptions =
MediaLoadOptions.Builder()
.setPlayPosition(startAt)
.setAutoplay(true)
.build()
awaitLinks(remoteMediaClient?.load(mediaItem, mediaLoadOptions)) {
loadMirror(index + 1)
}
}
} catch (e: Exception) {
awaitLinks(remoteMediaClient?.load(mediaItem, true, startAt)) {
val mediaLoadOptions =
MediaLoadOptions.Builder()
.setPlayPosition(startAt)
.setAutoplay(true)
.build()
awaitLinks(remoteMediaClient?.load(mediaItem, mediaLoadOptions)) {
loadMirror(index + 1)
}
}

View File

@ -43,6 +43,7 @@ class AccountSelectActivity : AppCompatActivity(), BiometricCallback {
super.onCreate(savedInstanceState)
loadThemes(this)
@Suppress("DEPRECATION")
window.navigationBarColor = colorFromAttribute(R.attr.primaryBlackBackground)
// Are we editing and coming from MainActivity?

View File

@ -387,6 +387,7 @@ abstract class AbstractPlayerFragment(
}
// Necessary for multiple combined videos
@Suppress("DEPRECATION")
playerView?.setShowMultiWindowTimeBar(true)
playerView?.player = player
playerView?.performClick()

View File

@ -1,5 +1,6 @@
package com.lagradost.cloudstream3.ui.player
import Torrent
import android.annotation.SuppressLint
import android.content.Context
import android.content.DialogInterface
@ -47,7 +48,7 @@ import androidx.media3.exoplayer.drm.DefaultDrmSessionManager
import androidx.media3.exoplayer.drm.FrameworkMediaDrm
import androidx.media3.exoplayer.drm.LocalMediaDrmCallback
import androidx.media3.exoplayer.source.ClippingMediaSource
import androidx.media3.exoplayer.source.ConcatenatingMediaSource
import androidx.media3.exoplayer.source.ConcatenatingMediaSource2
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory
import androidx.media3.exoplayer.source.MergingMediaSource
import androidx.media3.exoplayer.source.SingleSampleMediaSource
@ -766,6 +767,7 @@ class CS3IPlayer : IPlayer {
).apply {
// Required to make the decoder work with old subtitles
// Upgrade CustomSubtitleDecoderFactory when media3 supports it
@Suppress("DEPRECATION")
experimentalSetLegacyDecodingEnabled(true)
}.also { renderer ->
this.currentTextRenderer = renderer
@ -836,9 +838,9 @@ class CS3IPlayer : IPlayer {
factory.createMediaSource(item.mediaItem)
}
} else {
val source = ConcatenatingMediaSource()
val source = ConcatenatingMediaSource2.Builder()
mediaItemSlices.map { item ->
source.addMediaSource(
source.add(
// The duration MUST be known for it to work properly, see https://github.com/google/ExoPlayer/issues/4727
ClippingMediaSource(
factory.createMediaSource(item.mediaItem),
@ -846,7 +848,7 @@ class CS3IPlayer : IPlayer {
)
)
}
source
source.build()
}
//println("PLAYBACK POS $playbackPosition")
@ -1571,4 +1573,4 @@ class CS3IPlayer : IPlayer {
loadOfflinePlayer(context, it)
}
}
}
}

View File

@ -295,6 +295,7 @@ open class ResultFragmentPhone : FullScreenPlayer() {
override fun onResume() {
afterPluginsLoadedEvent += ::reloadViewModel
activity?.let {
@Suppress("DEPRECATION")
it.window?.navigationBarColor =
it.colorFromAttribute(R.attr.primaryBlackBackground)
}

View File

@ -182,6 +182,7 @@ class ResultFragmentTv : Fragment() {
override fun onResume() {
activity?.let {
@Suppress("DEPRECATION")
it.window?.navigationBarColor =
it.colorFromAttribute(R.attr.primaryBlackBackground)
}

View File

@ -6,7 +6,10 @@ import android.app.Activity
import android.app.Activity.RESULT_CANCELED
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.*
import android.content.ContentValues
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.content.pm.PackageManager
import android.database.Cursor
import android.media.AudioAttributes
@ -14,9 +17,14 @@ import android.media.AudioFocusRequest
import android.media.AudioManager
import android.media.tv.TvContract.Channels.COLUMN_INTERNAL_PROVIDER_ID
import android.net.ConnectivityManager
import android.net.Network
import android.net.NetworkCapabilities
import android.net.Uri
import android.os.*
import android.os.Build
import android.os.Environment
import android.os.Handler
import android.os.Looper
import android.os.ParcelFileDescriptor
import android.provider.MediaStore
import android.text.Spanned
import android.util.Log
@ -29,7 +37,6 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.RequiresApi
import androidx.annotation.WorkerThread
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import androidx.core.text.HtmlCompat
import androidx.core.text.toSpanned
import androidx.core.widget.ContentLoadingProgressBar
@ -40,7 +47,9 @@ import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.tvprovider.media.tv.*
import androidx.tvprovider.media.tv.PreviewChannelHelper
import androidx.tvprovider.media.tv.TvContractCompat
import androidx.tvprovider.media.tv.WatchNextProgram
import androidx.tvprovider.media.tv.WatchNextProgram.fromCursor
import androidx.viewpager2.widget.ViewPager2
import com.google.android.gms.cast.framework.CastContext
@ -49,12 +58,20 @@ import com.google.android.gms.common.ConnectionResult
import com.google.android.gms.common.GoogleApiAvailability
import com.google.android.gms.common.wrappers.Wrappers
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.APIHolder.apis
import com.lagradost.cloudstream3.AcraApplication.Companion.getActivity
import com.lagradost.cloudstream3.AllLanguagesName
import com.lagradost.cloudstream3.CommonActivity.activity
import com.lagradost.cloudstream3.CommonActivity.showToast
import com.lagradost.cloudstream3.DubStatus
import com.lagradost.cloudstream3.HomePageList
import com.lagradost.cloudstream3.LoadResponse
import com.lagradost.cloudstream3.MainAPI
import com.lagradost.cloudstream3.MainActivity.Companion.afterRepositoryLoadedEvent
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.SearchResponse
import com.lagradost.cloudstream3.TvType
import com.lagradost.cloudstream3.isMovieType
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
import com.lagradost.cloudstream3.plugins.RepositoryManager
@ -76,9 +93,15 @@ import com.lagradost.cloudstream3.utils.UIHelper.navigate
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import okhttp3.Cache
import java.io.*
import java.io.File
import java.io.FileNotFoundException
import java.io.FileOutputStream
import java.io.InputStream
import java.io.OutputStream
import java.net.URL
import java.net.URLDecoder
import java.util.concurrent.Executor
import java.util.concurrent.Executors
object AppContextUtils {
fun RecyclerView.setMaxViewPoolSize(maxViewTypeId: Int, maxPoolSize: Int) {
@ -665,10 +688,7 @@ object AppContextUtils {
openWebView(fragment, url)
}
}.launch(intent)
} else {
ContextCompat.startActivity(this, intent, null)
}
} else this.startActivity(intent)
} catch (e: Exception) {
logError(e)
if (fallbackWebview) {
@ -811,12 +831,18 @@ object AppContextUtils {
}
fun Activity.requestLocalAudioFocus(focusRequest: AudioFocusRequest?) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && focusRequest != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (focusRequest == null) {
Log.e("TAG", "focusRequest was null")
return
}
val audioManager = getSystemService(Context.AUDIO_SERVICE) as AudioManager
audioManager.requestAudioFocus(focusRequest)
} else {
val audioManager: AudioManager =
getSystemService(Context.AUDIO_SERVICE) as AudioManager
@Suppress("DEPRECATION")
audioManager.requestAudioFocus(
null,
AudioManager.STREAM_MUSIC,
@ -848,20 +874,27 @@ object AppContextUtils {
val isCastApiAvailable =
GoogleApiAvailability.getInstance()
.isGooglePlayServicesAvailable(applicationContext) == ConnectionResult.SUCCESS
try {
applicationContext?.let { CastContext.getSharedInstance(it) }
val executor: Executor = Executors.newSingleThreadExecutor()
applicationContext?.let {
val task = CastContext.getSharedInstance(it, executor)
task.result
}
} catch (e: Exception) {
println(e)
// track non-fatal
// Track non-fatal
return false
}
return isCastApiAvailable
}
fun Context.isConnectedToChromecast(): Boolean {
if (isCastApiAvailable()) {
val castContext = CastContext.getSharedInstance(this)
if (castContext.castState == CastState.CONNECTED) {
val executor: Executor = Executors.newSingleThreadExecutor()
val castContext = CastContext.getSharedInstance(this, executor)
if (castContext.result.castState == CastState.CONNECTED) {
return true
}
}
@ -974,16 +1007,16 @@ object AppContextUtils {
}
fun Context.isUsingMobileData(): Boolean {
val conManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val networkInfo = conManager.allNetworks
return networkInfo.any {
conManager.getNetworkCapabilities(it)
?.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) == true
} &&
!networkInfo.any {
conManager.getNetworkCapabilities(it)
?.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) == true
}
val connectionManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val activeNetwork: Network? = connectionManager.activeNetwork
val networkCapabilities = connectionManager.getNetworkCapabilities(activeNetwork)
networkCapabilities?.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) == true &&
!networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)
} else {
@Suppress("DEPRECATION")
connectionManager.activeNetworkInfo?.type == ConnectivityManager.TYPE_MOBILE
}
}
@ -1024,9 +1057,7 @@ object AppContextUtils {
}
build()
}
} else {
null
}
} else null
return currentAudioFocusRequest
}
}

View File

@ -295,7 +295,7 @@ object UIHelper {
// Hide the nav bar and status bar
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN
)
) // FIXME this should be replaced
//}
}
@ -399,8 +399,8 @@ object UIHelper {
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.show(WindowInsets.Type.statusBars())
} else {
@Suppress("DEPRECATION")
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
}
@ -418,8 +418,9 @@ object UIHelper {
WindowInsetsControllerCompat(window, View(this)).show(WindowInsetsCompat.Type.systemBars())
} else {*/ /** WINDOW COMPAT IS BUGGY DUE TO FU*KED UP PLAYER AND TRAILERS **/
window.decorView.systemUiVisibility =
(View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
@Suppress("DEPRECATION")
window.decorView.systemUiVisibility =
(View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) // FIXME this should be replaced
//}
changeStatusBarState(isLayout(EMULATOR))
@ -441,7 +442,14 @@ object UIHelper {
fun Context.hasPIPPermission(): Boolean {
val appOps =
getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
appOps.unsafeCheckOpNoThrow(
AppOpsManager.OPSTR_PICTURE_IN_PICTURE,
android.os.Process.myUid(),
packageName
) == AppOpsManager.MODE_ALLOWED
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@Suppress("DEPRECATION")
appOps.checkOpNoThrow(
AppOpsManager.OPSTR_PICTURE_IN_PICTURE,
android.os.Process.myUid(),

View File

@ -14,7 +14,8 @@ actual fun getContext(): Any? {
}
actual fun setContext(context: WeakReference<Any>) {
if (context.get() is Context) {
ctx = context as? WeakReference<Context>
val actualContext = context.get() as? Context
if (actualContext != null) {
ctx = WeakReference(actualContext)
}
}

View File

@ -382,37 +382,37 @@ fun mainPageOf(vararg elements: Pair<String, String>): List<MainPageData> {
return elements.map { (url, name) -> MainPageData(name = name, data = url) }
}
@Suppress("DEPRECATION")
fun newHomePageResponse(
name: String,
list: List<SearchResponse>,
hasNext: Boolean? = null,
): HomePageResponse {
@Suppress("DEPRECATION")
return HomePageResponse(
listOf(HomePageList(name, list)),
hasNext = hasNext ?: list.isNotEmpty()
)
}
@Suppress("DEPRECATION")
fun newHomePageResponse(
data: MainPageRequest,
list: List<SearchResponse>,
hasNext: Boolean? = null,
): HomePageResponse {
@Suppress("DEPRECATION")
return HomePageResponse(
listOf(HomePageList(data.name, list, data.horizontalImages)),
hasNext = hasNext ?: list.isNotEmpty()
)
}
@Suppress("DEPRECATION")
fun newHomePageResponse(list: HomePageList, hasNext: Boolean? = null): HomePageResponse {
@Suppress("DEPRECATION")
return HomePageResponse(listOf(list), hasNext = hasNext ?: list.list.isNotEmpty())
}
@Suppress("DEPRECATION")
fun newHomePageResponse(list: List<HomePageList>, hasNext: Boolean? = null): HomePageResponse {
@Suppress("DEPRECATION")
return HomePageResponse(list, hasNext = hasNext ?: list.any { it.list.isNotEmpty() })
}
@ -508,7 +508,6 @@ abstract class MainAPI {
open val mainPage = listOf(MainPageData("", "", false))
// @WorkerThread
@Suppress("DEPRECATION")
open suspend fun getMainPage(
page: Int,
request: MainPageRequest,
@ -817,8 +816,9 @@ data class SubtitleFile(val lang: String, val url: String)
* @property items List of [HomePageList] items.
* @property hasNext if there is a next page or not.
* */
data class HomePageResponse
@Deprecated("Use newHomePageResponse method", level = DeprecationLevel.WARNING)
data class HomePageResponse(
constructor(
val items: List<HomePageList>,
val hasNext: Boolean = false
)
@ -952,7 +952,6 @@ interface SearchResponse {
var quality: SearchQuality?
}
@Suppress("DEPRECATION")
fun MainAPI.newTorrentSearchResponse(
name: String,
url: String,
@ -960,6 +959,7 @@ fun MainAPI.newTorrentSearchResponse(
fix: Boolean = true,
initializer: TorrentSearchResponse.() -> Unit = { },
): TorrentSearchResponse {
@Suppress("DEPRECATION")
val builder = TorrentSearchResponse(
name = name,
url = if (fix) fixUrl(url) else url,
@ -972,7 +972,6 @@ fun MainAPI.newTorrentSearchResponse(
return builder
}
@Suppress("DEPRECATION")
fun MainAPI.newMovieSearchResponse(
name: String,
url: String,
@ -980,13 +979,13 @@ fun MainAPI.newMovieSearchResponse(
fix: Boolean = true,
initializer: MovieSearchResponse.() -> Unit = { },
): MovieSearchResponse {
@Suppress("DEPRECATION")
val builder = MovieSearchResponse(name, if (fix) fixUrl(url) else url, this.name, type)
builder.initializer()
return builder
}
@Suppress("DEPRECATION")
fun MainAPI.newLiveSearchResponse(
name: String,
url: String,
@ -994,6 +993,7 @@ fun MainAPI.newLiveSearchResponse(
fix: Boolean = true,
initializer: LiveSearchResponse.() -> Unit = { },
): LiveSearchResponse {
@Suppress("DEPRECATION")
val builder = LiveSearchResponse(
name = name,
url = if (fix) fixUrl(url) else url,
@ -1004,7 +1004,6 @@ fun MainAPI.newLiveSearchResponse(
return builder
}
@Suppress("DEPRECATION")
fun MainAPI.newTvSeriesSearchResponse(
name: String,
url: String,
@ -1012,13 +1011,13 @@ fun MainAPI.newTvSeriesSearchResponse(
fix: Boolean = true,
initializer: TvSeriesSearchResponse.() -> Unit = { },
): TvSeriesSearchResponse {
@Suppress("DEPRECATION")
val builder = TvSeriesSearchResponse(name, if (fix) fixUrl(url) else url, this.name, type)
builder.initializer()
return builder
}
@Suppress("DEPRECATION")
fun MainAPI.newAnimeSearchResponse(
name: String,
url: String,
@ -1026,6 +1025,7 @@ fun MainAPI.newAnimeSearchResponse(
fix: Boolean = true,
initializer: AnimeSearchResponse.() -> Unit = { },
): AnimeSearchResponse {
@Suppress("DEPRECATION")
val builder = AnimeSearchResponse(name, if (fix) fixUrl(url) else url, this.name, type)
builder.initializer()
@ -1089,8 +1089,9 @@ data class ActorData(
/** Data class of [SearchResponse] interface for Anime.
* @see newAnimeSearchResponse
* */
data class AnimeSearchResponse
@Deprecated("Use newAnimeSearchResponse", level = DeprecationLevel.WARNING)
data class AnimeSearchResponse(
constructor(
override val name: String,
override val url: String,
override val apiName: String,
@ -1108,7 +1109,6 @@ data class AnimeSearchResponse(
override var posterHeaders: Map<String, String>? = null,
) : SearchResponse
@Suppress("DEPRECATION")
fun AnimeSearchResponse.addDubStatus(status: DubStatus, episodes: Int? = null) {
this.dubStatus = dubStatus?.also { it.add(status) } ?: EnumSet.of(status)
if (this.type?.isMovieType() != true)
@ -1116,24 +1116,20 @@ fun AnimeSearchResponse.addDubStatus(status: DubStatus, episodes: Int? = null) {
this.episodes[status] = episodes
}
@Suppress("DEPRECATION")
fun AnimeSearchResponse.addDubStatus(isDub: Boolean, episodes: Int? = null) {
addDubStatus(if (isDub) DubStatus.Dubbed else DubStatus.Subbed, episodes)
}
@Suppress("DEPRECATION")
fun AnimeSearchResponse.addDub(episodes: Int?) {
if (episodes == null || episodes <= 0) return
addDubStatus(DubStatus.Dubbed, episodes)
}
@Suppress("DEPRECATION")
fun AnimeSearchResponse.addSub(episodes: Int?) {
if (episodes == null || episodes <= 0) return
addDubStatus(DubStatus.Subbed, episodes)
}
@Suppress("DEPRECATION")
fun AnimeSearchResponse.addDubStatus(
dubExist: Boolean,
subExist: Boolean,
@ -1147,7 +1143,6 @@ fun AnimeSearchResponse.addDubStatus(
addDubStatus(DubStatus.Subbed, subEpisodes)
}
@Suppress("DEPRECATION")
fun AnimeSearchResponse.addDubStatus(status: String, episodes: Int? = null) {
if (status.contains("(dub)", ignoreCase = true)) {
addDubStatus(DubStatus.Dubbed, episodes)
@ -1159,8 +1154,9 @@ fun AnimeSearchResponse.addDubStatus(status: String, episodes: Int? = null) {
/** Data class of [SearchResponse] interface for Torrent.
* @see newTorrentSearchResponse
* */
data class TorrentSearchResponse
@Deprecated("Use newTorrentSearchResponse", level = DeprecationLevel.WARNING)
data class TorrentSearchResponse(
constructor(
override val name: String,
override val url: String,
override val apiName: String,
@ -1175,8 +1171,9 @@ data class TorrentSearchResponse(
/** Data class of [SearchResponse] interface for Movies.
* @see newMovieSearchResponse
* */
data class MovieSearchResponse
@Deprecated("Use newMovieSearchResponse", level = DeprecationLevel.WARNING)
data class MovieSearchResponse(
constructor(
override val name: String,
override val url: String,
override val apiName: String,
@ -1186,14 +1183,15 @@ data class MovieSearchResponse(
var year: Int? = null,
override var id: Int? = null,
override var quality: SearchQuality? = null,
override var posterHeaders: Map<String, String>? = null,
override var posterHeaders: Map<String, String>? = null
) : SearchResponse
/** Data class of [SearchResponse] interface for Live streams.
* @see newLiveSearchResponse
* */
data class LiveSearchResponse
@Deprecated("Use newLiveSearchResponse", level = DeprecationLevel.WARNING)
data class LiveSearchResponse(
constructor(
override val name: String,
override val url: String,
override val apiName: String,
@ -1209,8 +1207,9 @@ data class LiveSearchResponse(
/** Data class of [SearchResponse] interface for Tv series.
* @see newTvSeriesSearchResponse
* */
data class TvSeriesSearchResponse
@Deprecated("Use newTvSeriesSearchResponse", level = DeprecationLevel.WARNING)
data class TvSeriesSearchResponse(
constructor(
override val name: String,
override val url: String,
override val apiName: String,
@ -1238,24 +1237,24 @@ data class TrailerData(
)
/** Abstract interface of LoadResponse responses
* @param name Title of the media, appears on result page.
* @param url Url of the media.
* @param apiName Plugin name, appears on result page.
* @param type [TvType] of the media .
* @param posterUrl Url of the media poster, appears on Top of result page.
* @param year Year of the media, appears on result page.
* @param plot Plot of the media, appears on result page.
* @param rating Rating of the media, appears on result page (0-10000).
* @param tags Tags of the media, appears on result page.
* @param duration duration of the media, appears on result page.
* @param trailers list of the media [TrailerData], used to load trailers.
* @param recommendations list of the [SearchResponse] related to media, appears on result page.
* @param actors list of the [ActorData] casted in the media, appears on result page.
* @param comingSoon determines if the media is released or coming soon.
* @param syncData Online sync services compatible with the media.
* @param posterHeaders headers map used by network request to get the poster.
* @param backgroundPosterUrl Url of the media background poster.
* @param contentRating content rating of the media, appears on result page.
* @property name Title of the media, appears on result page.
* @property url Url of the media.
* @property apiName Plugin name, appears on result page.
* @property type [TvType] of the media .
* @property posterUrl Url of the media poster, appears on Top of result page.
* @property year Year of the media, appears on result page.
* @property plot Plot of the media, appears on result page.
* @property rating Rating of the media, appears on result page (0-10000).
* @property tags Tags of the media, appears on result page.
* @property duration duration of the media, appears on result page.
* @property trailers list of the media [TrailerData], used to load trailers.
* @property recommendations list of the [SearchResponse] related to media, appears on result page.
* @property actors list of the [ActorData] casted in the media, appears on result page.
* @property comingSoon determines if the media is released or coming soon.
* @property syncData Online sync services compatible with the media.
* @property posterHeaders headers map used by network request to get the poster.
* @property backgroundPosterUrl Url of the media background poster.
* @property contentRating content rating of the media, appears on result page.
* */
interface LoadResponse {
var name: String
@ -1298,7 +1297,6 @@ interface LoadResponse {
return tryParseJson(idString) ?: return emptyMap()
}
@Suppress("DEPRECATION")
fun LoadResponse.isMovie(): Boolean {
return this.type.isMovieType() || this is MovieLoadResponse
}
@ -1665,8 +1663,9 @@ fun EpisodeResponse.addSeasonNames(names: List<SeasonData>) {
/** Data class of [LoadResponse] interface for Torrent.
* @see newTorrentLoadResponse
*/
data class TorrentLoadResponse
@Deprecated("Use newTorrentLoadResponse method", level = DeprecationLevel.WARNING)
data class TorrentLoadResponse(
constructor(
override var name: String,
override var url: String,
override var apiName: String,
@ -1692,6 +1691,8 @@ data class TorrentLoadResponse(
* Secondary constructor for backwards compatibility without contentRating.
* Remove this constructor after there is a new stable release and extensions are updated to support contentRating.
*/
@Suppress("DEPRECATION")
@Deprecated("Use newTorrentLoadResponse method with contentRating included", level = DeprecationLevel.WARNING)
constructor(
name: String,
url: String,
@ -1736,7 +1737,6 @@ data class TorrentLoadResponse(
)
}
@Suppress("DEPRECATION")
suspend fun MainAPI.newTorrentLoadResponse(
name: String,
url: String,
@ -1744,6 +1744,7 @@ suspend fun MainAPI.newTorrentLoadResponse(
torrent: String? = null,
initializer: suspend TorrentLoadResponse.() -> Unit = { }
): TorrentLoadResponse {
@Suppress("DEPRECATION")
val builder = TorrentLoadResponse(
name = name,
url = url,
@ -1761,9 +1762,9 @@ suspend fun MainAPI.newTorrentLoadResponse(
/** Data class of [LoadResponse] interface for Anime.
* @see newAnimeLoadResponse
* */
@Suppress("DEPRECATION")
data class AnimeLoadResponse
@Deprecated("Use newAnimeLoadResponse method", level = DeprecationLevel.WARNING)
data class AnimeLoadResponse(
constructor(
var engName: String? = null,
var japName: String? = null,
override var name: String,
@ -1823,6 +1824,8 @@ data class AnimeLoadResponse(
* Secondary constructor for backwards compatibility without contentRating.
* Remove this constructor after there is a new stable release and extensions are updated to support contentRating.
*/
@Suppress("DEPRECATION")
@Deprecated("Use newAnimeLoadResponse method with contentRating included", level = DeprecationLevel.WARNING)
constructor(
engName: String? = null,
japName: String? = null,
@ -1880,13 +1883,11 @@ data class AnimeLoadResponse(
/**
* If episodes already exist appends the list.
* */
@Suppress("DEPRECATION")
fun AnimeLoadResponse.addEpisodes(status: DubStatus, episodes: List<Episode>?) {
if (episodes.isNullOrEmpty()) return
this.episodes[status] = (this.episodes[status] ?: emptyList()) + episodes
}
@Suppress("DEPRECATION")
suspend fun MainAPI.newAnimeLoadResponse(
name: String,
url: String,
@ -1894,6 +1895,7 @@ suspend fun MainAPI.newAnimeLoadResponse(
comingSoonIfNone: Boolean = true,
initializer: suspend AnimeLoadResponse.() -> Unit = { },
): AnimeLoadResponse {
@Suppress("DEPRECATION")
val builder = AnimeLoadResponse(name = name, url = url, apiName = this.name, type = type)
builder.initializer()
if (comingSoonIfNone) {
@ -1910,8 +1912,9 @@ suspend fun MainAPI.newAnimeLoadResponse(
/** Data class of [LoadResponse] interface for Live streams.
* @see newLiveStreamLoadResponse
* */
data class LiveStreamLoadResponse
@Deprecated("Use newLiveStreamLoadResponse method", level = DeprecationLevel.WARNING)
data class LiveStreamLoadResponse(
constructor(
override var name: String,
override var url: String,
override var apiName: String,
@ -1938,6 +1941,8 @@ data class LiveStreamLoadResponse(
* Secondary constructor for backwards compatibility without contentRating.
* Remove this constructor after there is a new stable release and extensions are updated to support contentRating.
*/
@Suppress("DEPRECATION")
@Deprecated("Use newLiveStreamLoadResponse method with contentRating included", level = DeprecationLevel.WARNING)
constructor(
name: String,
url: String,
@ -1963,13 +1968,13 @@ data class LiveStreamLoadResponse(
)
}
@Suppress("DEPRECATION")
suspend fun MainAPI.newLiveStreamLoadResponse(
name: String,
url: String,
dataUrl: String,
initializer: suspend LiveStreamLoadResponse.() -> Unit = { }
): LiveStreamLoadResponse {
@Suppress("DEPRECATION")
val builder = LiveStreamLoadResponse(
name = name,
url = url,
@ -1984,8 +1989,9 @@ suspend fun MainAPI.newLiveStreamLoadResponse(
/** Data class of [LoadResponse] interface for Movies.
* @see newMovieLoadResponse
* */
data class MovieLoadResponse
@Deprecated("Use newMovieLoadResponse method", level = DeprecationLevel.WARNING)
data class MovieLoadResponse(
constructor(
override var name: String,
override var url: String,
override var apiName: String,
@ -2012,6 +2018,8 @@ data class MovieLoadResponse(
* Secondary constructor for backwards compatibility without contentRating.
* Remove this constructor after there is a new stable release and extensions are updated to support contentRating.
*/
@Suppress("DEPRECATION")
@Deprecated("Use newMovieLoadResponse method with contentRating included", level = DeprecationLevel.WARNING)
constructor(
name: String,
url: String,
@ -2037,7 +2045,6 @@ data class MovieLoadResponse(
)
}
@Suppress("DEPRECATION")
suspend fun <T> MainAPI.newMovieLoadResponse(
name: String,
url: String,
@ -2054,6 +2061,7 @@ suspend fun <T> MainAPI.newMovieLoadResponse(
initializer = initializer
)
val dataUrl = data?.toJson() ?: ""
@Suppress("DEPRECATION")
val builder = MovieLoadResponse(
name = name,
url = url,
@ -2066,7 +2074,6 @@ suspend fun <T> MainAPI.newMovieLoadResponse(
return builder
}
@Suppress("DEPRECATION")
suspend fun MainAPI.newMovieLoadResponse(
name: String,
url: String,
@ -2074,6 +2081,7 @@ suspend fun MainAPI.newMovieLoadResponse(
dataUrl: String,
initializer: suspend MovieLoadResponse.() -> Unit = { }
): MovieLoadResponse {
@Suppress("DEPRECATION")
val builder = MovieLoadResponse(
name = name,
url = url,
@ -2097,8 +2105,9 @@ suspend fun MainAPI.newMovieLoadResponse(
* @property runTime Episode runtime in seconds.
* @see newEpisode
* */
data class Episode
@Deprecated("Use newEpisode", level = DeprecationLevel.WARNING)
data class Episode(
constructor(
var data: String,
var name: String? = null,
var season: Int? = null,
@ -2113,6 +2122,8 @@ data class Episode(
* Secondary constructor for backwards compatibility without runTime.
* TODO Remove this constructor after there is a new stable release and extensions are updated to support runTime.
*/
@Suppress("DEPRECATION")
@Deprecated("Use newEpisode with runTime included", level = DeprecationLevel.WARNING)
constructor(
data: String,
name: String? = null,
@ -2127,26 +2138,24 @@ data class Episode(
)
}
@Suppress("DEPRECATION")
fun Episode.addDate(date: String?, format: String = "yyyy-MM-dd") {
try {
this.date = SimpleDateFormat(format)?.parse(date ?: return)?.time
this.date = SimpleDateFormat(format).parse(date ?: return)?.time
} catch (e: Exception) {
logError(e)
}
}
@Suppress("DEPRECATION")
fun Episode.addDate(date: Date?) {
this.date = date?.time
}
@Suppress("DEPRECATION")
fun MainAPI.newEpisode(
url: String,
initializer: Episode.() -> Unit = { },
fix: Boolean = true,
): Episode {
@Suppress("DEPRECATION")
val builder = Episode(
data = if (fix) fixUrl(url) else url
)
@ -2154,7 +2163,6 @@ fun MainAPI.newEpisode(
return builder
}
@Suppress("DEPRECATION")
fun <T> MainAPI.newEpisode(
data: T,
initializer: Episode.() -> Unit = { }
@ -2164,6 +2172,7 @@ fun <T> MainAPI.newEpisode(
initializer = initializer
) // just in case java is wack
@Suppress("DEPRECATION")
val builder = Episode(
data = data?.toJson() ?: throw ErrorLoadingException("invalid newEpisode")
)
@ -2196,9 +2205,9 @@ enum class SimklSyncServices(val originalName: String) {
/** Data class of [LoadResponse] interface for Tv series.
* @see newTvSeriesLoadResponse
* */
@Suppress("DEPRECATION")
data class TvSeriesLoadResponse
@Deprecated("Use newTvSeriesLoadResponse method", level = DeprecationLevel.WARNING)
data class TvSeriesLoadResponse(
constructor(
override var name: String,
override var url: String,
override var apiName: String,
@ -2250,6 +2259,8 @@ data class TvSeriesLoadResponse(
* Secondary constructor for backwards compatibility without contentRating.
* Remove this constructor after there is a new stable release and extensions are updated to support contentRating.
*/
@Suppress("DEPRECATION")
@Deprecated("Use newTvSeriesLoadResponse method with contentRating included", level = DeprecationLevel.WARNING)
constructor(
name: String,
url: String,
@ -2298,7 +2309,6 @@ data class TvSeriesLoadResponse(
)
}
@Suppress("DEPRECATION")
suspend fun MainAPI.newTvSeriesLoadResponse(
name: String,
url: String,
@ -2306,6 +2316,7 @@ suspend fun MainAPI.newTvSeriesLoadResponse(
episodes: List<Episode>,
initializer: suspend TvSeriesLoadResponse.() -> Unit = { }
): TvSeriesLoadResponse {
@Suppress("DEPRECATION")
val builder = TvSeriesLoadResponse(
name = name,
url = url,

View File

@ -26,25 +26,25 @@ class JsUnpacker(packedJS: String?) {
* @return the javascript unpacked or null.
*/
fun unpack(): String? {
val js = packedJS
val js = packedJS ?: return null
try {
var p =
Pattern.compile("""\}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""", Pattern.DOTALL)
var m = p.matcher(js)
if (m.find() && m.groupCount() == 4) {
val payload = m.group(1).replace("\\'", "'")
val payload = m.group(1)?.replace("\\'", "'") ?: ""
val radixStr = m.group(2)
val countStr = m.group(3)
val symtab = m.group(4).split("\\|".toRegex()).toTypedArray()
val symtab = (m.group(4)?.split("\\|".toRegex()) ?: emptyList()).toTypedArray()
var radix = 36
var count = 0
try {
radix = radixStr.toInt()
} catch (e: Exception) {
radix = radixStr?.toIntOrNull() ?: radix
} catch (_: Exception) {
}
try {
count = countStr.toInt()
} catch (e: Exception) {
count = countStr?.toIntOrNull() ?: 0
} catch (_: Exception) {
}
if (symtab.size != count) {
throw Exception("Unknown p.a.c.k.e.r. encoding")
@ -56,12 +56,12 @@ class JsUnpacker(packedJS: String?) {
var replaceOffset = 0
while (m.find()) {
val word = m.group(0)
val x = unbase.unbase(word)
val x = if (word == null) 0 else unbase.unbase(word)
var value: String? = null
if (x < symtab.size && x >= 0) {
value = symtab[x]
}
if (value != null && value.isNotEmpty()) {
if (!value.isNullOrEmpty() && !word.isNullOrEmpty()) {
decoded.replace(m.start() + replaceOffset, m.end() + replaceOffset, value)
replaceOffset += value.length - word.length
}
@ -118,7 +118,7 @@ class JsUnpacker(packedJS: String?) {
}
/**
* @param packedJS javascript P.A.C.K.E.R. coded.
* @param packedJS javascript P.A.C.K.E.R. coded.
*/
init {
this.packedJS = packedJS