add support for youtube music videos

This commit is contained in:
2026-02-12 11:55:14 +03:00
parent 21ab362776
commit b9fa2538db
+1 -1
View File
@@ -4,7 +4,7 @@ import path from "node:path";
import {Environment} from "../common/environment";
export function getYouTubeVideoId(url: string): string {
const regex = /(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?|shorts)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/i;
const regex = /(?:(?:youtube\.com|music\.youtube\.com)\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?|shorts|clip)\/|.*[?&]v=)|youtu\.be\/)([^"&?/\s]{11})/i;
const match = url.match(regex);
if (!match || !match[1]) throw new Error("Invalid YouTube or Shorts URL");
return match[1];