mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
open youtube links in app
This commit is contained in:
parent
8092759199
commit
72f12b1af4
@ -40,9 +40,6 @@
|
|||||||
<!-- youtube -->
|
<!-- youtube -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
|
|
||||||
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
<data android:scheme="http" />
|
<data android:scheme="http" />
|
||||||
@ -55,7 +52,7 @@
|
|||||||
<data android:pathPrefix="/v/" />
|
<data android:pathPrefix="/v/" />
|
||||||
<data android:pathPrefix="/embed/" />
|
<data android:pathPrefix="/embed/" />
|
||||||
<data android:pathPrefix="/watch" />
|
<data android:pathPrefix="/watch" />
|
||||||
<data android:pathPrefix="/attribution_link" />
|
<!--<data android:pathPrefix="/attribution_link" />-->
|
||||||
<data android:pathPrefix="/shorts/" />
|
<data android:pathPrefix="/shorts/" />
|
||||||
<!-- channel prefix -->
|
<!-- channel prefix -->
|
||||||
<data android:pathPrefix="/channel/" />
|
<data android:pathPrefix="/channel/" />
|
||||||
@ -98,7 +95,6 @@
|
|||||||
<data android:host="tube.connect.cafe" />
|
<data android:host="tube.connect.cafe" />
|
||||||
<data android:host="invidious.kavin.rocks" />
|
<data android:host="invidious.kavin.rocks" />
|
||||||
<data android:host="invidious-us.kavin.rocks" />
|
<data android:host="invidious-us.kavin.rocks" />
|
||||||
<data android:host="piped.kavin.rocks" />
|
|
||||||
<data android:host="invidious.site" />
|
<data android:host="invidious.site" />
|
||||||
<data android:host="vid.mint.lgbt" />
|
<data android:host="vid.mint.lgbt" />
|
||||||
<data android:host="invidiou.site" />
|
<data android:host="invidiou.site" />
|
||||||
@ -118,6 +114,7 @@
|
|||||||
<data android:host="y.com.cm" />
|
<data android:host="y.com.cm" />
|
||||||
<data android:pathPrefix="/" />
|
<data android:pathPrefix="/" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<!-- Piped filter -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
|
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
|
||||||
|
@ -14,6 +14,7 @@ import android.widget.LinearLayout
|
|||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.constraintlayout.motion.widget.MotionLayout
|
import androidx.constraintlayout.motion.widget.MotionLayout
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.text.HtmlCompat
|
import androidx.core.text.HtmlCompat
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.ViewCompat.getWindowInsetsController
|
import androidx.core.view.ViewCompat.getWindowInsetsController
|
||||||
@ -101,7 +102,59 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
Log.d("dafaq",data.host+" ${data.path} ")
|
Log.d("dafaq",data.host+" ${data.path} ")
|
||||||
|
if(data.host != null){
|
||||||
|
if(data.host!!.contains("youtube.com",true)){
|
||||||
|
if(data.path != null){
|
||||||
|
//channel
|
||||||
|
if(data.path!!.contains("/channel/") || data.path!!.contains("/c/") || data.path!!.contains("/user/")){
|
||||||
|
var channel = data.path
|
||||||
|
channel = channel!!.replace("/c/","")
|
||||||
|
channel = channel!!.replace("/user/","")
|
||||||
|
val bundle = bundleOf("channel_id" to channel)
|
||||||
|
navController.navigate(R.id.channel,bundle)
|
||||||
|
}else if(data.path!!.contains("/playlist")){
|
||||||
|
var playlist = data.query
|
||||||
|
playlist = playlist!!.replace("list=","")
|
||||||
|
val bundle = bundleOf("playlist_id" to playlist)
|
||||||
|
navController.navigate(R.id.playlistFragment,bundle)
|
||||||
|
}else if(data.path!!.contains("/shorts/") || data.path!!.contains("/embed/") || data.path!!.contains("/v/")){
|
||||||
|
var watch = data.path!!.replace("/shorts/","").replace("/v/","").replace("/embed/","")
|
||||||
|
var bundle = Bundle()
|
||||||
|
bundle.putString("videoId",watch)
|
||||||
|
var frag = PlayerFragment()
|
||||||
|
frag.arguments = bundle
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.remove(PlayerFragment())
|
||||||
|
.commit()
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(R.id.container, frag)
|
||||||
|
.commitNow()
|
||||||
|
}else if(data.path!!.contains("/watch") && data.query != null){
|
||||||
|
Log.d("dafaq",data.query!!)
|
||||||
|
var watch = data.query!!
|
||||||
|
var watches = watch.split("&")
|
||||||
|
if (watches.size >1){
|
||||||
|
for (v in watches){
|
||||||
|
if (v.contains("v=")){
|
||||||
|
var bundle = Bundle()
|
||||||
|
bundle.putString("videoId",v.replace("v=",""))
|
||||||
|
var frag = PlayerFragment()
|
||||||
|
frag.arguments = bundle
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.remove(PlayerFragment())
|
||||||
|
.commit()
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(R.id.container, frag)
|
||||||
|
.commitNow()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ class PlayerFragment : Fragment() {
|
|||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
videoId = videoId!!.replace("/watch?v=","")
|
||||||
relDownloadVideo = view.findViewById(R.id.relPlayer_download)
|
relDownloadVideo = view.findViewById(R.id.relPlayer_download)
|
||||||
val mainActivity = activity as MainActivity
|
val mainActivity = activity as MainActivity
|
||||||
mainActivity.findViewById<FrameLayout>(R.id.container).visibility=View.VISIBLE
|
mainActivity.findViewById<FrameLayout>(R.id.container).visibility=View.VISIBLE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user