Spaces:
Sleeping

youtube / src /components /AppLayout.tsx
hengds2f's picture
Upload 81 files
ba07e44 verified
Raw History Blame Contribute Delete
10.5 kB
import React, { useState } from 'react';
/**
* Project landing / documentation page.
*
* NOTE: The actual deployable application is the Python Flask app in this repo
* (`app.py` + `templates/index.html` + `Dockerfile`). This React page exists only
* as an in-repo preview / overview of what gets deployed to Hugging Face Spaces.
*/
const AppLayout: React.FC = () => {
const [copied, setCopied] = useState<string | null>(null);
const copy = (key: string, text: string) => {
navigator.clipboard.writeText(text).then(() => {
setCopied(key);
setTimeout(() => setCopied(null), 1500);
});
};
const files = [
{ name: 'app.py', desc: 'Flask backend: /info, /download, /status/<id>, /file/<id> + auto-cleanup' },
{ name: 'templates/index.html', desc: 'Dark-themed UI with URL input, format dropdown, progress, history' },
{ name: 'Dockerfile', desc: 'Python 3.11 + ffmpeg + latest yt-dlp, exposes port 7860' },
{ name: 'requirements.txt', desc: 'flask, flask-cors, yt-dlp, gunicorn' },
{ name: 'README.md', desc: 'Hugging Face Space frontmatter (sdk: docker, port 7860, purple→blue)' },
];
const endpoints = [
{ method: 'POST', path: '/info', desc: 'Returns title, thumbnail, duration, uploader, view_count for a URL' },
{ method: 'POST', path: '/download', desc: 'Queues a background download job. Returns { job_id }' },
{ method: 'GET', path: '/status/<job_id>', desc: 'Returns { status, progress, title, ... } — poll every 1s' },
{ method: 'GET', path: '/file/<job_id>', desc: 'Streams the finished file to the browser as an attachment' },
{ method: 'GET', path: '/healthz', desc: 'Liveness probe — returns { ok: true, jobs: N }' },
];
const formats = [
{ id: 'best', label: 'Best Quality (Video + Audio)' },
{ id: '1080p', label: 'MP4 1080p' },
{ id: '720p', label: 'MP4 720p' },
{ id: '480p', label: 'MP4 480p' },
{ id: 'mp3', label: 'MP3 Audio Only (192kbps)' },
{ id: 'audio', label: 'Best Audio (webm/m4a)' },
];
const sites = ['YouTube', 'Vimeo', 'TikTok', 'Twitter / X', 'Instagram', 'Reddit', 'Twitch', 'Facebook', 'SoundCloud', 'Dailymotion', 'Bilibili', '+1000 more'];
return (
<div className="min-h-screen bg-[#0f0f23] text-gray-100 font-sans relative overflow-hidden">
{/* Glow background */}
<div className="pointer-events-none absolute inset-0">
<div className="absolute -top-32 -left-32 h-96 w-96 rounded-full bg-purple-600/20 blur-3xl" />
<div className="absolute top-1/2 -right-32 h-96 w-96 rounded-full bg-blue-600/20 blur-3xl" />
<div className="absolute bottom-0 left-1/3 h-72 w-72 rounded-full bg-indigo-600/15 blur-3xl" />
</div>
<div className="relative max-w-6xl mx-auto px-6 py-10">
{/* Header */}
<header className="flex items-center justify-between mb-14">
<div className="flex items-center gap-3">
<div className="h-10 w-10 rounded-xl bg-gradient-to-br from-purple-500 via-indigo-500 to-blue-500 grid place-items-center shadow-lg shadow-purple-500/40">
<svg viewBox="0 0 24 24" className="h-5 w-5 fill-white"><path d="M8 5v14l11-7L8 5z" /></svg>
</div>
<span className="font-extrabold text-xl tracking-tight">VidGrab</span>
</div>
<div className="flex items-center gap-3 text-sm">
<span className="px-3 py-1.5 rounded-full bg-purple-500/10 border border-purple-500/30 text-purple-200 font-medium">1000+ sites</span>
<a href="https://github.com/yt-dlp/yt-dlp" target="_blank" rel="noopener noreferrer" className="text-gray-400 hover:text-white">yt-dlp ↗</a>
</div>
</header>
{/* Hero */}
<section className="text-center mb-12">
<div className="inline-flex items-center gap-2 px-3 py-1.5 rounded-full bg-white/5 border border-white/10 text-xs text-gray-300 mb-6">
<span className="h-2 w-2 rounded-full bg-emerald-400 animate-pulse" />
Docker • Flask • yt-dlp • Hugging Face Spaces ready
</div>
<h1 className="text-4xl sm:text-6xl font-extrabold tracking-tight leading-tight bg-gradient-to-br from-white via-purple-200 to-indigo-300 bg-clip-text text-transparent">
Full-stack video<br />downloader, built.
</h1>
<p className="mt-5 max-w-2xl mx-auto text-gray-400 text-lg">
A production-ready Flask + yt-dlp app with a beautiful dark UI, packaged as a Docker image
that drops straight into a Hugging Face Space on port 7860.
</p>
<div className="mt-8 flex flex-wrap gap-3 justify-center">
<a
href="/"
className="px-6 py-3 rounded-xl bg-gradient-to-r from-purple-500 to-blue-500 font-semibold text-white shadow-lg shadow-purple-500/30 hover:shadow-purple-500/50 transition"
>
Open Live App ↗
</a>
<button
onClick={() => copy('docker', 'docker build -t vidgrab . && docker run -p 7860:7860 vidgrab')}
className="px-6 py-3 rounded-xl bg-white/5 border border-white/10 hover:bg-white/10 font-medium transition"
>
{copied === 'docker' ? '✓ Copied!' : 'Copy Docker command'}
</button>
</div>
</section>
{/* Files generated */}
<section className="mb-14">
<h2 className="text-xs uppercase tracking-[0.15em] text-gray-400 font-semibold mb-4">Files generated in this repo</h2>
<div className="grid sm:grid-cols-2 gap-3">
{files.map((f) => (
<div key={f.name} className="rounded-2xl bg-[#1a1a2e] border border-white/10 p-5 hover:border-purple-500/40 transition group">
<div className="flex items-center justify-between mb-1.5">
<code className="text-sm font-mono text-purple-300 font-semibold">{f.name}</code>
<span className="text-[10px] uppercase tracking-wider text-gray-500 group-hover:text-purple-300 transition">ready</span>
</div>
<p className="text-sm text-gray-400 leading-relaxed">{f.desc}</p>
</div>
))}
</div>
</section>
{/* API + Formats */}
<section className="grid lg:grid-cols-2 gap-6 mb-14">
<div className="rounded-2xl bg-[#1a1a2e] border border-white/10 p-6">
<h3 className="font-bold text-lg mb-4 flex items-center gap-2">
<span className="h-2 w-2 rounded-full bg-blue-400" /> HTTP API
</h3>
<ul className="space-y-3">
{endpoints.map((e) => (
<li key={e.path} className="flex items-start gap-3 text-sm">
<span className={`shrink-0 px-2 py-0.5 rounded-md font-mono text-[10px] font-bold ${e.method === 'POST' ? 'bg-purple-500/20 text-purple-200 border border-purple-500/40' : 'bg-blue-500/20 text-blue-200 border border-blue-500/40'}`}>
{e.method}
</span>
<div>
<code className="font-mono text-gray-200">{e.path}</code>
<p className="text-gray-400 text-xs mt-0.5">{e.desc}</p>
</div>
</li>
))}
</ul>
</div>
<div className="rounded-2xl bg-[#1a1a2e] border border-white/10 p-6">
<h3 className="font-bold text-lg mb-4 flex items-center gap-2">
<span className="h-2 w-2 rounded-full bg-purple-400" /> Format options
</h3>
<ul className="space-y-2">
{formats.map((f) => (
<li key={f.id} className="flex items-center justify-between py-2 px-3 rounded-lg bg-white/[0.03] border border-white/5">
<span className="text-sm text-gray-200">{f.label}</span>
<code className="font-mono text-xs text-purple-300">{f.id}</code>
</li>
))}
</ul>
</div>
</section>
{/* Supported sites */}
<section className="mb-14">
<h2 className="text-xs uppercase tracking-[0.15em] text-gray-400 font-semibold mb-4">Supported platforms</h2>
<div className="flex flex-wrap gap-2">
{sites.map((s) => (
<span key={s} className="px-3.5 py-1.5 rounded-full text-sm bg-white/5 border border-white/10 text-gray-300 hover:bg-purple-500/10 hover:border-purple-500/40 hover:text-purple-200 transition cursor-default">
{s}
</span>
))}
</div>
</section>
{/* Deploy steps */}
<section className="rounded-2xl bg-gradient-to-br from-purple-600/15 via-indigo-600/10 to-blue-600/15 border border-purple-500/20 p-8 mb-10">
<h2 className="text-2xl font-bold mb-2">Deploy to Hugging Face Spaces</h2>
<p className="text-gray-300 mb-6">Three steps. No build server. No config files beyond what's already here.</p>
<ol className="space-y-4">
{[
{ t: 'Create a Space', d: 'On huggingface.co/new-space, choose SDK = Docker.' },
{ t: 'Push these files', d: 'git push the entire repo (app.py, templates/, Dockerfile, requirements.txt, README.md) to the Space.' },
{ t: 'Wait ~2 minutes', d: 'HF builds the Docker image and serves the app on port 7860 automatically.' },
].map((s, i) => (
<li key={s.t} className="flex gap-4">
<span className="shrink-0 h-8 w-8 rounded-lg bg-gradient-to-br from-purple-500 to-blue-500 grid place-items-center font-bold text-sm">{i + 1}</span>
<div>
<div className="font-semibold">{s.t}</div>
<div className="text-sm text-gray-400">{s.d}</div>
</div>
</li>
))}
</ol>
</section>
{/* Footer */}
<footer className="text-center text-sm text-gray-500 pt-8 border-t border-white/5">
Built with <a href="https://github.com/yt-dlp/yt-dlp" target="_blank" rel="noopener noreferrer" className="text-indigo-300 hover:underline">yt-dlp</a>
{' • '}Flask{' • '}Docker{' • '}Open source. For personal &amp; educational use — respect copyright.
</footer>
</div>
</div>
);
};
export default AppLayout;