Add webview support for cloudstreamrepo uri

This commit is contained in:
Blatzar 2022-08-17 00:17:50 +02:00
parent 63d6ea02c0
commit 99d6aef993
2 changed files with 15 additions and 5 deletions

View file

@ -93,6 +93,7 @@ import com.lagradost.cloudstream3.utils.Coroutines.main
import com.lagradost.cloudstream3.utils.Event import com.lagradost.cloudstream3.utils.Event
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
import java.net.URI
const val VLC_PACKAGE = "org.videolan.vlc" const val VLC_PACKAGE = "org.videolan.vlc"
@ -375,7 +376,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
} }
} }
} }
} else if (str.contains(appStringRepo)) { } else if (URI(str).scheme == appStringRepo) {
val url = str.replaceFirst(appStringRepo, "https") val url = str.replaceFirst(appStringRepo, "https")
loadRepository(url) loadRepository(url)
} else { } else {

View file

@ -11,8 +11,10 @@ import android.webkit.WebViewClient
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.USER_AGENT import com.lagradost.cloudstream3.USER_AGENT
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.appStringRepo
import com.lagradost.cloudstream3.utils.AppUtils.loadRepository import com.lagradost.cloudstream3.utils.AppUtils.loadRepository
import kotlinx.android.synthetic.main.fragment_webview.* import kotlinx.android.synthetic.main.fragment_webview.*
import java.net.URI
class WebviewFragment : Fragment() { class WebviewFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -27,10 +29,17 @@ class WebviewFragment : Fragment() {
request: WebResourceRequest? request: WebResourceRequest?
): Boolean { ): Boolean {
val requestUrl = request?.url.toString() val requestUrl = request?.url.toString()
if (requestUrl.startsWith("https://cs.repo")) {
val realUrl = "https://" + requestUrl.substringAfter("?") val repoUrl = if (requestUrl.startsWith("https://cs.repo")) {
println("Repository url: $realUrl :::: $requestUrl") "https://" + requestUrl.substringAfter("?")
activity?.loadRepository(realUrl) } else if (URI(requestUrl).scheme == appStringRepo) {
"https://" + requestUrl.replaceFirst(appStringRepo, "https")
} else {
null
}
if (repoUrl != null) {
activity?.loadRepository(repoUrl)
findNavController().popBackStack() findNavController().popBackStack()
return true return true
} }