Initial Commit

This commit is contained in:
2026-10-03 20:07:49 +02:00
commit a1346c98b1
427 changed files with 59320 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
export function getYoutubeId(href: string): string | null {
try {
const url = new URL(href)
if (url.hostname === 'youtu.be') {
return url.pathname.slice(1).split('/')[0] || null
}
if (url.hostname === 'youtube.com' || url.hostname.endsWith('.youtube.com')) {
if (url.pathname === '/watch') return url.searchParams.get('v')
const m = url.pathname.match(/^\/(shorts|embed|live)\/([\w-]+)/)
if (m?.[2]) return m[2]
}
return null
}
catch {
return null
}
}
export function youtubeEmbedUrl(videoId: string) {
return `https://www.youtube.com/embed/${videoId}`
}
export function youtubeThumbUrl(videoId: string) {
return `https://i.ytimg.com/vi/${videoId}/mqdefault.jpg`
}