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
				
			
		|  | @ -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…
	
	Add table
		Add a link
		
	
		Reference in a new issue