feat(tutorials): add video training academy management with YouTube parser and live preview

This commit is contained in:
mstfyldz
2026-08-22 13:49:00 +03:00
parent 2d149f1178
commit 7f690cc6d3
29 changed files with 2476 additions and 1034 deletions
+27
View File
@@ -0,0 +1,27 @@
export function extractYoutubeId(input: string): string {
const trimmed = input.trim()
if (!trimmed) return ''
// Direct 11-char ID
if (/^[a-zA-Z0-9_-]{11}$/.test(trimmed)) {
return trimmed
}
// youtu.be/ID
const shortMatch = trimmed.match(/youtu\.be\/([a-zA-Z0-9_-]{11})/)
if (shortMatch) return shortMatch[1]
// youtube.com/watch?v=ID
const watchMatch = trimmed.match(/[?&]v=([a-zA-Z0-9_-]{11})/)
if (watchMatch) return watchMatch[1]
// youtube.com/embed/ID
const embedMatch = trimmed.match(/youtube\.com\/embed\/([a-zA-Z0-9_-]{11})/)
if (embedMatch) return embedMatch[1]
// youtube.com/shorts/ID
const shortsMatch = trimmed.match(/youtube\.com\/shorts\/([a-zA-Z0-9_-]{11})/)
if (shortsMatch) return shortsMatch[1]
return trimmed
}