From 323ce5855f320ef0f6d24d0b12400cea738fc4bc Mon Sep 17 00:00:00 2001 From: coxju Date: Sat, 13 Jan 2024 12:56:11 +0530 Subject: [PATCH] feat (play with cloudstream) : open links with matching provider --- .../ui/player/DownloadedPlayerActivity.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/DownloadedPlayerActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/DownloadedPlayerActivity.kt index 1e2ea540..881ba7a9 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/DownloadedPlayerActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/DownloadedPlayerActivity.kt @@ -8,11 +8,14 @@ import android.util.Log import android.view.KeyEvent import androidx.activity.OnBackPressedCallback import androidx.appcompat.app.AppCompatActivity +import com.lagradost.cloudstream3.APIHolder import com.lagradost.cloudstream3.CommonActivity import com.lagradost.cloudstream3.R +import com.lagradost.cloudstream3.utils.AppUtils.loadResult import com.lagradost.cloudstream3.utils.ExtractorUri import com.lagradost.cloudstream3.utils.UIHelper.navigate import com.lagradost.safefile.SafeFile +import me.xdrop.fuzzywuzzy.FuzzySearch const val DTAG = "PlayerActivity" @@ -36,6 +39,27 @@ class DownloadedPlayerActivity : AppCompatActivity() { } private fun playLink(url: String) { + // check if url matches any provider + synchronized(APIHolder.apis) { + for (api in APIHolder.apis) { + if (url.startsWith(api.mainUrl)) { + loadResult(url, api.name) + return + } + } + // this is to match mirror domains - like example.com, example.net + for (api in APIHolder.apis) { + if (FuzzySearch.partialRatio( + api.mainUrl, + url + ) > 80 + ) { + loadResult(url, api.name) + return + } + } + } + this.navigate( R.id.global_to_navigation_player, GeneratorPlayer.newInstance( LinkGenerator(