import React, { useState, useEffect } from 'react';
import {
Youtube,
Instagram,
Music,
Video,
Download,
CheckCircle,
AlertCircle,
Loader2,
Link as LinkIcon,
Play,
Smartphone,
Shield,
Zap,
Github
} from 'lucide-react';
const App = () => {
const [platform, setPlatform] = useState('youtube');
const [url, setUrl] = useState('');
const [format, setFormat] = useState('mp4');
const [status, setStatus] = useState('idle'); // idle, fetching, converting, success, error
const [progress, setProgress] = useState(0);
const [errorMsg, setErrorMsg] = useState('');
const [result, setResult] = useState(null);
// Platform configuration
const platforms = {
youtube: {
name: 'YouTube',
icon: ,
color: 'text-red-500',
bg: 'bg-red-500',
gradient: 'from-red-500 to-red-600',
placeholder: 'Paste YouTube link (e.g., https://youtu.be/...)',
regex: /youtu/
},
instagram: {
name: 'Instagram',
icon: ,
color: 'text-pink-500',
bg: 'bg-pink-500',
gradient: 'from-pink-500 via-purple-500 to-orange-500',
placeholder: 'Paste Instagram Reel/Post link',
regex: /instagram/
},
tiktok: {
name: 'TikTok',
icon: ,
color: 'text-cyan-400',
bg: 'bg-black',
gradient: 'from-cyan-400 to-black', // stylistic choice for TikTok
placeholder: 'Paste TikTok video link',
regex: /tiktok/
}
};
const handleConvert = () => {
if (!url) {
setErrorMsg('Please enter a valid URL first.');
setStatus('error');
return;
}
// Simple validation simulation
const activePlatform = platforms[platform];
if (!activePlatform.regex.test(url)) {
setErrorMsg(`That doesn't look like a valid ${activePlatform.name} link.`);
setStatus('error');
return;
}
// Start Simulation
setErrorMsg('');
setStatus('fetching');
setProgress(0);
setResult(null);
// Mock: Fetching Metadata
setTimeout(() => {
setStatus('converting');
// Mock: Conversion Progress
let currentProgress = 0;
const interval = setInterval(() => {
currentProgress += Math.random() * 15;
if (currentProgress >= 100) {
currentProgress = 100;
clearInterval(interval);
finishConversion();
}
setProgress(Math.min(currentProgress, 100));
}, 300);
}, 1500);
};
const finishConversion = () => {
// Generate dummy result data
const mockTitles = [
"Amazing Content - Official Video (HD)",
"Viral Dance Challenge 2024",
"How to Code in React - Full Course",
"Funny Cat Compilation #42"
];
const randomTitle = mockTitles[Math.floor(Math.random() * mockTitles.length)];
setResult({
title: randomTitle,
duration: "12:34",
size: format === 'mp4' ? "42.5 MB" : "5.2 MB",
thumbnail: `https://placehold.co/600x400/1a1a1a/ffffff?text=${platforms[platform].name}+Video`,
quality: "1080p"
});
setStatus('success');
};
const handleDownload = () => {
// In a real app, this would trigger the browser download
const element = document.createElement("a");
const file = new Blob(["This is a dummy file for demonstration purposes."], {type: 'text/plain'});
element.href = URL.createObjectURL(file);
element.download = `OmniStream_Download.${format}`;
document.body.appendChild(element);
element.click();
};
return (
{/* Navbar */}
{/* Main Content */}
{/* Background Gradients */}
{/* Header Text */}
Universal Media Converter
Download videos and audio from YouTube, Instagram, and TikTok in high quality.
Fast, free, and secure.
{/* Converter Card */}
{/* Platform Tabs */}
{Object.keys(platforms).map((key) => {
const p = platforms[key];
const isActive = platform === key;
return (
);
})}
{/* Input Section */}
setUrl(e.target.value)}
placeholder={platforms[platform].placeholder}
className="w-full bg-transparent border-none focus:ring-0 text-white placeholder-slate-500 py-4 pl-3 pr-4"
/>
{url && (
)}
{/* Format Selector */}
{/* Convert Button */}
{/* Status Display */}
{status === 'error' && (
)}
{(status === 'fetching' || status === 'converting') && (
{status === 'fetching' ? 'Fetching Metadata...' : 'Converting Media...'}
{Math.round(progress)}%
{status === 'fetching' && (
Connecting to {platforms[platform].name} servers...
)}
)}
{/* Success Result Card */}
{status === 'success' && result && (
{/* Thumbnail */}
{result.duration}
{/* Info & Action */}
{result.title}
{format}
{result.quality}
{result.size}
Conversion completed successfully. Link expires in 2 hours.
)}
{/* Mock Footer Area inside card */}
By using this tool, you agree to our Terms of Service.
Only download content you have permission to use.
{/* Features Grid */}
Lightning Fast
Our cloud servers process media in seconds, not minutes.
100% Secure
No software installation required. Your data is encrypted.
Mobile Friendly
Works perfectly on iPhone, Android, tablets, and desktop.
);
}
export default App;