mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
fixed chomecast and removed khttp
This commit is contained in:
parent
42f76c1c5c
commit
250d307df7
6 changed files with 21 additions and 88 deletions
|
@ -80,7 +80,7 @@ dependencies {
|
|||
implementation 'androidx.core:core-ktx:1.6.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.3.1'
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
|
||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
|
||||
|
@ -91,9 +91,9 @@ dependencies {
|
|||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
|
||||
implementation "io.karn:khttp-android:0.1.2"
|
||||
//implementation "io.karn:khttp-android:0.1.2" //okhttp instead
|
||||
implementation 'org.jsoup:jsoup:1.13.1'
|
||||
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.11.3"
|
||||
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.12.3"
|
||||
|
||||
implementation("com.google.android.material:material:1.4.0")
|
||||
|
||||
|
@ -105,9 +105,9 @@ dependencies {
|
|||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
|
||||
// Exoplayer
|
||||
implementation 'com.google.android.exoplayer:exoplayer:2.15.0'
|
||||
implementation 'com.google.android.exoplayer:extension-cast:2.15.0'
|
||||
implementation "com.google.android.exoplayer:extension-mediasession:2.15.0"
|
||||
implementation 'com.google.android.exoplayer:exoplayer:2.15.1'
|
||||
implementation 'com.google.android.exoplayer:extension-cast:2.15.1'
|
||||
implementation "com.google.android.exoplayer:extension-mediasession:2.15.1"
|
||||
//implementation "com.google.android.exoplayer:extension-leanback:2.14.0"
|
||||
|
||||
// Bug reports
|
||||
|
@ -130,8 +130,8 @@ dependencies {
|
|||
//implementation 'com.github.TorrentStream:TorrentStream-Android:2.7.0'
|
||||
|
||||
// Downloading
|
||||
implementation "androidx.work:work-runtime:2.7.0-beta01"
|
||||
implementation "androidx.work:work-runtime-ktx:2.7.0-beta01"
|
||||
implementation "androidx.work:work-runtime:2.7.0-rc01"
|
||||
implementation "androidx.work:work-runtime-ktx:2.7.0-rc01"
|
||||
|
||||
// Networking
|
||||
implementation "com.squareup.okhttp3:okhttp:4.9.0"
|
||||
|
|
|
@ -75,7 +75,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
updateLocale() // android fucks me by chaining lang when rotating the phone
|
||||
}
|
||||
|
||||
var mCastSession: CastSession? = null
|
||||
private var mCastSession: CastSession? = null
|
||||
lateinit var mSessionManager: SessionManager
|
||||
private val mSessionManagerListener: SessionManagerListener<Session> by lazy { SessionManagerListenerImpl() }
|
||||
|
||||
|
@ -135,6 +135,10 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
}
|
||||
|
||||
companion object {
|
||||
fun Activity?.getCastSession() : CastSession? {
|
||||
return (this as MainActivity?)?.mSessionManager?.currentCastSession
|
||||
}
|
||||
|
||||
var canEnterPipMode: Boolean = false
|
||||
var canShowPipMode: Boolean = false
|
||||
var isInPIPMode: Boolean = false
|
||||
|
@ -330,7 +334,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
}*/
|
||||
|
||||
// Fucks up anime info layout since that has its own layout
|
||||
cast_mini_controller_holder?.isVisible = destination.id != R.id.navigation_results
|
||||
cast_mini_controller_holder?.isVisible = !listOf(R.id.navigation_results,R.id.navigation_player).contains(destination.id)
|
||||
|
||||
nav_view.isVisible = listOf(
|
||||
R.id.navigation_home,
|
||||
|
|
|
@ -67,6 +67,7 @@ import com.google.android.gms.cast.framework.CastState
|
|||
import com.google.android.material.button.MaterialButton
|
||||
import com.lagradost.cloudstream3.*
|
||||
import com.lagradost.cloudstream3.MainActivity.Companion.canEnterPipMode
|
||||
import com.lagradost.cloudstream3.MainActivity.Companion.getCastSession
|
||||
import com.lagradost.cloudstream3.MainActivity.Companion.isInPIPMode
|
||||
import com.lagradost.cloudstream3.MainActivity.Companion.showToast
|
||||
import com.lagradost.cloudstream3.R
|
||||
|
@ -1058,7 +1059,7 @@ class PlayerFragment : Fragment() {
|
|||
val epData = getEpisode() ?: return@addCastStateListener
|
||||
|
||||
val index = links.indexOf(getCurrentUrl())
|
||||
(activity as MainActivity?)?.mCastSession?.startCast(
|
||||
activity?.getCastSession()?.startCast(
|
||||
apiName,
|
||||
currentIsMovie ?: return@addCastStateListener,
|
||||
currentHeaderName,
|
||||
|
|
|
@ -35,6 +35,7 @@ import com.google.android.material.button.MaterialButton
|
|||
import com.lagradost.cloudstream3.*
|
||||
import com.lagradost.cloudstream3.APIHolder.getApiFromName
|
||||
import com.lagradost.cloudstream3.APIHolder.getId
|
||||
import com.lagradost.cloudstream3.MainActivity.Companion.getCastSession
|
||||
import com.lagradost.cloudstream3.MainActivity.Companion.showToast
|
||||
import com.lagradost.cloudstream3.mvvm.Resource
|
||||
import com.lagradost.cloudstream3.mvvm.logError
|
||||
|
@ -430,7 +431,7 @@ class ResultFragment : Fragment() {
|
|||
|
||||
fun startChromecast(startIndex: Int) {
|
||||
val eps = currentEpisodes ?: return
|
||||
(activity as MainActivity?)?.mCastSession?.startCast(
|
||||
activity?.getCastSession()?.startCast(
|
||||
apiName,
|
||||
currentIsMovie ?: return,
|
||||
currentHeaderName,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.lagradost.cloudstream3.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.net.Uri
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
||||
import com.fasterxml.jackson.databind.json.JsonMapper
|
||||
|
@ -96,8 +97,10 @@ object CastHelper {
|
|||
startIndex: Int? = null,
|
||||
startTime: Long? = null,
|
||||
) : Boolean {
|
||||
println("HELLO:" + episodes.isNullOrEmpty())
|
||||
if(this == null) return false
|
||||
if (episodes.isEmpty()) return false
|
||||
println("LINKS SIE:" + currentLinks.size)
|
||||
if (currentLinks.size <= currentEpisodeIndex) return false
|
||||
|
||||
val epData = episodes[currentEpisodeIndex]
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
package com.lagradost.cloudstream3.utils
|
||||
|
||||
|
||||
import khttp.structures.authorization.Authorization
|
||||
import khttp.structures.cookie.CookieJar
|
||||
import khttp.structures.files.FileLike
|
||||
import khttp.structures.cookie.Cookie
|
||||
import khttp.responses.Response
|
||||
|
||||
|
||||
/**
|
||||
* An HTTP session manager.
|
||||
*
|
||||
* This class simply keeps cookies across requests.
|
||||
*
|
||||
* @property sessionCookies A cookie jar.
|
||||
*/
|
||||
class HttpSession {
|
||||
companion object {
|
||||
const val DEFAULT_TIMEOUT = 30.0
|
||||
|
||||
fun mergeCookies(cookie1: CookieJar, cookie2: Map<String, String>?): Map<String, String> {
|
||||
val a = cookie1
|
||||
if (!cookie2.isNullOrEmpty()) {
|
||||
a.putAll(cookie2)
|
||||
}
|
||||
return a
|
||||
}
|
||||
}
|
||||
|
||||
val sessionCookies = CookieJar()
|
||||
|
||||
fun get(
|
||||
url: String, headers: Map<String, String?> = mapOf(),
|
||||
params: Map<String, String> = mapOf(),
|
||||
data: Any? = null, json: Any? = null,
|
||||
auth: Authorization? = null,
|
||||
cookies: Map<String, String>? = null,
|
||||
timeout: Double = DEFAULT_TIMEOUT,
|
||||
allowRedirects: Boolean? = null,
|
||||
stream: Boolean = false, files: List<FileLike> = listOf(),
|
||||
): Response {
|
||||
val res = get(
|
||||
url, headers, params,
|
||||
data, json, auth,
|
||||
mergeCookies(sessionCookies, cookies), timeout,
|
||||
allowRedirects,
|
||||
stream, files
|
||||
)
|
||||
sessionCookies.putAll(res.cookies)
|
||||
sessionCookies.putAll(CookieJar(*res.headers.filter { it.key.toLowerCase() == "set-cookie" }.map { Cookie(it.value) }.toTypedArray()))
|
||||
return res
|
||||
}
|
||||
|
||||
fun post(
|
||||
url: String, headers: Map<String, String?> = mapOf(),
|
||||
params: Map<String, String> = mapOf(),
|
||||
data: Any? = null, json: Any? = null,
|
||||
auth: Authorization? = null,
|
||||
cookies: Map<String, String>? = null,
|
||||
timeout: Double = DEFAULT_TIMEOUT,
|
||||
allowRedirects: Boolean? = null,
|
||||
stream: Boolean = false, files: List<FileLike> = listOf()
|
||||
): Response {
|
||||
val res = post(
|
||||
url, headers, params,
|
||||
data, json, auth,
|
||||
mergeCookies(sessionCookies, cookies), timeout,
|
||||
allowRedirects,
|
||||
stream, files
|
||||
)
|
||||
sessionCookies.putAll(res.cookies)
|
||||
sessionCookies.putAll(CookieJar(*res.headers.filter { it.key.toLowerCase() == "set-cookie" }.map { Cookie(it.value) }.toTypedArray()))
|
||||
return res
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue