mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
feat (play with cloudstream) : open links with matching provider
This commit is contained in:
parent
01f21e0fe8
commit
323ce5855f
1 changed files with 24 additions and 0 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue