Initial: reels clipper app
- FastAPI backend (auth, jobs, SSE, download) - Frontend: drag&drop + YouTube URL + jobs panel - Pipeline: yt_download → find_chorus → reframe → subtitle - Modes: track (face follow), center, blur - Whisper for SI/DE/EN subtitles - Auto-chorus detection via Whisper + RMS energy - Docker + Coolify ready
This commit is contained in:
@@ -0,0 +1,534 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="sl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Reels Clipper · biba.live</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg: #0d0e12;
|
||||
--panel: #1a1c24;
|
||||
--panel-2: #232631;
|
||||
--border: #2d3142;
|
||||
--text: #e6e8ed;
|
||||
--muted: #8a8fa3;
|
||||
--accent: #DC1C4C;
|
||||
--accent-2: #ff3a6e;
|
||||
--success: #3ec98f;
|
||||
--warn: #f0b03b;
|
||||
--error: #ef4444;
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
html, body { margin: 0; padding: 0; }
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
min-height: 100vh;
|
||||
line-height: 1.5;
|
||||
}
|
||||
header {
|
||||
padding: 24px 32px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
header h1 {
|
||||
margin: 0;
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.3px;
|
||||
}
|
||||
.accent-mark {
|
||||
display: inline-block;
|
||||
background: var(--accent);
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
font-weight: 800;
|
||||
color: white;
|
||||
margin-right: 4px;
|
||||
}
|
||||
main {
|
||||
max-width: 1100px;
|
||||
margin: 0 auto;
|
||||
padding: 32px;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 24px;
|
||||
}
|
||||
@media (max-width: 800px) {
|
||||
main { grid-template-columns: 1fr; }
|
||||
}
|
||||
.card {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
}
|
||||
.card h2 {
|
||||
margin: 0 0 16px;
|
||||
font-size: 16px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.6px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.dropzone {
|
||||
border: 2px dashed var(--border);
|
||||
border-radius: 10px;
|
||||
padding: 40px 20px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
.dropzone:hover, .dropzone.drag {
|
||||
border-color: var(--accent);
|
||||
background: rgba(220, 28, 76, 0.05);
|
||||
}
|
||||
.dropzone svg { width: 48px; height: 48px; opacity: 0.5; margin-bottom: 8px; }
|
||||
.dropzone .small { color: var(--muted); font-size: 13px; }
|
||||
input[type="text"], input[type="url"], select, input[type="number"] {
|
||||
width: 100%;
|
||||
background: var(--panel-2);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
color: var(--text);
|
||||
font-size: 14px;
|
||||
font-family: inherit;
|
||||
}
|
||||
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
|
||||
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; margin-top: 12px; }
|
||||
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
|
||||
button {
|
||||
background: var(--accent);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 11px 20px;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
button:hover { background: var(--accent-2); }
|
||||
button:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
|
||||
button.ghost:hover { background: var(--panel-2); color: var(--text); }
|
||||
button.small { padding: 6px 12px; font-size: 12px; }
|
||||
.full-width { grid-column: 1 / -1; }
|
||||
.jobs-list { display: flex; flex-direction: column; gap: 10px; }
|
||||
.job {
|
||||
background: var(--panel-2);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
padding: 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.job-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
|
||||
.job-title { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.badge { padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 600; }
|
||||
.badge.queued { background: rgba(138, 143, 163, 0.15); color: var(--muted); }
|
||||
.badge.processing, .badge.downloading { background: rgba(240, 176, 59, 0.15); color: var(--warn); }
|
||||
.badge.done { background: rgba(62, 201, 143, 0.15); color: var(--success); }
|
||||
.badge.failed { background: rgba(239, 68, 68, 0.15); color: var(--error); }
|
||||
.badge.uploaded { background: rgba(220, 28, 76, 0.15); color: var(--accent); }
|
||||
.progress { height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; }
|
||||
.progress-bar { height: 100%; background: var(--accent); width: 0%; transition: width 0.3s; }
|
||||
.progress-bar.indeterminate {
|
||||
width: 30%;
|
||||
animation: shimmer 1.5s linear infinite;
|
||||
}
|
||||
@keyframes shimmer {
|
||||
0% { margin-left: -30%; }
|
||||
100% { margin-left: 100%; }
|
||||
}
|
||||
.step { font-size: 12px; color: var(--muted); }
|
||||
.meta { font-size: 11px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
|
||||
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
|
||||
.error-text { color: var(--error); font-size: 12px; }
|
||||
video { width: 100%; max-height: 400px; border-radius: 8px; background: black; }
|
||||
.empty { color: var(--muted); text-align: center; padding: 40px 20px; font-size: 14px; }
|
||||
.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
|
||||
.toggle input { width: auto; }
|
||||
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
|
||||
.tab { padding: 10px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-size: 14px; }
|
||||
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
|
||||
.hidden { display: none !important; }
|
||||
code { background: var(--panel-2); padding: 1px 6px; border-radius: 3px; font-family: ui-monospace, monospace; font-size: 12px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1><span class="accent-mark">1]</span> reels clipper</h1>
|
||||
<span style="color: var(--muted); font-size: 13px;">biba.live</span>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<!-- ─── INPUT ───────────────────────────────────── -->
|
||||
<section class="card">
|
||||
<h2>nov reel</h2>
|
||||
|
||||
<div class="tabs">
|
||||
<div class="tab active" data-tab="upload">Upload</div>
|
||||
<div class="tab" data-tab="youtube">YouTube</div>
|
||||
</div>
|
||||
|
||||
<div id="tab-upload">
|
||||
<div class="dropzone" id="dropzone">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
|
||||
<polyline points="17 8 12 3 7 8"/>
|
||||
<line x1="12" y1="3" x2="12" y2="15"/>
|
||||
</svg>
|
||||
<div>Klikni ali povleci video sem</div>
|
||||
<div class="small">.mp4, .mov, .webm — do 2 GB</div>
|
||||
<input type="file" id="file-input" accept="video/*" style="display:none">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="tab-youtube" class="hidden">
|
||||
<label>YouTube URL</label>
|
||||
<input type="url" id="yt-url" placeholder="https://www.youtube.com/watch?v=...">
|
||||
</div>
|
||||
|
||||
<label>Način reframe</label>
|
||||
<select id="mode">
|
||||
<option value="track">Track (sledi obrazu — intervjuji, vlogi)</option>
|
||||
<option value="center">Center (statična kamera)</option>
|
||||
<option value="blur">Blur (glasba, koncerti)</option>
|
||||
</select>
|
||||
|
||||
<div class="row">
|
||||
<div>
|
||||
<label>Jezik podnapisov</label>
|
||||
<select id="lang">
|
||||
<option value="">Auto detect</option>
|
||||
<option value="sl">Slovenščina</option>
|
||||
<option value="de">Deutsch</option>
|
||||
<option value="en">English</option>
|
||||
<option value="hr">Hrvatski</option>
|
||||
<option value="sr">Српски</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label>Whisper model</label>
|
||||
<select id="model">
|
||||
<option value="tiny">tiny (najhitrejši)</option>
|
||||
<option value="base">base</option>
|
||||
<option value="small" selected>small (priporočeno)</option>
|
||||
<option value="medium">medium (zelo dobro)</option>
|
||||
<option value="large-v3">large-v3 (najboljše)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="toggle" style="margin-top: 16px;">
|
||||
<input type="checkbox" id="auto-chorus" checked>
|
||||
Avto-detekcija refrena (priporočeno za glasbo)
|
||||
</label>
|
||||
|
||||
<div id="manual-times" class="row hidden">
|
||||
<div>
|
||||
<label>Začetek (sekunde ali mm:ss)</label>
|
||||
<input type="text" id="start" placeholder="npr. 1:24">
|
||||
</div>
|
||||
<div>
|
||||
<label>Trajanje (s)</label>
|
||||
<input type="number" id="duration" value="30" min="5" max="180">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div>
|
||||
<label>Stil podnapisov</label>
|
||||
<select id="subtitle-style">
|
||||
<option value="reels">Reels (TikTok beli)</option>
|
||||
<option value="yellow">Yellow (MrBeast)</option>
|
||||
<option value="minimal">Minimal</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label>Kvaliteta</label>
|
||||
<select id="quality">
|
||||
<option value="fast">Fast (preview)</option>
|
||||
<option value="medium" selected>Medium (objava)</option>
|
||||
<option value="high">High (arhiv)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="toggle" style="margin-top: 12px;">
|
||||
<input type="checkbox" id="no-subs">
|
||||
Brez podnapisov
|
||||
</label>
|
||||
|
||||
<button id="submit-btn" class="full-width" style="margin-top: 20px; width: 100%;">
|
||||
Naredi reel
|
||||
</button>
|
||||
|
||||
<div id="upload-progress" class="hidden" style="margin-top: 12px;">
|
||||
<div class="step" id="upload-status">Nalaganje...</div>
|
||||
<div class="progress"><div class="progress-bar" id="upload-bar"></div></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- ─── JOBS ────────────────────────────────────── -->
|
||||
<section class="card">
|
||||
<h2>moji reels</h2>
|
||||
<div class="jobs-list" id="jobs-list">
|
||||
<div class="empty">Še ni obdelav</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
const $ = (s) => document.querySelector(s);
|
||||
const $$ = (s) => document.querySelectorAll(s);
|
||||
|
||||
// ─── Tabs ───────────────────────────────────────
|
||||
$$(".tab").forEach(t => {
|
||||
t.addEventListener("click", () => {
|
||||
$$(".tab").forEach(x => x.classList.remove("active"));
|
||||
t.classList.add("active");
|
||||
const target = t.dataset.tab;
|
||||
$("#tab-upload").classList.toggle("hidden", target !== "upload");
|
||||
$("#tab-youtube").classList.toggle("hidden", target !== "youtube");
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Auto-chorus toggle ─────────────────────────
|
||||
$("#auto-chorus").addEventListener("change", e => {
|
||||
$("#manual-times").classList.toggle("hidden", e.target.checked);
|
||||
});
|
||||
|
||||
// ─── Drag & drop ────────────────────────────────
|
||||
const dz = $("#dropzone");
|
||||
const fileInput = $("#file-input");
|
||||
let pendingFile = null;
|
||||
dz.addEventListener("click", () => fileInput.click());
|
||||
fileInput.addEventListener("change", () => {
|
||||
if (fileInput.files[0]) {
|
||||
pendingFile = fileInput.files[0];
|
||||
dz.querySelector("div").textContent = `📹 ${pendingFile.name}`;
|
||||
}
|
||||
});
|
||||
["dragover", "dragenter"].forEach(ev =>
|
||||
dz.addEventListener(ev, e => { e.preventDefault(); dz.classList.add("drag"); }));
|
||||
["dragleave", "drop"].forEach(ev =>
|
||||
dz.addEventListener(ev, e => { e.preventDefault(); dz.classList.remove("drag"); }));
|
||||
dz.addEventListener("drop", e => {
|
||||
const f = e.dataTransfer.files[0];
|
||||
if (f) {
|
||||
pendingFile = f;
|
||||
dz.querySelector("div").textContent = `📹 ${f.name}`;
|
||||
}
|
||||
});
|
||||
|
||||
// ─── Settings collector ─────────────────────────
|
||||
function collectSettings() {
|
||||
return {
|
||||
mode: $("#mode").value,
|
||||
lang: $("#lang").value || null,
|
||||
whisper_model: $("#model").value,
|
||||
auto_chorus: $("#auto-chorus").checked,
|
||||
start: !$("#auto-chorus").checked && $("#start").value ? parseTimestamp($("#start").value) : null,
|
||||
duration: parseFloat($("#duration").value) || 30,
|
||||
subtitle_style: $("#subtitle-style").value,
|
||||
quality: $("#quality").value,
|
||||
no_subs: $("#no-subs").checked,
|
||||
};
|
||||
}
|
||||
|
||||
function parseTimestamp(s) {
|
||||
s = s.trim();
|
||||
if (s.includes(":")) {
|
||||
const parts = s.split(":").map(parseFloat);
|
||||
if (parts.length === 2) return parts[0] * 60 + parts[1];
|
||||
if (parts.length === 3) return parts[0] * 3600 + parts[1] * 60 + parts[2];
|
||||
}
|
||||
return parseFloat(s);
|
||||
}
|
||||
|
||||
// ─── Submit ─────────────────────────────────────
|
||||
$("#submit-btn").addEventListener("click", async () => {
|
||||
const isYT = $("#tab-youtube").classList.contains("hidden") === false;
|
||||
const settings = collectSettings();
|
||||
|
||||
$("#submit-btn").disabled = true;
|
||||
$("#upload-progress").classList.remove("hidden");
|
||||
|
||||
try {
|
||||
if (isYT) {
|
||||
const url = $("#yt-url").value.trim();
|
||||
if (!url) { alert("Vpiši YouTube URL"); return; }
|
||||
$("#upload-status").textContent = "Pošiljam YouTube job...";
|
||||
const r = await fetch("/api/youtube", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ url, ...settings }),
|
||||
});
|
||||
if (!r.ok) throw new Error("YouTube submit napaka");
|
||||
const job = await r.json();
|
||||
watchJob(job.id);
|
||||
refreshJobs();
|
||||
} else {
|
||||
if (!pendingFile) { alert("Izberi datoteko"); return; }
|
||||
const fd = new FormData();
|
||||
fd.append("file", pendingFile);
|
||||
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.upload.onprogress = e => {
|
||||
if (e.lengthComputable) {
|
||||
const pct = (e.loaded / e.total) * 100;
|
||||
$("#upload-bar").style.width = pct + "%";
|
||||
$("#upload-status").textContent = `Nalagam... ${pct.toFixed(0)}%`;
|
||||
}
|
||||
};
|
||||
xhr.onload = async () => {
|
||||
if (xhr.status !== 200) {
|
||||
alert("Upload napaka: " + xhr.responseText);
|
||||
$("#submit-btn").disabled = false;
|
||||
return;
|
||||
}
|
||||
const job = JSON.parse(xhr.responseText);
|
||||
$("#upload-status").textContent = "Naloženo, začenjam obdelavo...";
|
||||
const proc = await fetch("/api/process", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ job_id: job.id, ...settings }),
|
||||
});
|
||||
if (!proc.ok) throw new Error("Process start napaka");
|
||||
watchJob(job.id);
|
||||
refreshJobs();
|
||||
};
|
||||
xhr.open("POST", "/api/upload");
|
||||
xhr.send(fd);
|
||||
}
|
||||
} catch (e) {
|
||||
alert("Napaka: " + e.message);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
$("#upload-progress").classList.add("hidden");
|
||||
$("#submit-btn").disabled = false;
|
||||
pendingFile = null;
|
||||
fileInput.value = "";
|
||||
dz.querySelector("div").textContent = "Klikni ali povleci video sem";
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
|
||||
// ─── Watch job (SSE) ────────────────────────────
|
||||
function watchJob(jobId) {
|
||||
const evt = new EventSource(`/api/stream/${jobId}`);
|
||||
evt.onmessage = (e) => {
|
||||
try {
|
||||
const job = JSON.parse(e.data);
|
||||
updateJobInList(job);
|
||||
if (job.status === "done" || job.status === "failed") {
|
||||
evt.close();
|
||||
refreshJobs();
|
||||
}
|
||||
} catch {}
|
||||
};
|
||||
evt.onerror = () => evt.close();
|
||||
}
|
||||
|
||||
// ─── Jobs list ──────────────────────────────────
|
||||
async function refreshJobs() {
|
||||
const r = await fetch("/api/jobs");
|
||||
if (!r.ok) return;
|
||||
const data = await r.json();
|
||||
const list = $("#jobs-list");
|
||||
if (!data.jobs.length) {
|
||||
list.innerHTML = '<div class="empty">Še ni obdelav</div>';
|
||||
return;
|
||||
}
|
||||
list.innerHTML = "";
|
||||
data.jobs.forEach(j => list.appendChild(buildJobEl(j)));
|
||||
// Watch any in-progress job
|
||||
data.jobs.forEach(j => {
|
||||
if (["queued", "processing", "downloading", "uploaded"].includes(j.status)) {
|
||||
watchJob(j.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateJobInList(job) {
|
||||
const existing = document.getElementById(`job-${job.id}`);
|
||||
const el = buildJobEl(job);
|
||||
if (existing) {
|
||||
existing.replaceWith(el);
|
||||
} else {
|
||||
const list = $("#jobs-list");
|
||||
if (list.querySelector(".empty")) list.innerHTML = "";
|
||||
list.prepend(el);
|
||||
}
|
||||
}
|
||||
|
||||
function buildJobEl(job) {
|
||||
const el = document.createElement("div");
|
||||
el.className = "job";
|
||||
el.id = `job-${job.id}`;
|
||||
|
||||
const title = job.source_type === "youtube"
|
||||
? (job.youtube_url || "YouTube")
|
||||
: (job.filename || job.id);
|
||||
|
||||
const sizeStr = job.output_size_mb ? `${job.output_size_mb} MB` :
|
||||
job.size_mb ? `${job.size_mb} MB` : "";
|
||||
const statusLabel = {
|
||||
queued: "v vrsti", uploaded: "naloženo", processing: "obdeluje",
|
||||
downloading: "prenaša", done: "končano", failed: "napaka",
|
||||
}[job.status] || job.status;
|
||||
|
||||
const isProcessing = ["queued", "processing", "downloading"].includes(job.status);
|
||||
const showBar = isProcessing ? '<div class="progress"><div class="progress-bar indeterminate"></div></div>' : "";
|
||||
|
||||
const actions = [];
|
||||
if (job.status === "done") {
|
||||
actions.push(`<button class="small" onclick="window.open('/api/download/${job.id}')">⬇ Download</button>`);
|
||||
actions.push(`<button class="small ghost" onclick="previewJob('${job.id}')">▶ Preview</button>`);
|
||||
}
|
||||
actions.push(`<button class="small ghost" onclick="deleteJob('${job.id}')">✕</button>`);
|
||||
|
||||
el.innerHTML = `
|
||||
<div class="job-head">
|
||||
<div class="job-title" title="${title}">${title}</div>
|
||||
<span class="badge ${job.status}">${statusLabel}</span>
|
||||
</div>
|
||||
${job.current_step ? `<div class="step">${job.current_step}</div>` : ""}
|
||||
${showBar}
|
||||
${job.error ? `<div class="error-text">⚠ ${job.error}</div>` : ""}
|
||||
<div class="meta">
|
||||
<span>${job.source_type === "youtube" ? "YouTube" : "Upload"}</span>
|
||||
${sizeStr ? `<span>${sizeStr}</span>` : ""}
|
||||
${job.mode ? `<span>${job.mode}</span>` : ""}
|
||||
${job.lang ? `<span>${job.lang}</span>` : ""}
|
||||
</div>
|
||||
<div class="actions">${actions.join("")}</div>
|
||||
${job.status === "done" ? `<video id="video-${job.id}" class="hidden" controls></video>` : ""}
|
||||
`;
|
||||
return el;
|
||||
}
|
||||
|
||||
async function deleteJob(id) {
|
||||
if (!confirm("Izbrišem ta job?")) return;
|
||||
await fetch(`/api/jobs/${id}`, { method: "DELETE" });
|
||||
refreshJobs();
|
||||
}
|
||||
|
||||
function previewJob(id) {
|
||||
const v = document.getElementById(`video-${id}`);
|
||||
v.src = `/api/preview/${id}`;
|
||||
v.classList.remove("hidden");
|
||||
v.play();
|
||||
}
|
||||
|
||||
refreshJobs();
|
||||
setInterval(refreshJobs, 10000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user