Skip to content
Open

Test #438

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
ebf9545
Test
Luna712 May 7, 2026
5ef97cd
Test
Luna712 May 7, 2026
7ef1d0a
Try
Luna712 May 7, 2026
c33c9f2
Update
Luna712 May 8, 2026
2748e16
Update
Luna712 May 8, 2026
c79e9f6
Update
Luna712 May 8, 2026
5672ae6
Update
Luna712 May 8, 2026
4fc74e1
Fix
Luna712 May 8, 2026
e725176
Fix
Luna712 May 8, 2026
f39a802
Try
Luna712 May 8, 2026
6c34c09
Try
Luna712 May 8, 2026
b16938d
Test
Luna712 May 8, 2026
87c5431
Update
Luna712 May 9, 2026
c6c062d
Test
Luna712 May 9, 2026
3a0a493
-
Luna712 May 9, 2026
814dcc6
-
Luna712 May 9, 2026
35fffa9
-
Luna712 May 9, 2026
b064702
Update
Luna712 May 9, 2026
610af03
Try fix
Luna712 May 9, 2026
23b5af1
update
Luna712 May 9, 2026
e4a6251
Update
Luna712 May 9, 2026
17121ea
Update
Luna712 May 9, 2026
f45a138
Update
Luna712 May 9, 2026
1df2815
Update
Luna712 May 9, 2026
88b5fcf
-
Luna712 May 9, 2026
e1b64a3
Update
Luna712 May 9, 2026
ac484bb
-
Luna712 May 9, 2026
3befb8f
Update
Luna712 May 9, 2026
124aa26
Update
Luna712 May 9, 2026
97be18a
Update
Luna712 May 9, 2026
1e39c4b
Fix
Luna712 May 9, 2026
92b4f7a
Update
Luna712 May 9, 2026
260281b
-
Luna712 May 9, 2026
0abaa4d
-
Luna712 May 9, 2026
ced0abf
-
Luna712 May 9, 2026
59ca226
Update
Luna712 May 9, 2026
7216821
Use ktor interceptor
Luna712 May 10, 2026
b566472
Update
Luna712 May 10, 2026
e1def47
-
Luna712 May 10, 2026
21f055e
Try
Luna712 May 10, 2026
dd124d7
Update
Luna712 May 10, 2026
f80f886
Fix
Luna712 May 10, 2026
b59f3b0
Fix
Luna712 May 10, 2026
c045f64
Fix
Luna712 May 10, 2026
0b35f85
Fix
Luna712 May 10, 2026
60ee97f
Update
Luna712 May 10, 2026
384e7dd
Fix
Luna712 May 10, 2026
69db6ed
Update
Luna712 May 10, 2026
eeb664b
Fix
Luna712 May 10, 2026
2f6498f
Fix
Luna712 May 10, 2026
654a66b
Fix
Luna712 May 10, 2026
19c05c0
Fix
Luna712 May 10, 2026
fddcfb8
Fix
Luna712 May 10, 2026
ce0cf5d
Fix
Luna712 May 10, 2026
d5ce11a
-
Luna712 May 10, 2026
018e210
Fix
Luna712 May 10, 2026
66888d1
Update
Luna712 May 10, 2026
ad2c1dd
Fix
Luna712 May 10, 2026
642d7b2
Fix
Luna712 May 10, 2026
5e9be02
Fix
Luna712 May 10, 2026
7c6a726
Update
Luna712 May 10, 2026
323d212
-
Luna712 May 10, 2026
8bb2d3d
Update
Luna712 May 10, 2026
6655896
Update
Luna712 May 10, 2026
ed910cf
Update
Luna712 May 10, 2026
f4e74c6
-
Luna712 May 10, 2026
8cf1392
Update
Luna712 May 10, 2026
1cb674b
Try
Luna712 May 10, 2026
7b48b56
Update
Luna712 May 10, 2026
1d1cf14
Fix
Luna712 May 10, 2026
8fa030b
Test
Luna712 May 10, 2026
c6a13a0
Try
Luna712 May 11, 2026
4cc3664
-
Luna712 May 11, 2026
2d15595
Try update
Luna712 May 11, 2026
f73b1cf
Fix
Luna712 May 11, 2026
5313215
Update
Luna712 May 11, 2026
5c8469d
Update
Luna712 May 11, 2026
20bf3ef
-
Luna712 May 11, 2026
390bbcc
Update
Luna712 May 12, 2026
7d3c37c
Update
Luna712 May 12, 2026
412a826
Update
Luna712 May 12, 2026
879a416
Use okhttp headers
Luna712 May 12, 2026
b6ebd5e
Back-compat CF interceptor
Luna712 May 12, 2026
6720c58
Fix
Luna712 May 12, 2026
a6bdb12
Fix
Luna712 May 12, 2026
b4366eb
Fix
Luna712 May 12, 2026
97bd241
Update
Luna712 May 12, 2026
3b7f979
Update
Luna712 May 12, 2026
c64eb51
Update
Luna712 May 12, 2026
98a8678
Update
Luna712 May 12, 2026
c3024b4
Update
Luna712 May 12, 2026
7e84792
Update
Luna712 May 12, 2026
9f0f0a6
Fix
Luna712 May 13, 2026
77be369
Update
Luna712 May 13, 2026
12baec2
Update
Luna712 May 13, 2026
2fc1c9a
Update
Luna712 May 13, 2026
d67e433
-
Luna712 May 13, 2026
f9cd6bb
Update
Luna712 May 13, 2026
76cc5fd
Fix
Luna712 May 13, 2026
557c074
Update
Luna712 May 13, 2026
23c420a
Update
Luna712 May 13, 2026
8fbed9c
Fix
Luna712 May 13, 2026
41a18f7
Update
Luna712 May 13, 2026
3d29e61
Fix
Luna712 May 13, 2026
27cfbd4
Update
Luna712 May 13, 2026
9a420d3
Fix
Luna712 May 13, 2026
6a865fa
Update
Luna712 May 13, 2026
8e0d753
-
Luna712 May 13, 2026
e4d1432
-
Luna712 May 13, 2026
6e56ed8
Add
Luna712 May 13, 2026
633aaf7
Fix
Luna712 May 13, 2026
edd0255
Test
Luna712 May 13, 2026
438f615
-
Luna712 May 13, 2026
a104a26
Update
Luna712 May 15, 2026
24a063a
Update
Luna712 May 15, 2026
98870f7
Update
Luna712 May 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
cache-read-only: false

- name: Run Gradle
run: ./gradlew assemblePrereleaseDebug lint
run: ./gradlew assemblePrereleaseDebug

- name: Upload Artifact
uses: actions/upload-artifact@v7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import androidx.annotation.AnyThread
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.mvvm.debugWarning
import com.lagradost.cloudstream3.mvvm.safe
import com.lagradost.nicehttp.Requests.Companion.await
import com.lagradost.cloudstream3.okHttpClient
import com.lagradost.nicehttp.RequestsCompat.await
import com.lagradost.nicehttp.cookies
import kotlinx.coroutines.runBlocking
import okhttp3.Headers
Expand Down Expand Up @@ -102,7 +103,8 @@ class CloudflareKiller : Interceptor {

val headers =
getHeaders(request.headers.toMap() + userAgentMap, cookies + request.cookies)
return app.baseClient.newCall(
@Suppress("DEPRECATION_ERROR")
return okHttpClient.newCall(
request.newBuilder()
.headers(headers)
.build()
Expand Down Expand Up @@ -135,4 +137,4 @@ class CloudflareKiller : Interceptor {
val cookies = savedCookies[request.url.host] ?: return null
return proceed(request, cookies)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.lagradost.cloudstream3.network

import androidx.annotation.AnyThread
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.okHttpClient
import com.lagradost.nicehttp.Requests
import com.lagradost.nicehttp.cookies
import kotlinx.coroutines.runBlocking
Expand Down Expand Up @@ -48,10 +49,10 @@ class DdosGuardKiller(private val alwaysBypass: Boolean) : Interceptor {
}

val headers = getHeaders(request.headers.toMap(), cookies + request.cookies)
return app.baseClient.newCall(
return okHttpClient.newCall(
request.newBuilder()
.headers(headers)
.build()
).execute()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import com.lagradost.cloudstream3.USER_AGENT
import com.lagradost.cloudstream3.mvvm.safe
import com.lagradost.nicehttp.Requests
import com.lagradost.nicehttp.ignoreAllSSLErrors
import io.ktor.client.*
import io.ktor.client.engine.okhttp.*
import io.ktor.client.plugins.*
import io.ktor.client.plugins.cache.*
import okhttp3.Cache
import okhttp3.Headers
import okhttp3.Headers.Companion.toHeaders
Expand All @@ -18,58 +22,66 @@ import java.security.Security

// Backwards compatible constructor, mark as deprecated later
fun Requests.initClient(context: Context) {
this.baseClient = buildDefaultClient(context)
this.baseClient = buildDefaultKtorClient(context)
}

/** Only use ignoreSSL if you know what you are doing*/
/** Only use ignoreSSL if you know what you are doing */
@Prerelease
fun Requests.initClient(context: Context, ignoreSSL: Boolean = false) {
this.baseClient = buildDefaultClient(context, ignoreSSL)
this.baseClient = buildDefaultKtorClient(context, ignoreSSL)
}


// Backwards compatible constructor, mark as deprecated later
fun buildDefaultClient(context: Context): OkHttpClient {
return buildDefaultClient(context, false)
}

/** Only use ignoreSSL if you know what you are doing*/
/** Only use ignoreSSL if you know what you are doing */
@Prerelease
fun buildDefaultClient(context: Context, ignoreSSL: Boolean = false): OkHttpClient {
safe { Security.insertProviderAt(Conscrypt.newProvider(), 1) }

val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
val dns = settingsManager.getInt(context.getString(R.string.dns_pref), 0)
val baseClient = OkHttpClient.Builder()

return OkHttpClient.Builder()
.followRedirects(true)
.followSslRedirects(true)
.apply {
if (ignoreSSL) {
ignoreAllSSLErrors()
}
}
.apply { if (ignoreSSL) ignoreAllSSLErrors() }
.cache(
// Note that you need to add a ResponseInterceptor to make this 100% active.
// The server response dictates if and when stuff should be cached.
Cache(
directory = File(context.cacheDir, "http_cache"),
maxSize = 50L * 1024L * 1024L // 50 MiB
)
).apply {
)
.apply {
when (dns) {
1 -> addGoogleDns()
2 -> addCloudFlareDns()
// 3 -> addOpenDns()
4 -> addAdGuardDns()
5 -> addDNSWatchDns()
6 -> addQuad9Dns()
7 -> addDnsSbDns()
8 -> addCanadianShieldDns()
}
}
// Needs to be build as otherwise the other builders will change this object
.build()
return baseClient
}

/**
* Builds a Ktor [HttpClient] using the OkHttp engine configured with the same
* settings as [buildDefaultClient] — cache, DNS, SSL, etc.
*/
fun buildDefaultKtorClient(context: Context, ignoreSSL: Boolean = false): HttpClient {
val okHttpClient = buildDefaultClient(context, ignoreSSL)
return HttpClient(OkHttp) {
install(HttpTimeout)
install(HttpCache)
install(HttpRequestRetry) { noRetry() }
engine {
preconfigured = okHttpClient
}
}
}

private val DEFAULT_HEADERS = mapOf("user-agent" to USER_AGENT)
Expand All @@ -89,4 +101,4 @@ fun getHeaders(
}) else mapOf()
val tempHeaders = (DEFAULT_HEADERS + headers + cookieMap)
return tempHeaders.toHeaders()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.mvvm.debugAssert
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.mvvm.safe
import com.lagradost.cloudstream3.okHttpClient
import com.lagradost.cloudstream3.ui.player.CustomDecoder.Companion.fixSubtitleAlignment
import com.lagradost.cloudstream3.ui.player.live.LiveHelper
import com.lagradost.cloudstream3.ui.player.live.PREFERRED_LIVE_OFFSET
Expand Down Expand Up @@ -732,18 +733,19 @@ class CS3IPlayer : IPlayer {

private var simpleCache: SimpleCache? = null

/// Create a small factory for small things, no cache, no cronet
// Create a small factory for small things, no cache, no cronet
private fun createOnlineSource(
headers: Map<String, String>?,
interceptor: Interceptor?
): HttpDataSource.Factory {
val client = if (interceptor == null) {
app.baseClient
okHttpClient
} else {
app.baseClient.newBuilder()
okHttpClient.newBuilder()
.addInterceptor(interceptor)
.build()
}

val source = OkHttpDataSource.Factory(client).setUserAgent(USER_AGENT)

if (!headers.isNullOrEmpty()) {
Expand Down Expand Up @@ -798,7 +800,7 @@ class CS3IPlayer : IPlayer {
val source = if (interceptor == null) {
if (engine == null) {
Log.d(TAG, "Using DefaultHttpDataSource for $link")
OkHttpDataSource.Factory(app.baseClient).setUserAgent(userAgent)
OkHttpDataSource.Factory(okHttpClient).setUserAgent(userAgent)
} else {
Log.d(TAG, "Using CronetDataSource for $link")
CronetDataSource.Factory(engine, Executors.newSingleThreadExecutor())
Expand All @@ -810,13 +812,13 @@ class CS3IPlayer : IPlayer {
}
} else {
Log.d(TAG, "Using OkHttpDataSource for $link")
val client = app.baseClient.newBuilder()
val client = okHttpClient.newBuilder()
.addInterceptor(interceptor)
.build()
OkHttpDataSource.Factory(client).setUserAgent(userAgent)
}

// Do no include empty referer, if the provider wants those they can use the header map.
// Do not include empty referer, if the provider wants those they can use the header map.
val refererMap =
if (link.referer.isBlank()) emptyMap() else mapOf("referer" to link.referer)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ object SearchSuggestionApi {
* Parses the TMDB search response and extracts movie/TV show titles.
* Filters to only include movies, TV shows, and anime.
*/
private fun parseSuggestions(response: NiceResponse): List<String> {
private suspend fun parseSuggestions(response: NiceResponse): List<String> {
return try {
val parsed = response.parsed<TmdbSearchResult>()
parsed.results
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ media3 = "1.9.3"
navigationKtx = "2.9.7"
newpipeextractor = "v0.26.0"
nextlibMedia3 = "1.9.3-0.12.0"
nicehttp = "0.4.18"
nicehttp = "ea97cfd14d"
overlappingpanels = "0.1.5"
paletteKtx = "1.0.0"
preferenceKtx = "1.2.1"
Expand Down Expand Up @@ -103,7 +103,7 @@ navigation-ui-ktx = { module = "androidx.navigation:navigation-ui-ktx", version.
newpipeextractor = { module = "com.github.teamnewpipe:NewPipeExtractor", version.ref = "newpipeextractor" }
nextlib-media3ext = { module = "io.github.anilbeesetti:nextlib-media3ext", version.ref = "nextlibMedia3" }
nextlib-mediainfo = { module = "io.github.anilbeesetti:nextlib-mediainfo", version.ref = "nextlibMedia3" }
nicehttp = { module = "com.github.Blatzar:NiceHttp", version.ref = "nicehttp" }
nicehttp = { module = "com.github.Luna712.NiceHttp-kmp:library", version.ref = "nicehttp" }
overlappingpanels = { module = "com.github.discord:OverlappingPanels", version.ref = "overlappingpanels" }
palette-ktx = { module = "androidx.palette:palette-ktx", version.ref = "paletteKtx" }
preference-ktx = { module = "androidx.preference:preference-ktx", version.ref = "preferenceKtx" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.lagradost.cloudstream3.utils.Coroutines.main
import com.lagradost.cloudstream3.utils.Coroutines.mainWork
import com.lagradost.cloudstream3.utils.Coroutines.runOnMainThread
import com.lagradost.cloudstream3.utils.Coroutines.threadSafeListOf
import com.lagradost.nicehttp.NiceResponse
import com.lagradost.nicehttp.requestCreator
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
Expand Down Expand Up @@ -293,7 +294,7 @@ fun WebResourceRequest.toRequest(): Request? {
}
}

fun Response.toWebResourceResponse(): WebResourceResponse {
fun NiceResponse.toWebResourceResponse(): WebResourceResponse {
val contentTypeValue = this.header("Content-Type")
// 1. contentType. 2. charset
val typeRegex = Regex("""(.*);(?:.*charset=(.*)(?:|;)|)""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import com.fleeksoft.ksoup.nodes.Document
import com.lagradost.nicehttp.NiceResponse
import com.lagradost.nicehttp.Requests
import com.lagradost.nicehttp.ResponseParser
import io.ktor.client.engine.okhttp.OkHttpEngine
import okhttp3.OkHttpClient
import kotlin.reflect.KClass

// Short name for requests client to make it nicer to use
Expand Down Expand Up @@ -40,6 +42,11 @@ var app = Requests(responseParser = jacksonResponseParser).apply {
defaultHeaders = mapOf("user-agent" to USER_AGENT)
}

// TODO: Remove usage of this by migrating interceptors and media3 to ktor
@InternalAPI
val okHttpClient = (app.baseClient.engine as? OkHttpEngine)
?.config?.preconfigured ?: OkHttpClient()

/** Parses the response body as a Ksoup Document. */
val NiceResponse.ksoupDocument: Document
get() = Ksoup.parse(text)
Expand All @@ -50,4 +57,4 @@ val NiceResponse.ksoupDocument: Document
@UnsafeSSL
var insecureApp = Requests(responseParser = jacksonResponseParser).apply {
defaultHeaders = mapOf("user-agent" to USER_AGENT)
}
}
Loading
Loading