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.ui.SubtitleView
|
||||||
import com.google.android.exoplayer2.upstream.DataSource
|
import com.google.android.exoplayer2.upstream.DataSource
|
||||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory
|
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.CacheDataSource
|
||||||
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor
|
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor
|
||||||
import com.google.android.exoplayer2.upstream.cache.SimpleCache
|
import com.google.android.exoplayer2.upstream.cache.SimpleCache
|
||||||
|
@ -313,26 +314,26 @@ class CS3IPlayer : IPlayer {
|
||||||
val provider = getApiFromName(link.source)
|
val provider = getApiFromName(link.source)
|
||||||
val interceptor = provider.getVideoInterceptor(link)
|
val interceptor = provider.getVideoInterceptor(link)
|
||||||
|
|
||||||
val client = app.baseClient
|
val source = if (interceptor == null) {
|
||||||
.let {
|
DefaultHttpDataSource.Factory().setUserAgent(USER_AGENT)
|
||||||
if (interceptor != null)
|
} else {
|
||||||
it.newBuilder()
|
val client = app.baseClient.newBuilder()
|
||||||
.addInterceptor(interceptor)
|
.addInterceptor(interceptor)
|
||||||
.build()
|
.build()
|
||||||
else it
|
OkHttpDataSource.Factory(client).setUserAgent(USER_AGENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
return OkHttpDataSource.Factory(client).apply {
|
val headers = mapOf(
|
||||||
setUserAgent(USER_AGENT)
|
"referer" to link.referer,
|
||||||
val headers = mapOf(
|
"accept" to "*/*",
|
||||||
"referer" to link.referer,
|
"sec-ch-ua" to "\"Chromium\";v=\"91\", \" Not;A Brand\";v=\"99\"",
|
||||||
"accept" to "*/*",
|
"sec-ch-ua-mobile" to "?0",
|
||||||
"sec-ch-ua" to "\"Chromium\";v=\"91\", \" Not;A Brand\";v=\"99\"",
|
"sec-fetch-user" to "?1",
|
||||||
"sec-ch-ua-mobile" to "?0",
|
"sec-fetch-mode" to "navigate",
|
||||||
"sec-fetch-user" to "?1",
|
"sec-fetch-dest" to "video"
|
||||||
"sec-fetch-mode" to "navigate",
|
) + link.headers // Adds the headers from the provider, e.g Authorization
|
||||||
"sec-fetch-dest" to "video"
|
|
||||||
) + link.headers // Adds the headers from the provider, e.g Authorization
|
return source.apply {
|
||||||
setDefaultRequestProperties(headers)
|
setDefaultRequestProperties(headers)
|
||||||
|
|
||||||
//https://stackoverflow.com/questions/69040127/error-code-io-bad-http-status-exoplayer-android
|
//https://stackoverflow.com/questions/69040127/error-code-io-bad-http-status-exoplayer-android
|
||||||
|
@ -468,7 +469,7 @@ class CS3IPlayer : IPlayer {
|
||||||
.setLoadControl(
|
.setLoadControl(
|
||||||
DefaultLoadControl.Builder()
|
DefaultLoadControl.Builder()
|
||||||
.setTargetBufferBytes(
|
.setTargetBufferBytes(
|
||||||
if(cacheSize <= 0) {
|
if (cacheSize <= 0) {
|
||||||
DefaultLoadControl.DEFAULT_TARGET_BUFFER_BYTES
|
DefaultLoadControl.DEFAULT_TARGET_BUFFER_BYTES
|
||||||
} else {
|
} else {
|
||||||
if (cacheSize > Int.MAX_VALUE) Int.MAX_VALUE else cacheSize.toInt()
|
if (cacheSize > Int.MAX_VALUE) Int.MAX_VALUE else cacheSize.toInt()
|
||||||
|
@ -476,7 +477,7 @@ class CS3IPlayer : IPlayer {
|
||||||
)
|
)
|
||||||
.setBufferDurationsMs(
|
.setBufferDurationsMs(
|
||||||
DefaultLoadControl.DEFAULT_MIN_BUFFER_MS,
|
DefaultLoadControl.DEFAULT_MIN_BUFFER_MS,
|
||||||
if(videoBufferMs <= 0) {
|
if (videoBufferMs <= 0) {
|
||||||
DefaultLoadControl.DEFAULT_MAX_BUFFER_MS
|
DefaultLoadControl.DEFAULT_MAX_BUFFER_MS
|
||||||
} else {
|
} else {
|
||||||
videoBufferMs.toInt()
|
videoBufferMs.toInt()
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.bumptech.glide.load.model.GlideUrl
|
||||||
import com.bumptech.glide.module.AppGlideModule
|
import com.bumptech.glide.module.AppGlideModule
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
import com.bumptech.glide.signature.ObjectKey
|
import com.bumptech.glide.signature.ObjectKey
|
||||||
|
import com.lagradost.cloudstream3.USER_AGENT
|
||||||
import com.lagradost.cloudstream3.network.DdosGuardKiller
|
import com.lagradost.cloudstream3.network.DdosGuardKiller
|
||||||
import com.lagradost.cloudstream3.network.initClient
|
import com.lagradost.cloudstream3.network.initClient
|
||||||
import com.lagradost.nicehttp.Requests
|
import com.lagradost.nicehttp.Requests
|
||||||
|
@ -33,7 +34,9 @@ class GlideModule : AppGlideModule() {
|
||||||
// https://stackoverflow.com/a/61634041
|
// https://stackoverflow.com/a/61634041
|
||||||
override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
|
override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
|
||||||
val client =
|
val client =
|
||||||
Requests().initClient(context)
|
Requests().apply {
|
||||||
|
defaultHeaders = mapOf("user-agent" to USER_AGENT)
|
||||||
|
}.initClient(context)
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.addInterceptor(DdosGuardKiller(false))
|
.addInterceptor(DdosGuardKiller(false))
|
||||||
.build()
|
.build()
|
||||||
|
|
Loading…
Reference in a new issue