Support youtu.be links (#77)
This commit is contained in:
parent
7e42820e7c
commit
3c35176b4f
|
@ -68,13 +68,16 @@
|
|||
android:host="m.youtube.com"
|
||||
android:pathPrefix="/watch"
|
||||
android:scheme="https" />
|
||||
<data
|
||||
android:host="youtu.be"
|
||||
android:pathPrefix="/"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".service.PlayerService"
|
||||
android:exported="false"
|
||||
|
||||
android:foregroundServiceType="mediaPlayback">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MEDIA_BUTTON"/>
|
||||
|
|
|
@ -77,6 +77,12 @@ fun IntentUriScreen(uri: Uri) {
|
|||
YouTube.song(videoId)?.map { song ->
|
||||
song?.let { listOf(song) } ?: emptyList()
|
||||
}
|
||||
} ?: uri.takeIf {
|
||||
uri.host == "youtu.be"
|
||||
}?.path?.drop(1)?.let { videoId ->
|
||||
YouTube.song(videoId)?.map { song ->
|
||||
song?.let { listOf(song) } ?: emptyList()
|
||||
}
|
||||
} ?: Result.failure(Error("Missing URL parameters"))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,13 @@ fun SearchScreen(
|
|||
val typography = LocalTypography.current
|
||||
|
||||
val isOpenableUrl = remember(textFieldValue.text) {
|
||||
Regex("""https://(music|www|m)\.youtube.com/(watch|playlist).*""").matches(textFieldValue.text)
|
||||
listOf(
|
||||
"https://www.youtube.com/watch?",
|
||||
"https://music.youtube.com/watch?",
|
||||
"https://www.youtube.com/list?",
|
||||
"https://music.youtube.com/list?",
|
||||
"https://youtu.be/",
|
||||
).any(textFieldValue.text::startsWith)
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
|
|
Loading…
Reference in a new issue