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