Support youtu.be links (#77)

This commit is contained in:
vfsfitvnm
2022-07-03 23:02:07 +02:00
parent 7e42820e7c
commit 3c35176b4f
3 changed files with 17 additions and 2 deletions

View File

@@ -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"))
}
}

View File

@@ -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) {