File tree Expand file tree Collapse file tree
app/src/main/java/com/github/libretube Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com.github.libretube.extensions
22
33import com.github.libretube.ui.dialogs.ShareDialog.Companion.YOUTUBE_FRONTEND_URL
4+ import com.github.libretube.ui.dialogs.ShareDialog.Companion.YOUTUBE_MUSIC_URL
5+ import com.github.libretube.ui.dialogs.ShareDialog.Companion.YOUTUBE_SHORT_URL
46
57/* *
6- * format a Piped route to an ID
8+ * format a full YouTube url or a path to a video/channel/playlist ID
79 */
810fun String.toID (): String {
911 return this
10- .replace(YOUTUBE_FRONTEND_URL , " " )
12+ // remove any youtube origins from urls
13+ .removePrefix(YOUTUBE_FRONTEND_URL )
14+ .removePrefix(YOUTUBE_MUSIC_URL )
15+ .removePrefix(YOUTUBE_SHORT_URL )
1116 .replace(" /watch?v=" , " " ) // videos
1217 .replace(" /channel/" , " " ) // channels
1318 .replace(" /playlist?list=" , " " ) // playlists
Original file line number Diff line number Diff line change @@ -149,6 +149,7 @@ class ShareDialog : DialogFragment() {
149149
150150 companion object {
151151 const val YOUTUBE_FRONTEND_URL = " https://www.youtube.com"
152+ const val YOUTUBE_MUSIC_URL = " https://music.youtube.com"
152153 const val YOUTUBE_SHORT_URL = " https://youtu.be"
153154 const val PIPED_FRONTEND_URL = " https://piped.video"
154155 }
You can’t perform that action at this time.
0 commit comments