From 500fae8995ec5048b6b6b60e6af1dd4b66ef2179 Mon Sep 17 00:00:00 2001
From: Sam Carton
Date: Sun, 28 Jul 2024 15:14:01 +0800
Subject: [PATCH] handle music.youtube.com links
---
src/components/VideoPlayer.tsx | 5 ++++-
src/pages/index.astro | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/components/VideoPlayer.tsx b/src/components/VideoPlayer.tsx
index 418a341..956655a 100644
--- a/src/components/VideoPlayer.tsx
+++ b/src/components/VideoPlayer.tsx
@@ -34,7 +34,10 @@ const tryGetVideoUrl = (urlInput: string | null) => {
return urlInput;
}
- if (urlInput.startsWith("https://youtu.be")) {
+ if (
+ urlInput.startsWith("https://youtu.be") ||
+ urlInput.startsWith("https://music.youtube.com")
+ ) {
// regex to extract the video ID from: https://youtu.be/sjgtpKxhZa4?si=lhbg5O4yeHiABClV
const videoId = urlInput.match(
/(?:\?v=|&v=|youtu\.be\/)(.*?)(?:\?|$)/,
diff --git a/src/pages/index.astro b/src/pages/index.astro
index 17d5237..23439cf 100644
--- a/src/pages/index.astro
+++ b/src/pages/index.astro
@@ -39,7 +39,10 @@ import Footer from "../components/Footer.astro";
Cruise CONTROL is a simple speed and loop control for YouTube
videos.
- Enter either the full video URL or the ID to get started.
+
+ Enter either the full video URL, YouTube Music URL, or the video ID to
+ get started.
+