forked from recloudstream/cloudstream
might have fixed #1031
This commit is contained in:
parent
c573deb09c
commit
ad64cb3f86
2 changed files with 26 additions and 22 deletions
|
@ -18,6 +18,7 @@ import com.google.android.exoplayer2.trackselection.TrackSelector
|
|||
import com.google.android.exoplayer2.ui.SubtitleView
|
||||
import com.google.android.exoplayer2.upstream.DataSource
|
||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory
|
||||
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource
|
||||
import com.google.android.exoplayer2.upstream.cache.CacheDataSource
|
||||
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor
|
||||
import com.google.android.exoplayer2.upstream.cache.SimpleCache
|
||||
|
@ -313,17 +314,15 @@ class CS3IPlayer : IPlayer {
|
|||
val provider = getApiFromName(link.source)
|
||||
val interceptor = provider.getVideoInterceptor(link)
|
||||
|
||||
val client = app.baseClient
|
||||
.let {
|
||||
if (interceptor != null)
|
||||
it.newBuilder()
|
||||
val source = if (interceptor == null) {
|
||||
DefaultHttpDataSource.Factory().setUserAgent(USER_AGENT)
|
||||
} else {
|
||||
val client = app.baseClient.newBuilder()
|
||||
.addInterceptor(interceptor)
|
||||
.build()
|
||||
else it
|
||||
OkHttpDataSource.Factory(client).setUserAgent(USER_AGENT)
|
||||
}
|
||||
|
||||
return OkHttpDataSource.Factory(client).apply {
|
||||
setUserAgent(USER_AGENT)
|
||||
val headers = mapOf(
|
||||
"referer" to link.referer,
|
||||
"accept" to "*/*",
|
||||
|
@ -333,6 +332,8 @@ class CS3IPlayer : IPlayer {
|
|||
"sec-fetch-mode" to "navigate",
|
||||
"sec-fetch-dest" to "video"
|
||||
) + link.headers // Adds the headers from the provider, e.g Authorization
|
||||
|
||||
return source.apply {
|
||||
setDefaultRequestProperties(headers)
|
||||
|
||||
//https://stackoverflow.com/questions/69040127/error-code-io-bad-http-status-exoplayer-android
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.bumptech.glide.load.model.GlideUrl
|
|||
import com.bumptech.glide.module.AppGlideModule
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.bumptech.glide.signature.ObjectKey
|
||||
import com.lagradost.cloudstream3.USER_AGENT
|
||||
import com.lagradost.cloudstream3.network.DdosGuardKiller
|
||||
import com.lagradost.cloudstream3.network.initClient
|
||||
import com.lagradost.nicehttp.Requests
|
||||
|
@ -33,7 +34,9 @@ class GlideModule : AppGlideModule() {
|
|||
// https://stackoverflow.com/a/61634041
|
||||
override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
|
||||
val client =
|
||||
Requests().initClient(context)
|
||||
Requests().apply {
|
||||
defaultHeaders = mapOf("user-agent" to USER_AGENT)
|
||||
}.initClient(context)
|
||||
.newBuilder()
|
||||
.addInterceptor(DdosGuardKiller(false))
|
||||
.build()
|
||||
|
|
Loading…
Reference in a new issue