Support channel urls
This commit is contained in:
@@ -72,6 +72,18 @@
|
|||||||
android:host="youtu.be"
|
android:host="youtu.be"
|
||||||
android:pathPrefix="/"
|
android:pathPrefix="/"
|
||||||
android:scheme="https" />
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="music.youtube.com"
|
||||||
|
android:pathPrefix="/channel"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="www.youtube.com"
|
||||||
|
android:pathPrefix="/channel"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="m.youtube.com"
|
||||||
|
android:pathPrefix="/c"
|
||||||
|
android:scheme="https" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ import it.vfsfitvnm.vimusic.ui.components.BottomSheetMenu
|
|||||||
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
|
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
|
||||||
import it.vfsfitvnm.vimusic.ui.components.rememberBottomSheetState
|
import it.vfsfitvnm.vimusic.ui.components.rememberBottomSheetState
|
||||||
import it.vfsfitvnm.vimusic.ui.screens.albumRoute
|
import it.vfsfitvnm.vimusic.ui.screens.albumRoute
|
||||||
|
import it.vfsfitvnm.vimusic.ui.screens.artistRoute
|
||||||
import it.vfsfitvnm.vimusic.ui.screens.home.HomeScreen
|
import it.vfsfitvnm.vimusic.ui.screens.home.HomeScreen
|
||||||
import it.vfsfitvnm.vimusic.ui.screens.player.Player
|
import it.vfsfitvnm.vimusic.ui.screens.player.Player
|
||||||
import it.vfsfitvnm.vimusic.ui.screens.playlistRoute
|
import it.vfsfitvnm.vimusic.ui.screens.playlistRoute
|
||||||
@@ -128,11 +129,15 @@ class MainActivity : ComponentActivity() {
|
|||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
val isSystemInDarkTheme = isSystemInDarkTheme()
|
val isSystemInDarkTheme = isSystemInDarkTheme()
|
||||||
|
|
||||||
var appearance by rememberSaveable(isSystemInDarkTheme, stateSaver = Appearance.Companion) {
|
var appearance by rememberSaveable(
|
||||||
|
isSystemInDarkTheme,
|
||||||
|
stateSaver = Appearance.Companion
|
||||||
|
) {
|
||||||
with(preferences) {
|
with(preferences) {
|
||||||
val colorPaletteName = getEnum(colorPaletteNameKey, ColorPaletteName.Dynamic)
|
val colorPaletteName = getEnum(colorPaletteNameKey, ColorPaletteName.Dynamic)
|
||||||
val colorPaletteMode = getEnum(colorPaletteModeKey, ColorPaletteMode.System)
|
val colorPaletteMode = getEnum(colorPaletteModeKey, ColorPaletteMode.System)
|
||||||
val thumbnailRoundness = getEnum(thumbnailRoundnessKey, ThumbnailRoundness.Light)
|
val thumbnailRoundness =
|
||||||
|
getEnum(thumbnailRoundnessKey, ThumbnailRoundness.Light)
|
||||||
|
|
||||||
val colorPalette =
|
val colorPalette =
|
||||||
colorPaletteOf(colorPaletteName, colorPaletteMode, isSystemInDarkTheme)
|
colorPaletteOf(colorPaletteName, colorPaletteMode, isSystemInDarkTheme)
|
||||||
@@ -225,6 +230,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
thumbnailRoundnessKey -> {
|
thumbnailRoundnessKey -> {
|
||||||
val thumbnailRoundness =
|
val thumbnailRoundness =
|
||||||
sharedPreferences.getEnum(key, ThumbnailRoundness.Light)
|
sharedPreferences.getEnum(key, ThumbnailRoundness.Light)
|
||||||
@@ -379,23 +385,35 @@ class MainActivity : ComponentActivity() {
|
|||||||
Toast.makeText(this, "Opening url...", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "Opening url...", Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
uri.getQueryParameter("list")?.let { playlistId ->
|
when (val path = uri.pathSegments.firstOrNull()) {
|
||||||
val browseId = "VL$playlistId"
|
"playlist" -> uri.getQueryParameter("list")?.let { playlistId ->
|
||||||
|
val browseId = "VL$playlistId"
|
||||||
|
|
||||||
if (playlistId.startsWith("OLAK5uy_")) {
|
if (playlistId.startsWith("OLAK5uy_")) {
|
||||||
Innertube.playlistPage(BrowseBody(browseId = browseId))?.getOrNull()?.let { playlist ->
|
Innertube.playlistPage(BrowseBody(browseId = browseId))?.getOrNull()?.let {
|
||||||
playlist.songsPage?.items?.firstOrNull()?.album?.endpoint?.browseId?.let { browseId ->
|
it.songsPage?.items?.firstOrNull()?.album?.endpoint?.browseId?.let { browseId ->
|
||||||
albumRoute.ensureGlobal(browseId)
|
albumRoute.ensureGlobal(browseId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
playlistRoute.ensureGlobal(browseId)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
playlistRoute.ensureGlobal(browseId)
|
|
||||||
}
|
}
|
||||||
} ?: (uri.getQueryParameter("v") ?: uri.takeIf { uri.host == "youtu.be" }?.path?.drop(1))?.let { videoId ->
|
|
||||||
Innertube.song(videoId)?.getOrNull()?.let { song ->
|
"channel", "c" -> uri.lastPathSegment?.let { channelId ->
|
||||||
val binder = snapshotFlow { binder }.filterNotNull().first()
|
artistRoute.ensureGlobal(channelId)
|
||||||
withContext(Dispatchers.Main) {
|
}
|
||||||
binder.player.forcePlay(song.asMediaItem)
|
|
||||||
|
else -> when {
|
||||||
|
path == "watch" -> uri.getQueryParameter("v")
|
||||||
|
uri.host == "youtu.be" -> path
|
||||||
|
else -> null
|
||||||
|
}?.let { videoId ->
|
||||||
|
Innertube.song(videoId)?.getOrNull()?.let { song ->
|
||||||
|
val binder = snapshotFlow { binder }.filterNotNull().first()
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
|
binder.player.forcePlay(song.asMediaItem)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user