import { useState } from 'react'; import { apiDownloaderDownloadRetrieve, apiDownloaderDownloadCreate } from '@/api/generated/public/downloader'; import { type VideoInfoResponse } from '@/api/generated/public/models'; export default function Downloader() { const [videoUrl, setVideoUrl] = useState(''); const [videoInfo, setVideoInfo] = useState(null); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); async function retriveVideoInfo() { setIsLoading(true); setError(null); try { const info = await apiDownloaderDownloadRetrieve({ url: videoUrl }); setVideoInfo(info); } catch (err: any) { setError({ error: err.message || 'Failed to retrieve video info' }); } finally { setIsLoading(false); } console.log('Retrieving video info for URL:', videoUrl); console.log('Retrieved video info:', videoInfo); } return (

Video Downloader

setVideoUrl(e.target.value)} placeholder="Paste video URL here" className="w-full p-2 border rounded mb-4" /> {isLoading &&

Loading video info...

} {error &&

Error: {error?.error}

} {videoInfo && (

{videoInfo.title}

{videoInfo.thumbnail && ( {videoInfo.title} )}

Duration: {videoInfo.duration}s

Available Video Qualities:

    {videoInfo.video_resolutions?.map((res) => (
  • {res}
  • ))}

Available Audio Qualities:

    {videoInfo.audio_resolutions?.map((res) => (
  • {res}
  • ))}
)}
); }