feat/youtube-growth-toolkit #8
2 changed files with 96 additions and 2 deletions
|
|
@ -255,6 +255,9 @@ function App() {
|
|||
const [downloadingAll, setDownloadingAll] = useState(false);
|
||||
// Pre-flight quality gate: { info: {max_height, min_height, cookies_invalid}, data }
|
||||
const [qualityGate, setQualityGate] = useState(null);
|
||||
// True while the optional cadence handoff ZIP is being uploaded, before the
|
||||
// process request is sent. Drives the small status line in the left panel.
|
||||
const [handoffUploading, setHandoffUploading] = useState(false);
|
||||
const [logs, setLogs] = useState([]);
|
||||
// When each server log line arrived (epoch s, parallel to logs), from /api/status.
|
||||
const [logTimes, setLogTimes] = useState([]);
|
||||
|
|
@ -678,6 +681,40 @@ function App() {
|
|||
channel: data.channel || null,
|
||||
};
|
||||
|
||||
// Optional cadence handoff bundle: reserve a slot, PUT the ZIP, then pass
|
||||
// its id to /api/process. A failure throws and is caught below, aborting
|
||||
// the job rather than silently re-transcribing the master.
|
||||
let handoffId = null;
|
||||
if (data.handoffFile) {
|
||||
setHandoffUploading(true);
|
||||
setLogs((l) => [...l, `Uploading handoff bundle (${data.handoffFile.name})…`]);
|
||||
try {
|
||||
const createRes = await apiFetch('/api/uploads', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ filename: data.handoffFile.name, kind: 'handoff' }),
|
||||
});
|
||||
if (!createRes.ok) throw new Error(`Handoff upload failed: ${readableError(await createRes.text())}`);
|
||||
const slot = await createRes.json();
|
||||
if (!slot?.upload_url) throw new Error('Handoff upload failed: the server returned no upload URL.');
|
||||
const putRes = await apiFetch(slot.upload_url, {
|
||||
method: slot.method || 'PUT',
|
||||
headers: { 'Content-Type': 'application/zip' },
|
||||
body: data.handoffFile,
|
||||
});
|
||||
if (!putRes.ok) throw new Error(`Handoff upload failed: ${readableError(await putRes.text())}`);
|
||||
const putData = await putRes.json().catch(() => ({}));
|
||||
handoffId = putData.upload_id || slot.upload_id || null;
|
||||
if (!handoffId) throw new Error('Handoff upload failed: the server returned no upload id.');
|
||||
setLogs((l) => [...l, 'Handoff bundle attached — transcription will be skipped.']);
|
||||
} finally {
|
||||
setHandoffUploading(false);
|
||||
}
|
||||
}
|
||||
// Only travels when a bundle was attached, so the default request is
|
||||
// byte-identical to today's.
|
||||
if (handoffId) advanced.handoff_id = handoffId;
|
||||
|
||||
if (data.type === 'url') {
|
||||
headers['Content-Type'] = 'application/json';
|
||||
body = JSON.stringify({
|
||||
|
|
@ -1203,6 +1240,13 @@ function App() {
|
|||
</span>
|
||||
</div>
|
||||
|
||||
{handoffUploading && (
|
||||
<div className="mb-4 sm:mb-6 flex items-center gap-2 text-xs text-ink2" role="status" aria-live="polite">
|
||||
<Loader2 size={14} className="animate-spin text-brass shrink-0" />
|
||||
<span>uploading handoff bundle…</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Video Preview */}
|
||||
{processingMedia && (
|
||||
<ProcessingAnimation
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { Link2, Upload, FileVideo, X, Info, Loader2, ChevronDown } from 'lucide-react';
|
||||
import { Link2, Upload, FileVideo, X, Info, Loader2, ChevronDown, Paperclip, FileArchive } from 'lucide-react';
|
||||
import { track } from '../lib/analytics';
|
||||
import { getApiUrl } from '../config';
|
||||
|
||||
|
|
@ -68,6 +68,11 @@ export default function MediaInput({ onProcess, isProcessing }) {
|
|||
// empty or unreachable the selector simply does not render.
|
||||
const [channels, setChannels] = useState([]);
|
||||
const [channel, setChannel] = useState('none');
|
||||
// Cadence handoff bundle (optional): cadence's ZIP with the manifest and
|
||||
// transcript for the master. Attached to a local-file job so the pipeline
|
||||
// skips transcription. It is not sent with the video form — the parent
|
||||
// uploads it to its own slot on submit and passes back handoff_id.
|
||||
const [handoffFile, setHandoffFile] = useState(null);
|
||||
const infoRef = useRef(null);
|
||||
|
||||
// Close the compatibility popover on any outside click.
|
||||
|
|
@ -159,7 +164,9 @@ export default function MediaInput({ onProcess, isProcessing }) {
|
|||
if (mode === 'url' && url) {
|
||||
onProcess({ type: 'url', payload: url, acknowledged: true, outputFormat, ...advanced });
|
||||
} else if (mode === 'file' && file && !fileTooShort) {
|
||||
onProcess({ type: 'file', payload: file, acknowledged: true, outputFormat, ...advanced });
|
||||
// The handoff bundle only travels with a local master: it is the
|
||||
// edition cadence cut from that same file.
|
||||
onProcess({ type: 'file', payload: file, acknowledged: true, outputFormat, handoffFile: handoffFile || null, ...advanced });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -281,6 +288,49 @@ export default function MediaInput({ onProcess, isProcessing }) {
|
|||
</div>
|
||||
)}
|
||||
|
||||
{/* Cadence handoff bundle — local file jobs only. Optional:
|
||||
without it nothing changes. With it, the parent uploads the
|
||||
ZIP to its own slot and the pipeline skips transcription. */}
|
||||
{mode === 'file' && (
|
||||
<div className="mt-4" data-tutorial="handoff-bundle">
|
||||
{handoffFile ? (
|
||||
<div className="flex items-center gap-3 rounded-input border border-rule bg-paper3 px-3 py-2.5 min-w-0">
|
||||
<FileArchive size={16} className="shrink-0 text-brass" />
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate text-sm text-ink2">{handoffFile.name}</span>
|
||||
<span className="block text-[11px] leading-relaxed text-muted">
|
||||
skips transcription · must match the master's edit
|
||||
</span>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setHandoffFile(null)}
|
||||
aria-label="remove handoff bundle"
|
||||
className="p-1 text-muted hover:text-ink hover:bg-paper2 rounded-full transition-colors shrink-0"
|
||||
>
|
||||
<X size={16} />
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<label className="flex items-start gap-2.5 cursor-pointer select-none text-xs text-muted hover:text-ink2 transition-colors">
|
||||
<input
|
||||
type="file"
|
||||
accept=".zip,application/zip"
|
||||
onChange={(e) => setHandoffFile(e.target.files?.[0] || null)}
|
||||
className="hidden"
|
||||
/>
|
||||
<Paperclip size={14} className="shrink-0 mt-0.5" />
|
||||
<span className="min-w-0">
|
||||
<span className="text-ink2">cadence handoff bundle</span> (.zip, optional)
|
||||
<span className="block text-[11px] leading-relaxed mt-0.5">
|
||||
Skips transcription. The bundle must match the uploaded master's edit.
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Output format selector */}
|
||||
<div className="mt-5" data-tutorial="output-format">
|
||||
<p className="eyebrow mb-2">Output format</p>
|
||||
|
|
|
|||
Loading…
Reference in a new issue