diff --git a/components/video-page/hooks/use-download-actions.ts b/components/video-page/hooks/use-download-actions.ts index fa175d4..8ec8af1 100644 --- a/components/video-page/hooks/use-download-actions.ts +++ b/components/video-page/hooks/use-download-actions.ts @@ -10,6 +10,7 @@ import type { VideoData, } from '@/components/video-page/types'; import { resolvePublicBunnyCdnHostname } from '@/lib/bunny-cdn'; +import { downloadNamedFile, extensionFromUrl, navigateDownload } from '@/lib/client/download-file'; function sanitizeDownloadFileName(value: string): string { return value @@ -117,18 +118,36 @@ export function useDownloadActions({ activeVersion, video }: UseDownloadActionsP throw new Error('Missing download URL'); } - const versionLabel = - activeVersion.versionLabel?.trim() || `v${activeVersion.versionNumber}`; - const baseName = sanitizeDownloadFileName(`${video.title} ${versionLabel}`) || 'video'; - const a = document.createElement('a'); - a.href = downloadUrl; - if (activeVersion.providerId === 'direct' || activeVersion.providerId === 'r2') { - const ext = activeVersion.originalUrl.split('.').pop()?.toLowerCase() || 'mp4'; - a.download = `${baseName}.${ext}`; + // File name: "