Skip to content

Download videos from almost any website. Lightweight, self-hosted media downloader with a clean web UI.

HTML

Initial release

averygan3a1ec0dab35d
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..cce2069
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+venv/
+downloads/
+__pycache__/
+*.pyc
+assets/*.mov
+.DS_Store
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..b78d47a
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,14 @@
+FROM python:3.12-slim
+
+RUN apt-get update && \
+ apt-get install -y --no-install-recommends ffmpeg && \
+ rm -rf /var/lib/apt/lists/*
+
+WORKDIR /app
+COPY requirements.txt .
+RUN pip install --no-cache-dir -r requirements.txt
+
+COPY . .
+
+EXPOSE 8899
+CMD ["python", "app.py"]
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..14fac91
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2026
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..cd85933
--- /dev/null
+++ b/README.md
@@ -0,0 +1,66 @@
+# ReClip
+
+A self-hosted, open-source video and audio downloader with a clean web UI. Paste links from YouTube, TikTok, Instagram, Twitter/X, and 1000+ other sites — download as MP4 or MP3.
+
+![Python](https://img.shields.io/badge/python-3.8+-blue)
+![License](https://img.shields.io/badge/license-MIT-green)
+
+<video src="assets/preview.mp4" autoplay loop muted playsinline width="600"></video>
+
+<img src="assets/preview-mp3.png" width="600">
+
+## Features
+
+- Download videos from 1000+ supported sites (via [yt-dlp](https://github.com/yt-dlp/yt-dlp))
+- MP4 video or MP3 audio extraction
+- Quality/resolution picker
+- Bulk downloads — paste multiple URLs at once
+- Automatic URL deduplication
+- Clean, responsive UI — no frameworks, no build step
+- Single Python file backend (~150 lines)
+
+## Quick Start
+
+```bash
+brew install yt-dlp ffmpeg # or apt install ffmpeg && pip install yt-dlp
+git clone https://github.com/YOUR_USERNAME/reclip.git
+cd reclip
+bash run.sh
+```
+
+Open **http://localhost:8899**.
+
+Or with Docker:
+
+```bash
+docker build -t reclip . && docker run -p 8899:8899 reclip
+```
+
+## Usage
+
+1. Paste one or more video URLs into the input box
+2. Choose **MP4** (video) or **MP3** (audio)
+3. Click **Fetch** to load video info and thumbnails
+4. Select quality/resolution if available
+5. Click **Download** on individual videos, or **Download All**
+
+## Supported Sites
+
+Anything [yt-dlp supports](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md), including:
+
+YouTube, TikTok, Instagram, Twitter/X, Reddit, Facebook, Vimeo, Twitch, Dailymotion, SoundCloud, Loom, Streamable, Pinterest, Tumblr, Threads, LinkedIn, and many more.
+
+## Stack
+
+- **Backend:** Python + Flask (~150 lines)
+- **Frontend:** Vanilla HTML/CSS/JS (single file, no build step)
+- **Download engine:** [yt-dlp](https://github.com/yt-dlp/yt-dlp) + [ffmpeg](https://ffmpeg.org/)
+- **Dependencies:** 2 (Flask, yt-dlp)
+
+## Disclaimer
+
+This tool is intended for personal use only. Please respect copyright laws and the terms of service of the platforms you download from. The developers are not responsible for any misuse of this tool.
+
+## License
+
+[MIT](LICENSE)
diff --git a/app.py b/app.py
new file mode 100644
index 0000000..1a3dfac
--- /dev/null
+++ b/app.py
@@ -0,0 +1,170 @@
+import os
+import uuid
+import glob
+import json
+import subprocess
+import threading
+from flask import Flask, request, jsonify, send_file, render_template
+
+app = Flask(__name__)
+DOWNLOAD_DIR = os.path.join(os.path.dirname(__file__), "downloads")
+os.makedirs(DOWNLOAD_DIR, exist_ok=True)
+
+jobs = {}
+
+
+def run_download(job_id, url, format_choice, format_id):
+ job = jobs[job_id]
+ out_template = os.path.join(DOWNLOAD_DIR, f"{job_id}.%(ext)s")
+
+ cmd = ["yt-dlp", "--no-playlist", "-o", out_template]
+
+ if format_choice == "audio":
+ cmd += ["-x", "--audio-format", "mp3"]
+ elif format_id:
+ cmd += ["-f", f"{format_id}+bestaudio/best", "--merge-output-format", "mp4"]
+ else:
+ cmd += ["-f", "bestvideo+bestaudio/best", "--merge-output-format", "mp4"]
+
+ cmd.append(url)
+
+ try:
+ result = subprocess.run(cmd, capture_output=True, text=True, timeout=300)
+ if result.returncode != 0:
+ job["status"] = "error"
+ job["error"] = result.stderr.strip().split("\n")[-1]
+ return
+
+ files = glob.glob(os.path.join(DOWNLOAD_DIR, f"{job_id}.*"))
+ if not files:
+ job["status"] = "error"
+ job["error"] = "Download completed but no file was found"
+ return
+
+ if format_choice == "audio":
+ target = [f for f in files if f.endswith(".mp3")]
+ chosen = target[0] if target else files[0]
+ else:
+ target = [f for f in files if f.endswith(".mp4")]
+ chosen = target[0] if target else files[0]
+
+ for f in files:
+ if f != chosen:
+ try:
+ os.remove(f)
+ except OSError:
+ pass
+
+ job["status"] = "done"
+ job["file"] = chosen
+ ext = os.path.splitext(chosen)[1]
+ title = job.get("title", "").strip()
+ # Sanitize title for filename
+ if title:
+ safe_title = "".join(c for c in title if c not in r'\/:*?"<>|').strip()
+ job["filename"] = f"{safe_title}{ext}" if safe_title else os.path.basename(chosen)
+ else:
+ job["filename"] = os.path.basename(chosen)
+ except subprocess.TimeoutExpired:
+ job["status"] = "error"
+ job["error"] = "Download timed out (5 min limit)"
+ except Exception as e:
+ job["status"] = "error"
+ job["error"] = str(e)
+
+
+def index():
+ return render_template("index.html")
+
+
[email protected]("/api/info", methods=["POST"])
+def get_info():
+ data = request.json
+ url = data.get("url", "").strip()
+ if not url:
+ return jsonify({"error": "No URL provided"}), 400
+
+ cmd = ["yt-dlp", "--no-playlist", "-j", url]
+ try:
+ result = subprocess.run(cmd, capture_output=True, text=True, timeout=60)
+ if result.returncode != 0:
+ return jsonify({"error": result.stderr.strip().split("\n")[-1]}), 400
+
+ info = json.loads(result.stdout)
+
+ # Build quality options — keep best format per resolution
+ best_by_height = {}
+ for f in info.get("formats", []):
+ height = f.get("height")
+ if height and f.get("vcodec", "none") != "none":
+ tbr = f.get("tbr") or 0
+ if height not in best_by_height or tbr > (best_by_height[height].get("tbr") or 0):
+ best_by_height[height] = f
+
+ formats = []
+ for height, f in best_by_height.items():
+ formats.append({
+ "id": f["format_id"],
+ "label": f"{height}p",
+ "height": height,
+ })
+ formats.sort(key=lambda x: x["height"], reverse=True)
+
+ return jsonify({
+ "title": info.get("title", ""),
+ "thumbnail": info.get("thumbnail", ""),
+ "duration": info.get("duration"),
+ "uploader": info.get("uploader", ""),
+ "formats": formats,
+ })
+ except subprocess.TimeoutExpired:
+ return jsonify({"error": "Timed out fetching video info"}), 400
+ except Exception as e:
+ return jsonify({"error": str(e)}), 400
+
+
[email protected]("/api/download", methods=["POST"])
+def start_download():
+ data = request.json
+ url = data.get("url", "").strip()
+ format_choice = data.get("format", "video")
+ format_id = data.get("format_id")
+ title = data.get("title", "")
+
+ if not url:
+ return jsonify({"error": "No URL provided"}), 400
+
+ job_id = uuid.uuid4().hex[:10]
+ jobs[job_id] = {"status": "downloading", "url": url, "title": title}
+
+ thread = threading.Thread(target=run_download, args=(job_id, url, format_choice, format_id))
+ thread.daemon = True
+ thread.start()
+
+ return jsonify({"job_id": job_id})
+
+
[email protected]("/api/status/<job_id>")
+def check_status(job_id):
+ job = jobs.get(job_id)
+ if not job:
+ return jsonify({"error": "Job not found"}), 404
+ return jsonify({
+ "status": job["status"],
+ "error": job.get("error"),
+ "filename": job.get("filename"),
+ })
+
+
[email protected]("/api/file/<job_id>")
+def download_file(job_id):
+ job = jobs.get(job_id)
+ if not job or job["status"] != "done":
+ return jsonify({"error": "File not ready"}), 404
+ return send_file(job["file"], as_attachment=True, download_name=job["filename"])
+
+
+if __name__ == "__main__":
+ port = int(os.environ.get("PORT", 8899))
+ app.run(host="0.0.0.0", port=port)
diff --git a/assets/preview-mp3.png b/assets/preview-mp3.png
new file mode 100644
index 0000000..fbe2a65
Binary files /dev/null and b/assets/preview-mp3.png differ
diff --git a/assets/preview.mp4 b/assets/preview.mp4
new file mode 100644
index 0000000..2f894b8
Binary files /dev/null and b/assets/preview.mp4 differ
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..558431a
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,2 @@
+flask
+yt-dlp
diff --git a/run.sh b/run.sh
new file mode 100755
index 0000000..cd20d50
--- /dev/null
+++ b/run.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+set -e
+cd "$(dirname "$0")"
+
+# Check prerequisites
+missing=""
+
+if ! command -v python3 &> /dev/null; then
+ missing="$missing python3"
+fi
+
+if ! command -v yt-dlp &> /dev/null; then
+ missing="$missing yt-dlp"
+fi
+
+if ! command -v ffmpeg &> /dev/null; then
+ missing="$missing ffmpeg"
+fi
+
+if [ -n "$missing" ]; then
+ echo "Missing required tools:$missing"
+ echo ""
+ if command -v brew &> /dev/null; then
+ echo "Install with: brew install$missing"
+ elif command -v apt &> /dev/null; then
+ echo "Install with: sudo apt install$missing"
+ else
+ echo "Please install:$missing"
+ fi
+ exit 1
+fi
+
+# Set up venv and install Python deps
+if [ ! -d "venv" ]; then
+ echo "Setting up virtual environment..."
+ python3 -m venv venv
+ source venv/bin/activate
+ pip install -q flask yt-dlp
+else
+ source venv/bin/activate
+fi
+
+PORT="${PORT:-8899}"
+export PORT
+
+echo ""
+echo " ReClip is running at http://localhost:$PORT"
+echo ""
+python3 app.py
diff --git a/static/favicon.svg b/static/favicon.svg
new file mode 100644
index 0000000..32dcc50
--- /dev/null
+++ b/static/favicon.svg
@@ -0,0 +1,4 @@
+<svg width="128" height="128" viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg">
+ <circle cx="64" cy="64" r="53.336" fill="#e85d2a"/>
+ <path d="m53.008 49.051 26.996 14.949-26.996 14.949z" fill="#fff"/>
+</svg>
diff --git a/templates/index.html b/templates/index.html
new file mode 100644
index 0000000..5952a2d
--- /dev/null
+++ b/templates/index.html
@@ -0,0 +1,689 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>ReClip — Free Media Downloader</title>
+ <link rel="icon" href="/static/favicon.svg" type="image/svg+xml">
+ <link rel="preconnect" href="https://fonts.googleapis.com">
+ <link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=DM+Mono:wght@400;500&display=swap" rel="stylesheet">
+ <style>
+ :root {
+ --bg: #f4f1eb;
+ --fg: #3a3a38;
+ --accent: #e85d2a;
+ --accent-hover: #d04e1f;
+ --muted: #9c9889;
+ --card: #fff;
+ --card-border: #e2ded6;
+ --success: #2d8a4e;
+ --error: #c43d3d;
+ --radius: 14px;
+ --shimmer: linear-gradient(90deg, #ebe8e2 25%, #f0ede7 50%, #ebe8e2 75%);
+ }
+
+ * { margin: 0; padding: 0; box-sizing: border-box; }
+
+ body {
+ font-family: 'DM Mono', monospace;
+ background: var(--bg);
+ color: var(--fg);
+ min-height: 100vh;
+ overflow-x: hidden;
+ }
+
+ body::after {
+ content: '';
+ position: fixed;
+ inset: 0;
+ opacity: 0.03;
+ pointer-events: none;
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
+ background-size: 128px;
+ }
+
+ .page {
+ max-width: 620px;
+ margin: 0 auto;
+ padding: 60px 24px 80px;
+ }
+
+ .brand { margin-bottom: 48px; }
+ .brand h1 {
+ font-family: 'Instrument Serif', serif;
+ font-size: 4.2rem;
+ font-weight: 400;
+ letter-spacing: -0.03em;
+ line-height: 1;
+ color: var(--fg);
+ }
+ .brand h1 em { font-style: italic; color: var(--accent); }
+ .brand p {
+ margin-top: 10px;
+ font-size: 0.78rem;
+ color: var(--muted);
+ letter-spacing: 0.04em;
+ text-transform: uppercase;
+ }
+
+ textarea {
+ width: 100%;
+ padding: 18px 20px;
+ border: 1.5px solid var(--card-border);
+ border-radius: var(--radius);
+ background: var(--card);
+ color: var(--fg);
+ font-family: 'DM Mono', monospace;
+ font-size: 0.88rem;
+ outline: none;
+ resize: none;
+ min-height: 56px;
+ transition: border-color 0.25s, box-shadow 0.25s;
+ margin-bottom: 6px;
+ }
+ textarea:focus {
+ border-color: var(--accent);
+ box-shadow: 0 0 0 3px rgba(232, 93, 42, 0.08);
+ }
+ textarea::placeholder { color: var(--muted); }
+
+ .hint {
+ font-size: 0.7rem;
+ color: var(--muted);
+ margin-bottom: 20px;
+ letter-spacing: 0.02em;
+ }
+
+ .controls {
+ display: flex;
+ gap: 10px;
+ margin-bottom: 6px;
+ align-items: center;
+ }
+ .pill-group {
+ display: flex;
+ border: 1.5px solid var(--card-border);
+ border-radius: 10px;
+ overflow: hidden;
+ background: var(--card);
+ }
+ .pill {
+ padding: 9px 18px;
+ font-family: 'DM Mono', monospace;
+ font-size: 0.76rem;
+ border: none;
+ background: transparent;
+ color: var(--muted);
+ cursor: pointer;
+ transition: all 0.2s;
+ letter-spacing: 0.03em;
+ text-transform: uppercase;
+ }
+ .pill.active { background: var(--fg); color: var(--bg); }
+ .pill:not(.active):hover { color: var(--fg); }
+
+ .fetch-btn {
+ flex: 1;
+ padding: 10px 20px;
+ border: none;
+ border-radius: 10px;
+ background: var(--accent);
+ color: #fff;
+ font-family: 'DM Mono', monospace;
+ font-size: 0.82rem;
+ font-weight: 500;
+ cursor: pointer;
+ transition: background 0.2s, transform 0.1s;
+ letter-spacing: 0.04em;
+ text-transform: uppercase;
+ }
+ .fetch-btn:hover { background: var(--accent-hover); }
+ .fetch-btn:active { transform: scale(0.98); }
+ .fetch-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
+
+ /* Cards */
+ .cards { margin-top: 24px; }
+
+ .card {
+ display: flex;
+ gap: 14px;
+ border: 1.5px solid var(--card-border);
+ border-radius: var(--radius);
+ background: var(--card);
+ padding: 14px;
+ margin-bottom: 10px;
+ animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
+ }
+ @keyframes slideUp {
+ from { opacity: 0; transform: translateY(12px); }
+ to { opacity: 1; transform: translateY(0); }
+ }
+
+ .card-thumb {
+ width: 120px;
+ min-width: 120px;
+ height: 80px;
+ border-radius: 8px;
+ overflow: hidden;
+ background: var(--card-border);
+ flex-shrink: 0;
+ position: relative;
+ }
+ .card-thumb img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ display: block;
+ }
+ /* No-thumbnail icon */
+ .card-thumb .no-thumb {
+ width: 100%;
+ height: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ color: var(--muted);
+ }
+ .card-thumb .no-thumb svg {
+ width: 28px;
+ height: 28px;
+ opacity: 0.5;
+ }
+
+ /* Shimmer skeleton for loading state */
+ .card-thumb.loading {
+ background: var(--shimmer);
+ background-size: 200% 100%;
+ animation: shimmer 1.5s infinite;
+ }
+ .skeleton-line {
+ height: 12px;
+ border-radius: 4px;
+ background: var(--shimmer);
+ background-size: 200% 100%;
+ animation: shimmer 1.5s infinite;
+ margin-bottom: 6px;
+ }
+ .skeleton-line.short { width: 40%; height: 10px; }
+ .skeleton-line.medium { width: 75%; }
+ @keyframes shimmer {
+ 0% { background-position: 200% 0; }
+ 100% { background-position: -200% 0; }
+ }
+
+ .card-body {
+ flex: 1;
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ }
+ .card-title {
+ font-family: 'Instrument Serif', serif;
+ font-size: 1rem;
+ line-height: 1.3;
+ color: var(--fg);
+ margin-bottom: 2px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+ .card-meta {
+ font-size: 0.68rem;
+ color: var(--muted);
+ letter-spacing: 0.03em;
+ text-transform: uppercase;
+ margin-bottom: 8px;
+ }
+
+ .card-actions {
+ display: flex;
+ gap: 6px;
+ align-items: center;
+ flex-wrap: wrap;
+ }
+
+ .card-dl-btn {
+ padding: 6px 14px;
+ border: none;
+ border-radius: 7px;
+ background: var(--fg);
+ color: var(--bg);
+ font-family: 'DM Mono', monospace;
+ font-size: 0.7rem;
+ font-weight: 500;
+ cursor: pointer;
+ transition: all 0.2s;
+ letter-spacing: 0.03em;
+ text-transform: uppercase;
+ }
+ .card-dl-btn:hover { background: #2d2d2a; }
+ .card-dl-btn:disabled { opacity: 0.4; cursor: not-allowed; }
+ .card-dl-btn.done { background: var(--success); color: #fff; }
+ .card-dl-btn.error { background: var(--error); color: #fff; }
+
+ .card-status {
+ font-size: 0.68rem;
+ color: var(--muted);
+ }
+ .card-status.downloading { color: var(--accent); }
+ .card-status.done { color: var(--success); }
+ .card-status.error { color: var(--error); }
+
+ .q-chip {
+ padding: 4px 10px;
+ border: 1.5px solid var(--card-border);
+ border-radius: 6px;
+ background: transparent;
+ color: var(--muted);
+ font-family: 'DM Mono', monospace;
+ font-size: 0.65rem;
+ cursor: pointer;
+ transition: all 0.2s;
+ }
+ .q-chip.active {
+ border-color: var(--fg);
+ color: var(--fg);
+ background: rgba(26,26,24,0.04);
+ }
+ .q-chip:hover:not(.active) { border-color: var(--muted); }
+
+ /* Error card */
+ .card.card-error {
+ border-color: rgba(196, 61, 61, 0.2);
+ background: rgba(196, 61, 61, 0.03);
+ }
+ .card-error-icon {
+ width: 100%;
+ height: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: rgba(196, 61, 61, 0.08);
+ color: var(--error);
+ }
+ .card-error-icon svg {
+ width: 24px;
+ height: 24px;
+ }
+ .card-error-msg {
+ font-size: 0.72rem;
+ color: var(--error);
+ margin-top: 2px;
+ line-height: 1.4;
+ }
+ .card-error-url {
+ font-size: 0.65rem;
+ color: var(--muted);
+ word-break: break-all;
+ margin-top: 4px;
+ }
+
+ /* Download all bar */
+ .dl-all-bar {
+ display: flex;
+ gap: 10px;
+ margin-top: 16px;
+ }
+ .dl-all-btn {
+ flex: 1;
+ padding: 12px;
+ border: none;
+ border-radius: 10px;
+ background: var(--fg);
+ color: var(--bg);
+ font-family: 'DM Mono', monospace;
+ font-size: 0.82rem;
+ font-weight: 500;
+ cursor: pointer;
+ transition: all 0.2s;
+ letter-spacing: 0.04em;
+ text-transform: uppercase;
+ }
+ .dl-all-btn:hover { background: #2d2d2a; }
+ .dl-all-btn:disabled { opacity: 0.4; cursor: not-allowed; }
+
+ .spin {
+ display: inline-block;
+ width: 10px; height: 10px;
+ border: 2px solid currentColor;
+ border-right-color: transparent;
+ border-radius: 50%;
+ animation: spin 0.6s linear infinite;
+ vertical-align: middle;
+ }
+ @keyframes spin { to { transform: rotate(360deg); } }
+
+ .footer {
+ margin-top: 48px;
+ text-align: center;
+ font-size: 0.68rem;
+ color: var(--muted);
+ letter-spacing: 0.05em;
+ text-transform: uppercase;
+ line-height: 1.8;
+ }
+
+ /* Mobile */
+ @media (max-width: 500px) {
+ .brand h1 { font-size: 3rem; }
+ .page { padding: 40px 16px 60px; }
+ .card { flex-direction: column; gap: 10px; }
+ .card-thumb {
+ width: 100%;
+ min-width: unset;
+ height: 160px;
+ }
+ .card-title { white-space: normal; }
+ .controls { flex-wrap: wrap; }
+ .fetch-btn { width: 100%; }
+ }
+ </style>
+</head>
+<body>
+ <div class="page">
+ <div class="brand">
+ <h1>Re<em>Clip</em></h1>
+ <p>Free media downloader</p>
+ </div>
+
+ <textarea id="urls" placeholder="Paste one or more URLs..." rows="2"></textarea>
+ <p class="hint">Multiple links? Separate with spaces, commas, or newlines.</p>
+
+ <div class="controls">
+ <div class="pill-group">
+ <button class="pill active" data-format="video" onclick="setFormat(this)">MP4</button>
+ <button class="pill" data-format="audio" onclick="setFormat(this)">MP3</button>
+ </div>
+ <button class="fetch-btn" id="goBtn" onclick="go()">Fetch</button>
+ </div>
+
+ <div id="cards" class="cards"></div>
+
+ <div class="footer">
+ YouTube &middot; TikTok &middot; Instagram &middot; Twitter/X &middot; Reddit &middot; Facebook<br>
+ Vimeo &middot; Twitch &middot; Dailymotion &middot; SoundCloud &middot; Loom &middot; Streamable<br>
+ Pinterest &middot; Tumblr &middot; Threads &middot; LinkedIn &middot; 1000+ more
+ </div>
+ </div>
+
+ <script>
+ let currentFormat = 'video';
+ let cardData = [];
+
+ function setFormat(btn) {
+ document.querySelectorAll('.pill').forEach(b => b.classList.remove('active'));
+ btn.classList.add('active');
+ currentFormat = btn.dataset.format;
+ }
+
+ function parseUrls(text) {
+ return [...new Set(text.split(/[\s,]+/).map(u => u.trim()).filter(u => u.startsWith('http')))];
+ }
+
+ function fmtDur(s) {
+ if (!s) return '';
+ const m = Math.floor(s / 60);
+ const sec = Math.floor(s % 60);
+ return `${m}:${sec.toString().padStart(2, '0')}`;
+ }
+
+ function esc(s) {
+ const d = document.createElement('div');
+ d.textContent = s;
+ return d.innerHTML;
+ }
+
+ function friendlyError(err) {
+ if (err.includes('Unsupported URL')) return 'This URL is not supported';
+ if (err.includes('Video unavailable')) return 'Video is unavailable or private';
+ if (err.includes('Private video')) return 'This video is private';
+ if (err.includes('HTTP Error 403')) return 'Access denied by the platform';
+ if (err.includes('HTTP Error 404')) return 'Video not found';
+ if (err.includes('copyright')) return 'Video blocked due to copyright';
+ if (err.includes('geo')) return 'Video not available in your region';
+ if (err.includes('timed out') || err.includes('Timed out')) return 'Request timed out — try again';
+ if (err.includes('network') || err.includes('Network')) return 'Network error — check your connection';
+ return err.length > 80 ? err.slice(0, 80) + '...' : err;
+ }
+
+ document.getElementById('urls').addEventListener('keydown', e => {
+ if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); go(); }
+ });
+
+ async function go() {
+ const urls = parseUrls(document.getElementById('urls').value);
+ if (!urls.length) return;
+
+ const btn = document.getElementById('goBtn');
+ const container = document.getElementById('cards');
+ btn.disabled = true;
+ btn.textContent = 'Loading...';
+ container.innerHTML = '';
+ cardData = [];
+
+ for (let i = 0; i < urls.length; i++) {
+ const url = urls[i];
+ const idx = cardData.length;
+ cardData.push({ url, status: 'loading' });
+ renderCard(idx);
+
+ try {
+ const res = await fetch('/api/info', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ url }),
+ });
+ const data = await res.json();
+ if (data.error) {
+ cardData[idx] = { ...cardData[idx], status: 'info-error', error: data.error };
+ } else {
+ cardData[idx] = {
+ ...cardData[idx],
+ status: 'ready',
+ title: data.title || '',
+ thumbnail: data.thumbnail || '',
+ duration: data.duration,
+ uploader: data.uploader || '',
+ formats: data.formats || [],
+ selectedFormatId: data.formats?.[0]?.id || null,
+ };
+ }
+ } catch (err) {
+ cardData[idx] = { ...cardData[idx], status: 'info-error', error: err.message };
+ }
+ renderCard(idx);
+ }
+
+ if (cardData.filter(c => c.status === 'ready').length > 1) {
+ renderDownloadAll();
+ }
+
+ btn.disabled = false;
+ btn.textContent = 'Fetch';
+ }
+
+ function renderCard(idx) {
+ const c = cardData[idx];
+ let el = document.getElementById(`card-${idx}`);
+ if (!el) {
+ el = document.createElement('div');
+ el.id = `card-${idx}`;
+ el.className = 'card';
+ document.getElementById('cards').appendChild(el);
+ }
+
+ // Loading skeleton
+ if (c.status === 'loading') {
+ el.className = 'card';
+ el.innerHTML = `
+ <div class="card-thumb loading"></div>
+ <div class="card-body">
+ <div class="skeleton-line medium"></div>
+ <div class="skeleton-line short"></div>
+ </div>
+ `;
+ return;
+ }
+
+ // Error state
+ if (c.status === 'info-error') {
+ el.className = 'card card-error';
+ el.innerHTML = `
+ <div class="card-thumb">
+ <div class="card-error-icon">
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>
+ </div>
+ </div>
+ <div class="card-body">
+ <div class="card-title" style="color:var(--error)">Could not fetch video</div>
+ <div class="card-error-msg">${esc(friendlyError(c.error || ''))}</div>
+ <div class="card-error-url">${esc(c.url)}</div>
+ </div>
+ `;
+ return;
+ }
+
+ // Ready / downloading / done / error states
+ el.className = 'card';
+ const isAudio = currentFormat === 'audio';
+
+ let thumbHtml;
+ if (isAudio) {
+ thumbHtml = `<div class="no-thumb" style="color:var(--accent)"><svg viewBox="0 0 24 24" fill="currentColor" stroke="none"><polygon points="5 3 19 12 5 21 5 3"/></svg></div>`;
+ } else if (c.thumbnail) {
+ thumbHtml = `<img src="${c.thumbnail}" alt="">`;
+ } else {
+ thumbHtml = `<div class="no-thumb"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="2" width="20" height="20" rx="2"/><circle cx="8" cy="8" r="1.5"/><path d="m21 15-5-5L5 21"/></svg></div>`;
+ }
+
+ let qualityChips = '';
+ if (!isAudio && c.formats && c.formats.length > 1) {
+ qualityChips = c.formats.map(f =>
+ `<button class="q-chip${f.id === c.selectedFormatId ? ' active' : ''}" onclick="pickFormat(${idx}, '${f.id}')">${f.label}</button>`
+ ).join('');
+ }
+
+ let actionHtml = '';
+ if (c.status === 'ready') {
+ actionHtml = `<button class="card-dl-btn" onclick="dlCard(${idx})">Download</button>${qualityChips}`;
+ } else if (c.status === 'downloading') {
+ actionHtml = `<span class="card-status downloading"><span class="spin"></span> Downloading...</span>`;
+ } else if (c.status === 'done') {
+ actionHtml = `<button class="card-dl-btn done" onclick="saveCard(${idx})">Save</button>
+ <span class="card-status done">${esc(c.filename || '')}</span>`;
+ } else if (c.status === 'error') {
+ actionHtml = `<button class="card-dl-btn" onclick="dlCard(${idx})">Retry</button>
+ <span class="card-status error">${esc(friendlyError(c.error || 'Download failed'))}</span>`;
+ }
+
+ el.innerHTML = `
+ <div class="card-thumb">${thumbHtml}</div>
+ <div class="card-body">
+ <div class="card-title">${esc(c.title || 'Untitled')}</div>
+ <div class="card-meta">${esc(c.uploader)}${c.duration ? ' · ' + fmtDur(c.duration) : ''}</div>
+ <div class="card-actions">${actionHtml}</div>
+ </div>
+ `;
+ }
+
+ function renderDownloadAll() {
+ const existing = document.getElementById('dl-all-bar');
+ if (existing) existing.remove();
+
+ const bar = document.createElement('div');
+ bar.id = 'dl-all-bar';
+ bar.className = 'dl-all-bar';
+ bar.innerHTML = `<button class="dl-all-btn" onclick="dlAll()">Download All</button>`;
+ document.getElementById('cards').appendChild(bar);
+ }
+
+ function pickFormat(idx, formatId) {
+ cardData[idx].selectedFormatId = formatId;
+ renderCard(idx);
+ }
+
+ async function dlCard(idx) {
+ const c = cardData[idx];
+ c.status = 'downloading';
+ c.error = null;
+ renderCard(idx);
+
+ try {
+ const res = await fetch('/api/download', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ url: c.url,
+ format: currentFormat,
+ format_id: c.selectedFormatId,
+ title: c.title || '',
+ }),
+ });
+ const data = await res.json();
+ if (data.error) {
+ c.status = 'error';
+ c.error = data.error;
+ renderCard(idx);
+ return;
+ }
+ c.jobId = data.job_id;
+ pollCard(idx);
+ } catch (err) {
+ c.status = 'error';
+ c.error = err.message;
+ renderCard(idx);
+ }
+ }
+
+ function pollCard(idx) {
+ const c = cardData[idx];
+ const iv = setInterval(async () => {
+ try {
+ const res = await fetch(`/api/status/${c.jobId}`);
+ const data = await res.json();
+ if (data.status === 'done') {
+ clearInterval(iv);
+ c.status = 'done';
+ c.filename = data.filename;
+ renderCard(idx);
+ if (cardData.length === 1) saveCard(idx);
+ } else if (data.status === 'error') {
+ clearInterval(iv);
+ c.status = 'error';
+ c.error = data.error;
+ renderCard(idx);
+ }
+ } catch {
+ clearInterval(iv);
+ c.status = 'error';
+ c.error = 'Lost connection to server';
+ renderCard(idx);
+ }
+ }, 1000);
+ }
+
+ function saveCard(idx) {
+ const c = cardData[idx];
+ if (!c.jobId) return;
+ const a = document.createElement('a');
+ a.href = `/api/file/${c.jobId}`;
+ a.download = c.filename || '';
+ a.click();
+ }
+
+ async function dlAll() {
+ const btn = document.querySelector('.dl-all-btn');
+ if (btn) { btn.disabled = true; btn.textContent = 'Downloading...'; }
+
+ for (let i = 0; i < cardData.length; i++) {
+ if (cardData[i].status === 'ready') {
+ await dlCard(i);
+ }
+ }
+
+ if (btn) { btn.disabled = false; btn.textContent = 'Download All'; }
+ }
+ </script>
+</body>
+</html>