code cleanup

This commit is contained in:
LagradOst 2021-08-29 20:42:44 +02:00
parent 7b62788f0b
commit 96dd822fa1
35 changed files with 72 additions and 110 deletions

View file

@ -8,7 +8,6 @@ import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
import com.lagradost.cloudstream3.utils.Coroutines.runOnMainThread import com.lagradost.cloudstream3.utils.Coroutines.runOnMainThread
import org.acra.ReportField import org.acra.ReportField
import org.acra.config.CoreConfiguration import org.acra.config.CoreConfiguration
import org.acra.config.toast
import org.acra.data.CrashReportData import org.acra.data.CrashReportData
import org.acra.data.StringFormat import org.acra.data.StringFormat
import org.acra.ktx.initAcra import org.acra.ktx.initAcra

View file

@ -3,7 +3,6 @@ package com.lagradost.cloudstream3
import android.app.Activity import android.app.Activity
import android.app.PictureInPictureParams import android.app.PictureInPictureParams
import android.content.ComponentName import android.content.ComponentName
import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.content.res.ColorStateList import android.content.res.ColorStateList
@ -76,6 +75,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
lateinit var navOptions: NavOptions lateinit var navOptions: NavOptions
var currentToast: Toast? = null var currentToast: Toast? = null
fun showToast(act: Activity?, @StringRes message: Int, duration: Int) { fun showToast(act: Activity?, @StringRes message: Int, duration: Int) {
if (act == null) return if (act == null) return
showToast(act, act.getString(message), duration) showToast(act, act.getString(message), duration)

View file

@ -40,7 +40,7 @@ class GogoanimeProvider : MainAPI() {
TvType.ONA TvType.ONA
) )
override fun getMainPage(): HomePageResponse? { override fun getMainPage(): HomePageResponse {
val headers = mapOf( val headers = mapOf(
"authority" to "ajax.gogo-load.com", "authority" to "ajax.gogo-load.com",
"sec-ch-ua" to "\"Google Chrome\";v=\"89\", \"Chromium\";v=\"89\", \";Not A Brand\";v=\"99\"", "sec-ch-ua" to "\"Google Chrome\";v=\"89\", \"Chromium\";v=\"89\", \";Not A Brand\";v=\"99\"",

View file

@ -15,7 +15,7 @@ class WcoStream : ExtractorApi() {
val html = khttp.get(url, headers = mapOf("Referer" to "https://wcostream.cc/")).text val html = khttp.get(url, headers = mapOf("Referer" to "https://wcostream.cc/")).text
val (Id) = "/e/(.*?)?domain".toRegex().find(url)!!.destructured val (Id) = "/e/(.*?)?domain".toRegex().find(url)!!.destructured
val (skey) = """skey\s=\s['\"](.*?)['\"];""".toRegex().find(html)!!.destructured val (skey) = """skey\s=\s['"](.*?)['"];""".toRegex().find(html)!!.destructured
val apiLink = "$baseUrl/info/$Id?domain=wcostream.cc&skey=$skey" val apiLink = "$baseUrl/info/$Id?domain=wcostream.cc&skey=$skey"
val referrer = "$baseUrl/e/$Id?domain=wcostream.cc" val referrer = "$baseUrl/e/$Id?domain=wcostream.cc"

View file

@ -37,7 +37,7 @@ class XStreamCdn : ExtractorApi() {
} }
} }
override fun getUrl(url: String, referer: String?): List<ExtractorLink>? { override fun getUrl(url: String, referer: String?): List<ExtractorLink> {
val headers = mapOf( val headers = mapOf(
"Referer" to url, "Referer" to url,
"User-Agent" to "Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0", "User-Agent" to "Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0",

View file

@ -3,7 +3,6 @@ package com.lagradost.cloudstream3.mvvm
import android.util.Log import android.util.Log
import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import com.bumptech.glide.load.HttpException import com.bumptech.glide.load.HttpException
import com.lagradost.cloudstream3.ErrorLoadingException import com.lagradost.cloudstream3.ErrorLoadingException
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -12,11 +11,11 @@ import java.net.SocketTimeoutException
import java.net.UnknownHostException import java.net.UnknownHostException
fun <T> LifecycleOwner.observe(liveData: LiveData<T>, action: (t: T) -> Unit) { fun <T> LifecycleOwner.observe(liveData: LiveData<T>, action: (t: T) -> Unit) {
liveData.observe(this, Observer { it?.let { t -> action(t) } }) liveData.observe(this) { it?.let { t -> action(t) } }
} }
fun <T> LifecycleOwner.observeDirectly(liveData: LiveData<T>, action: (t: T) -> Unit) { fun <T> LifecycleOwner.observeDirectly(liveData: LiveData<T>, action: (t: T) -> Unit) {
liveData.observe(this, Observer { it?.let { t -> action(t) } }) liveData.observe(this) { it?.let { t -> action(t) } }
val currentValue = liveData.value val currentValue = liveData.value
if (currentValue != null) if (currentValue != null)
action(currentValue) action(currentValue)
@ -64,7 +63,7 @@ suspend fun <T> safeApiCall(
Resource.Failure(true, null, null, "Please try again later.") Resource.Failure(true, null, null, "Please try again later.")
} }
is HttpException -> { is HttpException -> {
Resource.Failure(false, throwable.statusCode, null, throwable.localizedMessage) Resource.Failure(false, throwable.statusCode, null, throwable.localizedMessage ?: "")
} }
is UnknownHostException -> { is UnknownHostException -> {
Resource.Failure(true, null, null, "Cannot connect to server, try again later.") Resource.Failure(true, null, null, "Cannot connect to server, try again later.")
@ -76,7 +75,7 @@ suspend fun <T> safeApiCall(
Resource.Failure(false, null, null, "This operation is not implemented.") Resource.Failure(false, null, null, "This operation is not implemented.")
} }
else -> { else -> {
val stackTraceMsg = throwable.localizedMessage + "\n\n" + throwable.stackTrace.joinToString( val stackTraceMsg = (throwable.localizedMessage ?: "") + "\n\n" + throwable.stackTrace.joinToString(
separator = "\n" separator = "\n"
) { ) {
"${it.fileName} ${it.lineNumber}" "${it.fileName} ${it.lineNumber}"

View file

@ -3,7 +3,6 @@ package com.lagradost.cloudstream3.receivers
import android.content.BroadcastReceiver import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Build
import android.util.Log import android.util.Log

View file

@ -23,7 +23,7 @@ class MyMiniControllerFragment : MiniControllerFragment() {
if (obtainStyledAttributes.hasValue(R.styleable.CustomCast_customCastBackgroundColor)) { if (obtainStyledAttributes.hasValue(R.styleable.CustomCast_customCastBackgroundColor)) {
currentColor = obtainStyledAttributes.getColor(R.styleable.CustomCast_customCastBackgroundColor, 0) currentColor = obtainStyledAttributes.getColor(R.styleable.CustomCast_customCastBackgroundColor, 0)
} }
obtainStyledAttributes.recycle()
super.onInflate(context, attributeSet, bundle) super.onInflate(context, attributeSet, bundle)
} }

View file

@ -7,7 +7,6 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.lagradost.cloudstream3.TvType
import com.lagradost.cloudstream3.isMovieType import com.lagradost.cloudstream3.isMovieType
import com.lagradost.cloudstream3.utils.DOWNLOAD_EPISODE_CACHE import com.lagradost.cloudstream3.utils.DOWNLOAD_EPISODE_CACHE
import com.lagradost.cloudstream3.utils.DOWNLOAD_HEADER_CACHE import com.lagradost.cloudstream3.utils.DOWNLOAD_HEADER_CACHE

View file

@ -9,10 +9,9 @@ import android.widget.TextView
import androidx.core.widget.ContentLoadingProgressBar import androidx.core.widget.ContentLoadingProgressBar
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIcons
import com.lagradost.cloudstream3.utils.Coroutines import com.lagradost.cloudstream3.utils.Coroutines
import com.lagradost.cloudstream3.utils.IDisposable import com.lagradost.cloudstream3.utils.IDisposable
import com.lagradost.cloudstream3.utils.VideoDownloadHelper import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIcons
import com.lagradost.cloudstream3.utils.VideoDownloadManager import com.lagradost.cloudstream3.utils.VideoDownloadManager
class EasyDownloadButton : IDisposable { class EasyDownloadButton : IDisposable {

View file

@ -3,19 +3,11 @@ package com.lagradost.cloudstream3.ui.home
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.cardview.widget.CardView
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide import com.lagradost.cloudstream3.R
import com.bumptech.glide.load.model.GlideUrl import com.lagradost.cloudstream3.SearchResponse
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.ui.search.SEARCH_ACTION_LOAD
import com.lagradost.cloudstream3.ui.search.SEARCH_ACTION_SHOW_METADATA
import com.lagradost.cloudstream3.ui.search.SearchClickCallback import com.lagradost.cloudstream3.ui.search.SearchClickCallback
import com.lagradost.cloudstream3.ui.search.SearchResultBuilder import com.lagradost.cloudstream3.ui.search.SearchResultBuilder
import com.lagradost.cloudstream3.utils.UIHelper.setImage
import kotlinx.android.synthetic.main.home_result_grid.view.*
class HomeChildItemAdapter( class HomeChildItemAdapter(
var cardList: List<SearchResponse>, var cardList: List<SearchResponse>,

View file

@ -8,7 +8,6 @@ import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.lagradost.cloudstream3.HomePageList import com.lagradost.cloudstream3.HomePageList
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.SearchResponse
import com.lagradost.cloudstream3.ui.search.SearchClickCallback import com.lagradost.cloudstream3.ui.search.SearchClickCallback
import kotlinx.android.synthetic.main.homepage_parent.view.* import kotlinx.android.synthetic.main.homepage_parent.view.*

View file

@ -853,7 +853,7 @@ class PlayerFragment : Fragment() {
if (realLang.length == 2) SubtitleHelper.fromTwoLettersToLanguage(realLang) ?: realLang else realLang if (realLang.length == 2) SubtitleHelper.fromTwoLettersToLanguage(realLang) ?: realLang else realLang
if (!this::exoPlayer.isInitialized) return if (!this::exoPlayer.isInitialized) return
(exoPlayer?.trackSelector as DefaultTrackSelector?)?.let { trackSelector -> (exoPlayer.trackSelector as DefaultTrackSelector?)?.let { trackSelector ->
if (lang.isNullOrBlank()) { if (lang.isNullOrBlank()) {
trackSelector.setParameters( trackSelector.setParameters(
trackSelector.buildUponParameters() trackSelector.buildUponParameters()
@ -1028,11 +1028,11 @@ class PlayerFragment : Fragment() {
observeDirectly(viewModel.episodes) { _episodes -> observeDirectly(viewModel.episodes) { _episodes ->
episodes = _episodes episodes = _episodes
if (isLoading) { if (isLoading) {
if (playerData.episodeIndex > 0 && playerData.episodeIndex < episodes.size) { /*if (playerData.episodeIndex > 0 && playerData.episodeIndex < episodes.size) {
} else { } else {
// WHAT THE FUCK DID YOU DO // WHAT THE FUCK DID YOU DO
} }*/
} }
} }
@ -1304,11 +1304,11 @@ class PlayerFragment : Fragment() {
playbackPosition = if (this::exoPlayer.isInitialized) exoPlayer.currentPosition else 0 playbackPosition = if (this::exoPlayer.isInitialized) exoPlayer.currentPosition else 0
setMirrorId(sources[sourceIndex].getId()) setMirrorId(sources[sourceIndex].getId())
initPlayer(getCurrentUrl()) initPlayer(getCurrentUrl())
} else { } /*else {
if (isPlaying) { if (isPlaying) {
// exoPlayer.play() // exoPlayer.play()
} }
} }*/
if (subtitleIndex != startIndexFromMap) { if (subtitleIndex != startIndexFromMap) {
setPreferredSubLanguage(if (subtitleIndex <= 0) null else currentSubtitles[subtitleIndex - 1]) setPreferredSubLanguage(if (subtitleIndex <= 0) null else currentSubtitles[subtitleIndex - 1])

View file

@ -6,7 +6,6 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import android.widget.Toast
import androidx.annotation.LayoutRes import androidx.annotation.LayoutRes
import androidx.core.widget.ContentLoadingProgressBar import androidx.core.widget.ContentLoadingProgressBar
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView

View file

@ -1,29 +1,17 @@
package com.lagradost.cloudstream3.ui.search package com.lagradost.cloudstream3.ui.search
import android.app.Activity
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.FrameLayout import android.widget.FrameLayout
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView
import androidx.cardview.widget.CardView
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.model.GlideUrl
import com.lagradost.cloudstream3.AnimeSearchResponse
import com.lagradost.cloudstream3.DubStatus
import com.lagradost.cloudstream3.SearchResponse import com.lagradost.cloudstream3.SearchResponse
import com.lagradost.cloudstream3.TvType import com.lagradost.cloudstream3.ui.AutofitRecyclerView
import com.lagradost.cloudstream3.utils.UIHelper.getGridFormatId import com.lagradost.cloudstream3.utils.UIHelper.getGridFormatId
import com.lagradost.cloudstream3.utils.UIHelper.getGridIsCompact import com.lagradost.cloudstream3.utils.UIHelper.getGridIsCompact
import com.lagradost.cloudstream3.utils.UIHelper.toPx import com.lagradost.cloudstream3.utils.UIHelper.toPx
import com.lagradost.cloudstream3.ui.AutofitRecyclerView import kotlinx.android.synthetic.main.search_result_compact.view.*
import com.lagradost.cloudstream3.utils.UIHelper.setImage
import kotlinx.android.synthetic.main.search_result_compact.view.backgroundCard
import kotlinx.android.synthetic.main.search_result_compact.view.imageText
import kotlinx.android.synthetic.main.search_result_compact.view.imageView
import kotlinx.android.synthetic.main.search_result_grid.view.*
import kotlin.math.roundToInt import kotlin.math.roundToInt
const val SEARCH_ACTION_LOAD = 0 const val SEARCH_ACTION_LOAD = 0

View file

@ -7,7 +7,6 @@ import com.lagradost.cloudstream3.ui.download.DOWNLOAD_ACTION_PLAY_FILE
import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick
import com.lagradost.cloudstream3.ui.download.DownloadClickEvent import com.lagradost.cloudstream3.ui.download.DownloadClickEvent
import com.lagradost.cloudstream3.ui.result.START_ACTION_LOAD_EP import com.lagradost.cloudstream3.ui.result.START_ACTION_LOAD_EP
import com.lagradost.cloudstream3.ui.result.START_ACTION_RESUME_LATEST
import com.lagradost.cloudstream3.utils.AppUtils.loadSearchResult import com.lagradost.cloudstream3.utils.AppUtils.loadSearchResult
import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.utils.DataStoreHelper
import com.lagradost.cloudstream3.utils.VideoDownloadHelper import com.lagradost.cloudstream3.utils.VideoDownloadHelper

View file

@ -12,9 +12,7 @@ import android.net.NetworkCapabilities
import android.net.Uri import android.net.Uri
import android.os.Build import android.os.Build
import android.provider.MediaStore import android.provider.MediaStore
import android.view.View
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceManager
import com.google.android.gms.cast.framework.CastContext import com.google.android.gms.cast.framework.CastContext
import com.google.android.gms.cast.framework.CastState import com.google.android.gms.cast.framework.CastState
import com.google.android.gms.common.ConnectionResult import com.google.android.gms.common.ConnectionResult

View file

@ -2,7 +2,6 @@ package com.lagradost.cloudstream3.utils
import android.content.Context import android.content.Context
import com.google.android.gms.cast.CastMediaControlIntent import com.google.android.gms.cast.CastMediaControlIntent
import com.google.android.gms.cast.LaunchOptions
import com.google.android.gms.cast.framework.CastOptions import com.google.android.gms.cast.framework.CastOptions
import com.google.android.gms.cast.framework.OptionsProvider import com.google.android.gms.cast.framework.OptionsProvider
import com.google.android.gms.cast.framework.SessionProvider import com.google.android.gms.cast.framework.SessionProvider

View file

@ -1,6 +1,5 @@
package com.lagradost.cloudstream3.utils package com.lagradost.cloudstream3.utils
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.extractors.* import com.lagradost.cloudstream3.extractors.*
import com.lagradost.cloudstream3.mvvm.normalSafeApiCall import com.lagradost.cloudstream3.mvvm.normalSafeApiCall

View file

@ -44,13 +44,13 @@ class InAppUpdater {
data class GithubObject( data class GithubObject(
@JsonProperty("sha") val sha: String, // sha 256 hash @JsonProperty("sha") val sha: String, // sha 256 hash
@JsonProperty("type") val type: String, // object type @JsonProperty("type") val type: String, // object type
@JsonProperty("url") val url: String, @JsonProperty("url") val url: String,
) )
data class GithubTag( data class GithubTag(
@JsonProperty("object") val github_object: GithubObject, @JsonProperty("object") val github_object: GithubObject,
) )
data class Update( data class Update(
@JsonProperty("shouldUpdate") val shouldUpdate: Boolean, @JsonProperty("shouldUpdate") val shouldUpdate: Boolean,
@ -80,7 +80,7 @@ class InAppUpdater {
val url = "https://api.github.com/repos/LagradOst/CloudStream-3/releases" val url = "https://api.github.com/repos/LagradOst/CloudStream-3/releases"
val headers = mapOf("Accept" to "application/vnd.github.v3+json") val headers = mapOf("Accept" to "application/vnd.github.v3+json")
val response = val response =
mapper.readValue<List<GithubRelease>>(khttp.get(url, headers = headers).text) mapper.readValue<List<GithubRelease>>(khttp.get(url, headers = headers).text)
val versionRegex = Regex("""(.*?((\d)\.(\d)\.(\d)).*\.apk)""") val versionRegex = Regex("""(.*?((\d)\.(\d)\.(\d)).*\.apk)""")
@ -92,26 +92,29 @@ class InAppUpdater {
versionRegex.find(it.name)?.groupValues?.get(2) versionRegex.find(it.name)?.groupValues?.get(2)
}).toList().lastOrNull()*/ }).toList().lastOrNull()*/
val found = val found =
response.filter { rel -> response.filter { rel ->
!rel.prerelease !rel.prerelease
}.sortedWith(compareBy { release -> }.sortedWith(compareBy { release ->
release.assets.filter { it.content_type == "application/vnd.android.package-archive" } release.assets.filter { it.content_type == "application/vnd.android.package-archive" }
.getOrNull(0)?.name?.let { it1 -> .getOrNull(0)?.name?.let { it1 ->
versionRegex.find( versionRegex.find(
it1 it1
)?.groupValues?.get(2) )?.groupValues?.get(2)
} }
}).toList().lastOrNull() }).toList().lastOrNull()
val foundAsset = found?.assets?.getOrNull(0) val foundAsset = found?.assets?.getOrNull(0)
val currentVersion = packageName?.let { val currentVersion = packageName?.let {
packageManager.getPackageInfo(it, packageManager.getPackageInfo(
0) it,
0
)
} }
val foundVersion = foundAsset?.name?.let { versionRegex.find(it) } val foundVersion = foundAsset?.name?.let { versionRegex.find(it) }
val shouldUpdate = if (found != null && foundAsset?.browser_download_url != "" && foundVersion != null) currentVersion?.versionName?.compareTo( val shouldUpdate =
if (found != null && foundAsset?.browser_download_url != "" && foundVersion != null) currentVersion?.versionName?.compareTo(
foundVersion.groupValues[2] foundVersion.groupValues[2]
)!! < 0 else false )!! < 0 else false
return if (foundVersion != null) { return if (foundVersion != null) {
Update(shouldUpdate, foundAsset.browser_download_url, foundVersion.groupValues[2], found.body) Update(shouldUpdate, foundAsset.browser_download_url, foundVersion.groupValues[2], found.body)
} else { } else {
@ -161,6 +164,7 @@ class InAppUpdater {
val localContext = this val localContext = this
val id = downloadManager.enqueue(request) val id = downloadManager.enqueue(request)
registerReceiver( registerReceiver(
object : BroadcastReceiver() { object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) { override fun onReceive(context: Context?, intent: Intent?) {
@ -173,8 +177,7 @@ class InAppUpdater {
val c = downloadManager.query(query) val c = downloadManager.query(query)
if (c.moveToFirst()) { if (c.moveToFirst()) {
val columnIndex = c val columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS)
.getColumnIndex(DownloadManager.COLUMN_STATUS)
if (DownloadManager.STATUS_SUCCESSFUL == c if (DownloadManager.STATUS_SUCCESSFUL == c
.getInt(columnIndex) .getInt(columnIndex)
) { ) {
@ -217,8 +220,10 @@ class InAppUpdater {
if (update.shouldUpdate && update.updateURL != null) { if (update.shouldUpdate && update.updateURL != null) {
runOnUiThread { runOnUiThread {
val currentVersion = packageName?.let { val currentVersion = packageName?.let {
packageManager.getPackageInfo(it, packageManager.getPackageInfo(
0) it,
0
)
} }
val builder: AlertDialog.Builder = AlertDialog.Builder(this) val builder: AlertDialog.Builder = AlertDialog.Builder(this)
@ -233,23 +238,19 @@ class InAppUpdater {
val downloadStatus = context.downloadUpdate(update.updateURL) val downloadStatus = context.downloadUpdate(update.updateURL)
if (!downloadStatus) { if (!downloadStatus) {
runOnUiThread { runOnUiThread {
showToast(context, showToast(
context,
"Download Failed", "Download Failed",
Toast.LENGTH_LONG) Toast.LENGTH_LONG
)
} }
} /*else { }
activity.runOnUiThread {
Toast.makeText(localContext,
"Downloaded APK",
Toast.LENGTH_LONG).show()
}
}*/
} }
} }
setNegativeButton("Cancel") { _, _ -> } setNegativeButton("Cancel") { _, _ -> }
if(checkAutoUpdate) { if (checkAutoUpdate) {
setNeutralButton("Don't show again") { _, _ -> setNeutralButton("Don't show again") { _, _ ->
settingsManager.edit().putBoolean("auto_update", false).apply() settingsManager.edit().putBoolean("auto_update", false).apply()
} }

View file

@ -31,7 +31,7 @@ class JsUnpacker(packedJS: String?) {
val js = packedJS val js = packedJS
try { try {
var p = var p =
Pattern.compile("""\}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""", Pattern.DOTALL) Pattern.compile("""}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""", Pattern.DOTALL)
var m = p.matcher(js) var m = p.matcher(js)
if (m.find() && m.groupCount() == 4) { if (m.find() && m.groupCount() == 4) {
val payload = m.group(1).replace("\\'", "'") val payload = m.group(1).replace("\\'", "'")

View file

@ -5,7 +5,6 @@ import android.content.Context
import android.view.View import android.view.View
import android.widget.* import android.widget.*
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.util.forEach
import androidx.core.view.marginLeft import androidx.core.view.marginLeft
import androidx.core.view.marginRight import androidx.core.view.marginRight
import androidx.core.view.marginTop import androidx.core.view.marginTop

View file

@ -1,6 +1,5 @@
package com.lagradost.cloudstream3.utils package com.lagradost.cloudstream3.utils
import com.lagradost.cloudstream3.SearchResponse
import com.lagradost.cloudstream3.TvType import com.lagradost.cloudstream3.TvType
import com.lagradost.cloudstream3.ui.download.EasyDownloadButton import com.lagradost.cloudstream3.ui.download.EasyDownloadButton

View file

@ -7,7 +7,6 @@ import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Environment import android.os.Environment
import android.provider.MediaStore import android.provider.MediaStore
import android.webkit.MimeTypeMap
import android.widget.Toast import android.widget.Toast
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
@ -26,7 +25,6 @@ import com.lagradost.cloudstream3.utils.DataStore.getKey
import com.lagradost.cloudstream3.utils.DataStore.removeKey import com.lagradost.cloudstream3.utils.DataStore.removeKey
import com.lagradost.cloudstream3.utils.DataStore.setKey import com.lagradost.cloudstream3.utils.DataStore.setKey
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
import com.lagradost.cloudstream3.utils.VideoDownloadManager.getExistingDownloadUriOrNullQ
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@ -35,7 +33,6 @@ import java.lang.Thread.sleep
import java.net.URL import java.net.URL
import java.net.URLConnection import java.net.URLConnection
import java.util.* import java.util.*
import kotlin.collections.ArrayList
const val DOWNLOAD_CHANNEL_ID = "cloudstream3.general" const val DOWNLOAD_CHANNEL_ID = "cloudstream3.general"
const val DOWNLOAD_CHANNEL_NAME = "Downloads" const val DOWNLOAD_CHANNEL_NAME = "Downloads"
@ -91,7 +88,7 @@ object VideoDownloadManager {
val referer: String val referer: String
} }
fun VideoDownloadManager.IDownloadableMinimum.getId(): Int { fun IDownloadableMinimum.getId(): Int {
return url.hashCode() return url.hashCode()
} }
@ -146,9 +143,9 @@ object VideoDownloadManager {
private const val ERROR_CONTENT_RESOLVER_CANT_OPEN_STREAM = -8 private const val ERROR_CONTENT_RESOLVER_CANT_OPEN_STREAM = -8
private const val ERROR_CONTENT_RESOLVER_NOT_FOUND = -9 private const val ERROR_CONTENT_RESOLVER_NOT_FOUND = -9
const val KEY_RESUME_PACKAGES = "download_resume" private const val KEY_RESUME_PACKAGES = "download_resume"
const val KEY_DOWNLOAD_INFO = "download_info" const val KEY_DOWNLOAD_INFO = "download_info"
const val KEY_RESUME_QUEUE_PACKAGES = "download_q_resume" private const val KEY_RESUME_QUEUE_PACKAGES = "download_q_resume"
val downloadStatus = HashMap<Int, DownloadType>() val downloadStatus = HashMap<Int, DownloadType>()
val downloadStatusEvent = Event<Pair<Int, DownloadType>>() val downloadStatusEvent = Event<Pair<Int, DownloadType>>()
@ -428,7 +425,7 @@ object VideoDownloadManager {
) )
val folder = File(normalPath) val folder = File(normalPath)
if (folder.isDirectory) { if (folder.isDirectory) {
return folder.listFiles().map { Pair(it.name, it.toUri()) } return folder.listFiles()?.map { Pair(it.name, it.toUri()) }
} }
return null return null
} }
@ -934,7 +931,7 @@ object VideoDownloadManager {
context.setKey(KEY_RESUME_QUEUE_PACKAGES, dQueue) context.setKey(KEY_RESUME_QUEUE_PACKAGES, dQueue)
} }
fun isMyServiceRunning(context: Context, serviceClass: Class<*>): Boolean { /*fun isMyServiceRunning(context: Context, serviceClass: Class<*>): Boolean {
val manager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager? val manager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager?
for (service in manager!!.getRunningServices(Int.MAX_VALUE)) { for (service in manager!!.getRunningServices(Int.MAX_VALUE)) {
if (serviceClass.name == service.service.className) { if (serviceClass.name == service.service.className) {
@ -942,7 +939,7 @@ object VideoDownloadManager {
} }
} }
return false return false
} }*/
fun downloadEpisode( fun downloadEpisode(
context: Activity?, context: Activity?,

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android" <font-family
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<font <font
app:fontStyle="normal" app:fontStyle="normal"
app:fontWeight="100" app:fontWeight="100"

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:background="?attr/bitDarkerGrayBackground" android:background="?attr/bitDarkerGrayBackground"

View file

@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" xmlns:tools="http://schemas.android.com/tools" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="horizontal"
android:keepScreenOn="true" android:keepScreenOn="true"
app:backgroundTint="@android:color/black" app:backgroundTint="@android:color/black"

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:background="?attr/darkBackground" android:background="?attr/darkBackground"

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:background="@null" android:background="@null"

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:background="@null" android:background="@null"

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:background="?attr/bitDarkerGrayBackground" android:background="?attr/bitDarkerGrayBackground"

View file

@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:orientation="vertical"
android:focusable="true" android:focusable="true"

View file

@ -9,7 +9,6 @@
> >
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:foreground="?android:attr/selectableItemBackgroundBorderless" android:foreground="?android:attr/selectableItemBackgroundBorderless"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/backgroundCard" android:id="@+id/backgroundCard"
android:layout_margin="2dp" android:layout_margin="2dp"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -5,7 +5,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/subs_root" android:id="@+id/subs_root"
android:background="?attr/bitDarkerGrayBackground" android:background="?attr/bitDarkerGrayBackground"
xmlns:app="http://schemas.android.com/apk/res-auto"
> >
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android"> <paths>
<external-path <external-path
name="external" name="external"
path="." /> path="." />