iris-queue / index.html
AparnaVelvet's picture
Update index.html
c93f6a1 verified
Raw History Blame Contribute Delete
8.3 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Aparna's Iris Queue</title>
<style>
body { font-family: system-ui, sans-serif; max-width: 740px; margin: 24px auto; padding: 0 16px; background: #160c14; color: #fdf2f8; }
h2 { color: #f472b6; }
label { display: block; margin-top: 14px; font-weight: 600; font-size: 14px; color: #fbcfe8; }
input, textarea { width: 100%; box-sizing: border-box; margin-top: 6px; padding: 10px; border-radius: 8px; border: 1px solid #831843; background: #281322; color: #fdf2f8; font-size: 14px; }
.radios { display: flex; gap: 18px; margin-top: 8px; }
.radios label { display: flex; align-items: center; gap: 6px; margin-top: 0; font-weight: 500; cursor: pointer; }
.radios input { width: auto; margin: 0; accent-color: #ec4899; }
.row { display: flex; gap: 8px; align-items: stretch; margin-top: 6px; }
.row input { margin-top: 0; flex: 1; }
.btn-sec { padding: 10px 14px; border: 1px solid #9d174d; border-radius: 8px; background: #500724; color: #fbcfe8; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn-pri { margin-top: 18px; width: 100%; padding: 12px; border: 0; border-radius: 8px; background: #ec4899; color: #fff; font-weight: 700; font-size: 16px; cursor: pointer; }
button:disabled { opacity: 0.6; cursor: wait; }
#titles_box, #status { margin-top: 10px; padding: 12px; border-radius: 8px; background: #281322; border: 1px solid #831843; white-space: pre-wrap; font-family: monospace; font-size: 13px; max-height: 220px; overflow-y: auto; }
</style>
</head>
<body>
<h2>🩷 Aparna's Iris Queue Helper</h2>
<label>Video Type</label>
<div class="radios">
<label><input type="radio" name="video_type" value="shorts" checked /> shorts</label>
<label><input type="radio" name="video_type" value="longform" /> longform</label>
</div>
<label for="access_key">Access Key</label>
<div class="row">
<input id="access_key" type="password" placeholder="Paste the token here" />
<button id="load_titles_btn" class="btn-sec" type="button">Load Last 30 Titles</button>
</div>
<div id="titles_box">(Click "Load Last 30 Titles" above to view past titles)</div>
<label for="video_title">Video Title</label>
<input id="video_title" type="text" placeholder="Enter catchy clickable YouTube title..." />
<label for="audio_url">Audio URL</label>
<div class="row">
<input id="audio_url" type="url" placeholder="https://..." />
<button id="paste_btn" class="btn-sec" type="button">Paste from Clipboard</button>
</div>
<div id="thumb_wrap">
<label for="thumb_prompt">Thumbnail Prompt (Longform Only)</label>
<textarea id="thumb_prompt" rows="4" placeholder="Detailed descriptive visual prompt with bold hook text (longform only)..."></textarea>
</div>
<label for="transcript">Raw Transcript</label>
<textarea id="transcript" rows="9" placeholder="Paste raw spoken transcript (without [SPOKEN WORD])..."></textarea>
<button id="save_btn" class="btn-pri" type="button">Save Entry</button>
<div id="status">Ready.</div>
<script type="module">
import { downloadFile, uploadFile } from "https://cdn.jsdelivr.net/npm/@huggingface/hub/+esm";
const keyEl = document.getElementById("access_key");
const loadBtn = document.getElementById("load_titles_btn");
const titlesBox = document.getElementById("titles_box");
const titleEl = document.getElementById("video_title");
const urlEl = document.getElementById("audio_url");
const pasteBtn = document.getElementById("paste_btn");
const thumbWrap = document.getElementById("thumb_wrap");
const thumbEl = document.getElementById("thumb_prompt");
const trEl = document.getElementById("transcript");
const btnEl = document.getElementById("save_btn");
const stEl = document.getElementById("status");
const savedFingerprints = new Set();
const savedKey = localStorage.getItem("aparna_fg_key") || "";
if (savedKey) keyEl.value = savedKey;
function getVt() {
return document.querySelector('input[name="video_type"]:checked')?.value || "shorts";
}
function toggleThumb() {
thumbWrap.style.display = getVt() === "longform" ? "block" : "none";
}
document.querySelectorAll('input[name="video_type"]').forEach(r => r.addEventListener("change", toggleThumb));
toggleThumb();
loadBtn.addEventListener("click", async () => {
const token = keyEl.value.trim();
if (!token) { titlesBox.textContent = "ERROR: Enter Access Key first."; return; }
localStorage.setItem("aparna_fg_key", token);
const histPath = getVt() === "longform" ? "history/longform_titles.txt" : "history/shorts_titles.txt";
titlesBox.textContent = "Loading...";
try {
const res = await downloadFile({
repo: { type: "dataset", name: "AparnaVelvet/Storage" },
path: histPath,
accessToken: token,
});
const txt = res ? (await res.text()).trim() : "";
titlesBox.textContent = txt || "(0 titles so far — first run!)";
} catch (err) {
titlesBox.textContent = "ERROR loading titles: " + (err?.message || err);
}
});
pasteBtn.addEventListener("click", async () => {
try {
const txt = (await navigator.clipboard.readText() || "").trim();
if (!txt) { stEl.textContent = "Clipboard is empty."; return; }
urlEl.value = txt;
stEl.textContent = "Pasted URL from clipboard.";
} catch (err) {
stEl.textContent = "Clipboard blocked: " + (err?.message || err);
urlEl.focus();
}
});
btnEl.addEventListener("click", async () => {
const token = keyEl.value.trim();
const vtype = getVt();
const title = titleEl.value.replace(/[\r\n]+/g, " ").trim();
const url = urlEl.value.trim();
const thumbPrompt = vtype === "longform" ? thumbEl.value.replace(/[\r\n]+/g, " ").trim() : "";
let raw = trEl.value.replace(/\[\s*SPOKEN\s+WORD\s*\]/gi, "").replace(/\s+/g, " ").trim();
if (!token) { stEl.textContent = "ERROR: Please enter Access Key."; return; }
if (title.length < 3) { stEl.textContent = "ERROR: Please enter a Video Title."; return; }
if (!/^https?:\/\/\S+$/i.test(url)) { stEl.textContent = "ERROR: Please enter a valid http/https Audio URL."; return; }
if (vtype === "longform" && thumbPrompt.length < 10) {
stEl.textContent = "ERROR: Please enter a detailed Thumbnail Prompt for longform videos.";
return;
}
if (raw.length < 5) { stEl.textContent = "ERROR: Transcript is empty."; return; }
const fpInput = `${vtype}|${url.toLowerCase()}|${raw.toLowerCase()}`;
const buf = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(fpInput));
const fp = Array.from(new Uint8Array(buf)).map(b => b.toString(16).padStart(2, "0")).join("").slice(0, 8);
if (savedFingerprints.has(fp)) {
stEl.textContent = "SKIPPED: Duplicate entry already saved in this session.";
return;
}
localStorage.setItem("aparna_fg_key", token);
btnEl.disabled = true;
stEl.textContent = "Saving...";
try {
const now = new Date();
const p = (n) => String(n).padStart(2, "0");
const dateStr = `${now.getUTCFullYear()}${p(now.getUTCMonth()+1)}${p(now.getUTCDate())}`;
const prefix = vtype === "longform" ? "long" : "short";
const repoPath = `${vtype}/${prefix}_${dateStr}_${fp}.txt`;
const body = `TITLE: ${title}\n\nURL: ${url}\n\nTHUMBNAIL_PROMPT:\n${thumbPrompt}\n\nTRANSCRIPT:\n${raw}\n`;
await uploadFile({
repo: { type: "dataset", name: "AparnaVelvet/Storage" },
accessToken: token,
file: { path: repoPath, content: new Blob([body], { type: "text/plain" }) },
commitTitle: `Queue ${repoPath} via Iris Queue Space`,
});
savedFingerprints.add(fp);
stEl.textContent = `SUCCESS: Saved ${repoPath}`;
} catch (err) {
stEl.textContent = `ERROR: ${err?.message || err}`;
} finally {
btnEl.disabled = false;
}
});
</script>
</body>
</html>