fix(dashboard): real log times, stage progress, cards that use the width
Logs - Each job log line records when it arrived (app._TimedLog) and /api/status returns log_times; the dashboard showed new Date() on every render, so every line had the same, moving clock. - The cloud log view shows every stage: download %, early audio, transcription %, finding moments, layout, clips found, and per clip creating / framed / ready. Progress updates its own line instead of adding one per step. Lines glued to yt-dlp's \r progress bar (the parallel transcription prints onto it) are split, so its % shows again. "Found N clips" matched the old "viral clips" wording only. Result cards - The results grid only goes to two columns when each card gets ~600px (auto-fill) instead of at the xl breakpoint, where the side panel was squeezed and the copy buttons spilled out of the card. - Card actions take as many per row as fit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7103f9446f
commit
0ef20db988
6 changed files with 187 additions and 42 deletions
52
app.py
52
app.py
|
|
@ -791,7 +791,7 @@ def _recover_jobs_from_disk():
|
||||||
owner = int(raw) if raw.isdigit() else (raw or None)
|
owner = int(raw) if raw.isdigit() else (raw or None)
|
||||||
jobs[job_id] = {
|
jobs[job_id] = {
|
||||||
'status': 'completed',
|
'status': 'completed',
|
||||||
'logs': ["♻️ Job recovered from disk after server restart."],
|
'logs': _TimedLog(["♻️ Job recovered from disk after server restart."]),
|
||||||
'output_dir': job_path,
|
'output_dir': job_path,
|
||||||
'user_id': owner,
|
'user_id': owner,
|
||||||
'result': {'clips': clips, 'cost_analysis': data.get('cost_analysis')},
|
'result': {'clips': clips, 'cost_analysis': data.get('cost_analysis')},
|
||||||
|
|
@ -1225,7 +1225,7 @@ def _resume_interrupted_jobs() -> set:
|
||||||
|
|
||||||
jobs[job_id] = {
|
jobs[job_id] = {
|
||||||
'status': 'queued',
|
'status': 'queued',
|
||||||
'logs': [f"♻️ Resuming your video after a server update (attempt {attempts})."],
|
'logs': _TimedLog([f"♻️ Resuming your video after a server update (attempt {attempts})."]),
|
||||||
'cmd': m.get("cmd"),
|
'cmd': m.get("cmd"),
|
||||||
'env': env,
|
'env': env,
|
||||||
'output_dir': job_path,
|
'output_dir': job_path,
|
||||||
|
|
@ -2221,6 +2221,39 @@ _SENSITIVE_LOG_RE = re.compile(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class _TimedLog(list):
|
||||||
|
"""A job's log lines plus the time each one arrived (``.times``).
|
||||||
|
|
||||||
|
The dashboard used to stamp every line with the time it was RENDERED, so
|
||||||
|
all of them showed the same clock and it changed on every poll.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, lines=()):
|
||||||
|
super().__init__(lines)
|
||||||
|
self.times = [time.time()] * len(self)
|
||||||
|
|
||||||
|
def append(self, line):
|
||||||
|
super().append(line)
|
||||||
|
self.times.append(time.time())
|
||||||
|
|
||||||
|
def extend(self, lines):
|
||||||
|
lines = list(lines)
|
||||||
|
super().extend(lines)
|
||||||
|
self.times.extend([time.time()] * len(lines))
|
||||||
|
|
||||||
|
|
||||||
|
def _visible_logs_timed(logs):
|
||||||
|
"""(lines, times) to surface to the client; see _visible_logs."""
|
||||||
|
times = getattr(logs, "times", None)
|
||||||
|
if times is not None and len(times) != len(logs):
|
||||||
|
times = None
|
||||||
|
if not BILLING_ENABLED or DEBUG_LOGS:
|
||||||
|
return list(logs), list(times) if times is not None else None
|
||||||
|
from log_view import friendly_logs_timed
|
||||||
|
pairs = friendly_logs_timed(logs, times)
|
||||||
|
return [p[0] for p in pairs], ([p[1] for p in pairs] if times is not None else None)
|
||||||
|
|
||||||
|
|
||||||
def _visible_logs(logs):
|
def _visible_logs(logs):
|
||||||
"""Logs to surface to the client.
|
"""Logs to surface to the client.
|
||||||
|
|
||||||
|
|
@ -3050,7 +3083,7 @@ async def process_endpoint(
|
||||||
# Enqueue Job
|
# Enqueue Job
|
||||||
jobs[job_id] = {
|
jobs[job_id] = {
|
||||||
'status': 'queued',
|
'status': 'queued',
|
||||||
'logs': [f"Job {job_id} queued."],
|
'logs': _TimedLog([f"Job {job_id} queued."]),
|
||||||
'cmd': cmd,
|
'cmd': cmd,
|
||||||
'env': env,
|
'env': env,
|
||||||
'output_dir': job_output_dir,
|
'output_dir': job_output_dir,
|
||||||
|
|
@ -3109,7 +3142,7 @@ def _job_view_from_disk(job_id):
|
||||||
owner = m.get("user_id")
|
owner = m.get("user_id")
|
||||||
return {
|
return {
|
||||||
'status': 'processing' if alive else 'queued',
|
'status': 'processing' if alive else 'queued',
|
||||||
'logs': ["♻️ The server was updated; your video continues on the new instance."],
|
'logs': _TimedLog(["♻️ The server was updated; your video continues on the new instance."]),
|
||||||
'user_id': (int(owner) if isinstance(owner, str) and owner.isdigit() else owner),
|
'user_id': (int(owner) if isinstance(owner, str) and owner.isdigit() else owner),
|
||||||
'result': None,
|
'result': None,
|
||||||
}
|
}
|
||||||
|
|
@ -3134,9 +3167,12 @@ async def get_status(job_id: str, request: Request):
|
||||||
raise HTTPException(status_code=404, detail="Job not found")
|
raise HTTPException(status_code=404, detail="Job not found")
|
||||||
|
|
||||||
await _assert_job_owner(request, job)
|
await _assert_job_owner(request, job)
|
||||||
|
_logs_view = _visible_logs_timed(job['logs'])
|
||||||
return {
|
return {
|
||||||
"status": _presented_status(job_id, job),
|
"status": _presented_status(job_id, job),
|
||||||
"logs": _visible_logs(job['logs']),
|
"logs": _logs_view[0],
|
||||||
|
# When each line arrived (epoch seconds, parallel to "logs"), or None.
|
||||||
|
"log_times": _logs_view[1],
|
||||||
"result": job.get('result'),
|
"result": job.get('result'),
|
||||||
# Position in line and a rough wait while the job is still queued.
|
# Position in line and a rough wait while the job is still queued.
|
||||||
"queue": queue_snapshot(job_id),
|
"queue": queue_snapshot(job_id),
|
||||||
|
|
@ -3436,7 +3472,7 @@ async def _restore_job_files(job_id: str, proj, user_id: str) -> bool:
|
||||||
f"{_canonical_clip_file(job_dir, base_name, i)}")
|
f"{_canonical_clip_file(job_dir, base_name, i)}")
|
||||||
jobs[job_id] = {
|
jobs[job_id] = {
|
||||||
'status': 'completed',
|
'status': 'completed',
|
||||||
'logs': ["♻️ Project restored from your library."],
|
'logs': _TimedLog(["♻️ Project restored from your library."]),
|
||||||
'output_dir': job_dir,
|
'output_dir': job_dir,
|
||||||
'user_id': user_id,
|
'user_id': user_id,
|
||||||
'result': {'clips': clips, 'cost_analysis': data.get('cost_analysis')},
|
'result': {'clips': clips, 'cost_analysis': data.get('cost_analysis')},
|
||||||
|
|
@ -6690,7 +6726,7 @@ async def saasshorts_generate(
|
||||||
saas_jobs[job_id] = {
|
saas_jobs[job_id] = {
|
||||||
"user_id": await _owner_id(request),
|
"user_id": await _owner_id(request),
|
||||||
"status": "processing",
|
"status": "processing",
|
||||||
"logs": [f"Retrying job {job_id[:8]}... reusing cached assets from disk."],
|
"logs": _TimedLog([f"Retrying job {job_id[:8]}... reusing cached assets from disk."]),
|
||||||
"result": None,
|
"result": None,
|
||||||
"output_dir": job_output_dir,
|
"output_dir": job_output_dir,
|
||||||
}
|
}
|
||||||
|
|
@ -6702,7 +6738,7 @@ async def saasshorts_generate(
|
||||||
saas_jobs[job_id] = {
|
saas_jobs[job_id] = {
|
||||||
"user_id": await _owner_id(request),
|
"user_id": await _owner_id(request),
|
||||||
"status": "processing",
|
"status": "processing",
|
||||||
"logs": ["SaaSShorts job started."],
|
"logs": _TimedLog(["SaaSShorts job started."]),
|
||||||
"result": None,
|
"result": None,
|
||||||
"output_dir": job_output_dir,
|
"output_dir": job_output_dir,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -346,6 +346,8 @@ function App() {
|
||||||
// Pre-flight quality gate: { info: {max_height, min_height, cookies_invalid}, data }
|
// Pre-flight quality gate: { info: {max_height, min_height, cookies_invalid}, data }
|
||||||
const [qualityGate, setQualityGate] = useState(null);
|
const [qualityGate, setQualityGate] = useState(null);
|
||||||
const [logs, setLogs] = useState([]);
|
const [logs, setLogs] = useState([]);
|
||||||
|
// When each server log line arrived (epoch s, parallel to logs), from /api/status.
|
||||||
|
const [logTimes, setLogTimes] = useState([]);
|
||||||
// Collapsed on phones: the log tail is the least useful thing on a 360px
|
// Collapsed on phones: the log tail is the least useful thing on a 360px
|
||||||
// screen and it was pushing the actual clips a full scroll down.
|
// screen and it was pushing the actual clips a full scroll down.
|
||||||
const [logsVisible, setLogsVisible] = useState(() => {
|
const [logsVisible, setLogsVisible] = useState(() => {
|
||||||
|
|
@ -509,6 +511,7 @@ function App() {
|
||||||
setJobId(data.job_id);
|
setJobId(data.job_id);
|
||||||
setResults(data.result || null);
|
setResults(data.result || null);
|
||||||
setLogs(['♻️ Project restored from your library.']);
|
setLogs(['♻️ Project restored from your library.']);
|
||||||
|
setLogTimes([Date.now() / 1000]);
|
||||||
setProcessingMedia(null);
|
setProcessingMedia(null);
|
||||||
setQualityGate(null);
|
setQualityGate(null);
|
||||||
setStatus('complete');
|
setStatus('complete');
|
||||||
|
|
@ -751,7 +754,10 @@ function App() {
|
||||||
refreshMe();
|
refreshMe();
|
||||||
} else {
|
} else {
|
||||||
// Update logs if available
|
// Update logs if available
|
||||||
if (data.logs) setLogs(data.logs);
|
if (data.logs) {
|
||||||
|
setLogs(data.logs);
|
||||||
|
setLogTimes(data.log_times || []);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Polling error", e);
|
console.error("Polling error", e);
|
||||||
|
|
@ -953,6 +959,7 @@ function App() {
|
||||||
setStatus('processing');
|
setStatus('processing');
|
||||||
setJobError('');
|
setJobError('');
|
||||||
setLogs(["Starting process..."]);
|
setLogs(["Starting process..."]);
|
||||||
|
setLogTimes([Date.now() / 1000]);
|
||||||
setResults(null);
|
setResults(null);
|
||||||
// Studio handovers have no local media object; the preview switches to the
|
// Studio handovers have no local media object; the preview switches to the
|
||||||
// backend-served source once the job id is known.
|
// backend-served source once the job id is known.
|
||||||
|
|
@ -1100,6 +1107,7 @@ function App() {
|
||||||
setJobId(null);
|
setJobId(null);
|
||||||
setResults(null);
|
setResults(null);
|
||||||
setLogs([]);
|
setLogs([]);
|
||||||
|
setLogTimes([]);
|
||||||
setProcessingMedia(null);
|
setProcessingMedia(null);
|
||||||
setProjectState(null);
|
setProjectState(null);
|
||||||
setNoSource(false);
|
setNoSource(false);
|
||||||
|
|
@ -2030,7 +2038,9 @@ function App() {
|
||||||
<div className="flex-1 p-3.5 sm:p-4 overflow-y-auto font-mono text-[11px] sm:text-xs space-y-1.5 custom-scrollbar text-muted break-words">
|
<div className="flex-1 p-3.5 sm:p-4 overflow-y-auto font-mono text-[11px] sm:text-xs space-y-1.5 custom-scrollbar text-muted break-words">
|
||||||
{logs.map((log, i) => (
|
{logs.map((log, i) => (
|
||||||
<div key={i} className={`flex gap-2 ${log.toLowerCase().includes('error') ? 'text-danger' : 'text-muted'}`}>
|
<div key={i} className={`flex gap-2 ${log.toLowerCase().includes('error') ? 'text-danger' : 'text-muted'}`}>
|
||||||
<span className="text-muted opacity-50 shrink-0 hidden sm:inline">{new Date().toLocaleTimeString()}</span>
|
<span className="text-muted opacity-50 shrink-0 hidden sm:inline tabular-nums">
|
||||||
|
{logTimes[i] ? new Date(logTimes[i] * 1000).toLocaleTimeString() : ''}
|
||||||
|
</span>
|
||||||
<span className="min-w-0 break-words">{log}</span>
|
<span className="min-w-0 break-words">{log}</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
@ -2167,7 +2177,7 @@ function App() {
|
||||||
|
|
||||||
<div className="flex-1 overflow-y-auto custom-scrollbar p-1">
|
<div className="flex-1 overflow-y-auto custom-scrollbar p-1">
|
||||||
{results && results.clips && results.clips.length > 0 ? (
|
{results && results.clips && results.clips.length > 0 ? (
|
||||||
<div className={`grid gap-4 pb-10 ${status === 'complete' ? 'grid-cols-1 xl:grid-cols-2' : 'grid-cols-1'}`}>
|
<div className={`grid gap-4 pb-10 ${status === 'complete' ? 'grid-cols-[repeat(auto-fill,minmax(min(100%,600px),1fr))]' : 'grid-cols-1'}`}>
|
||||||
{rankedClips.map(({ clip, index: i }) => (
|
{rankedClips.map(({ clip, index: i }) => (
|
||||||
<ResultCard
|
<ResultCard
|
||||||
key={`${jobId}-${i}-${clip.video_url || ''}`}
|
key={`${jobId}-${i}-${clip.video_url || ''}`}
|
||||||
|
|
|
||||||
|
|
@ -866,7 +866,7 @@ export default function ResultCard({ clip, index, jobId, durable, uploadPostKey,
|
||||||
|
|
||||||
{/* Descriptions (compact) — full text lives in the modal */}
|
{/* Descriptions (compact) — full text lives in the modal */}
|
||||||
<div className="flex-1 min-h-0 space-y-2 mb-4">
|
<div className="flex-1 min-h-0 space-y-2 mb-4">
|
||||||
<div className="bg-paper rounded-input px-3 py-2 border border-rule flex items-center gap-2 min-w-0">
|
<div className="bg-paper rounded-input px-3 py-2 border border-rule flex items-center gap-2 min-w-0 overflow-hidden">
|
||||||
<span className="eyebrow shrink-0">YOUTUBE</span>
|
<span className="eyebrow shrink-0">YOUTUBE</span>
|
||||||
<p className="text-xs text-ink2 truncate flex-1 min-w-0">
|
<p className="text-xs text-ink2 truncate flex-1 min-w-0">
|
||||||
{clip.video_title_for_youtube_short || "Viral Short Video"}
|
{clip.video_title_for_youtube_short || "Viral Short Video"}
|
||||||
|
|
@ -880,7 +880,7 @@ export default function ResultCard({ clip, index, jobId, durable, uploadPostKey,
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="bg-paper rounded-input px-3 py-2 border border-rule flex items-center gap-2 min-w-0">
|
<div className="bg-paper rounded-input px-3 py-2 border border-rule flex items-center gap-2 min-w-0 overflow-hidden">
|
||||||
<span className="eyebrow shrink-0">TIKTOK · IG</span>
|
<span className="eyebrow shrink-0">TIKTOK · IG</span>
|
||||||
<p className="text-xs text-ink2 truncate flex-1 min-w-0">
|
<p className="text-xs text-ink2 truncate flex-1 min-w-0">
|
||||||
{clip.video_description_for_tiktok || clip.video_description_for_instagram}
|
{clip.video_description_for_tiktok || clip.video_description_for_instagram}
|
||||||
|
|
@ -911,7 +911,7 @@ export default function ResultCard({ clip, index, jobId, durable, uploadPostKey,
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Actions Footer */}
|
{/* Actions Footer */}
|
||||||
<div className="grid grid-cols-2 gap-2 mt-auto pt-4 border-t border-rule">
|
<div className="grid grid-cols-[repeat(auto-fill,minmax(104px,1fr))] gap-2 mt-auto pt-4 border-t border-rule">
|
||||||
{onEditClip && (
|
{onEditClip && (
|
||||||
<button
|
<button
|
||||||
onClick={() => onEditClip(index)}
|
onClick={() => onEditClip(index)}
|
||||||
|
|
|
||||||
114
log_view.py
114
log_view.py
|
|
@ -4,6 +4,10 @@ Self-hosted instances see the raw pipeline output (useful for debugging).
|
||||||
Cloud/paying users get a curated, whitelist-based view: friendly progress
|
Cloud/paying users get a curated, whitelist-based view: friendly progress
|
||||||
lines only — no file paths, model names, encoder details or pipeline
|
lines only — no file paths, model names, encoder details or pipeline
|
||||||
internals. Anything not matched by a rule is hidden.
|
internals. Anything not matched by a rule is hidden.
|
||||||
|
|
||||||
|
Progress (download %, transcription %) updates ITS OWN line instead of
|
||||||
|
adding one per step, so the view reads as a list of stages. Each line keeps
|
||||||
|
the time it first appeared.
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
@ -15,40 +19,102 @@ def _strip_paths(line):
|
||||||
return _PATH_RE.sub('', line).rstrip(' :')
|
return _PATH_RE.sub('', line).rstrip(' :')
|
||||||
|
|
||||||
|
|
||||||
# Ordered rules; first match wins. Replacement is a template using the
|
# Ordered rules; first match wins: (pattern, template, progress kind).
|
||||||
# match's groups, or None to keep the (path-stripped) line verbatim.
|
# The template uses the match's groups, or None keeps the (path-stripped)
|
||||||
|
# line verbatim. A progress kind makes the line update in place.
|
||||||
_RULES = [
|
_RULES = [
|
||||||
# Worker/job lifecycle + errors: keep, minus any paths.
|
# Worker/job lifecycle + errors: keep, minus any paths.
|
||||||
(re.compile(r'^(Job started|Process finished|Process failed|'
|
(re.compile(r'^(Job started|Process finished|Process failed|'
|
||||||
r'Execution error|No metadata|❌)'), None),
|
r'Execution error|No metadata|❌)'), None, None),
|
||||||
|
(re.compile(r'Download attempt'), '📥 Downloading video…', 'download'),
|
||||||
|
(re.compile(r'\[download\]\s+(\d+)(?:\.\d+)?% of'), '📥 Downloading video… {0}%', 'download'),
|
||||||
|
(re.compile(r'downloading only the first (\d+) min'),
|
||||||
|
'✂️ Long video: downloading the first {0} min', None),
|
||||||
|
(re.compile(r'Video downloaded in'), '✅ Video downloaded', None),
|
||||||
|
(re.compile(r'Audio ready ahead of the video'),
|
||||||
|
'🎧 Audio ready — transcribing while the video downloads', None),
|
||||||
# Live transcription progress emitted by transcribe_backends.
|
# Live transcription progress emitted by transcribe_backends.
|
||||||
(re.compile(r'^🎙️ Transcribing… \d+%'), None),
|
(re.compile(r'Transcribing… (\d+)%'), '🎙️ Transcribing audio… {0}%', 'asr'),
|
||||||
(re.compile(r'Transcribing (video|audio)'), '🎙️ Transcribing audio…'),
|
(re.compile(r'Transcribing (video|audio)'), '🎙️ Transcribing audio…', 'asr'),
|
||||||
(re.compile(r'Found (\d+) viral clips'), '🔥 Found {0} viral clips!'),
|
(re.compile(r'Analyzing with (?:Gemini|local LLM)'), '🤖 Finding the best moments…', None),
|
||||||
(re.compile(r'Processing Clip (\d+)'), '🎬 Creating clip {0}…'),
|
(re.compile(r'Silent video — analyzing'), '🎥 No speech — finding moments in the picture…', None),
|
||||||
(re.compile(r'Clip (\d+) ready'), '✅ Clip {0} ready'),
|
(re.compile(r'Choosing a layout'), '🎛️ Choosing the layout…', None),
|
||||||
|
(re.compile(r'Found (\d+) (?:viral )?clips'), '🔥 Found {0} clips!', None),
|
||||||
|
(re.compile(r'Processing Clip (\d+)'), '🎬 Creating clip {0}…', None),
|
||||||
|
(re.compile(r'Clip (\d+) framed'), '🎞️ Clip {0} framed', None),
|
||||||
|
(re.compile(r'Clip (\d+) ready'), '✅ Clip {0} ready', None),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def _match(segment):
|
||||||
|
"""(text, kind) for one raw segment, or None to hide it."""
|
||||||
|
stripped = segment.strip()
|
||||||
|
if not stripped:
|
||||||
|
return None
|
||||||
|
for pattern, template, kind in _RULES:
|
||||||
|
match = pattern.search(stripped)
|
||||||
|
if match:
|
||||||
|
if template is None:
|
||||||
|
return _strip_paths(stripped), kind
|
||||||
|
return template.format(*match.groups()), kind
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _segments(line):
|
||||||
|
"""A raw line can hold several outputs: yt-dlp redraws its progress bar
|
||||||
|
with \\r and no newline, so a parallel print lands on the same line."""
|
||||||
|
parts = []
|
||||||
|
for chunk in str(line).split('\r'):
|
||||||
|
# A print glued to the end of a progress bar: split before each emoji
|
||||||
|
# marker the pipeline starts its own lines with.
|
||||||
|
parts.extend(p for p in re.split(r'(?=🎙️|🎧|✅ Video downloaded)', chunk) if p)
|
||||||
|
return parts
|
||||||
|
|
||||||
|
|
||||||
def friendly_log_line(line):
|
def friendly_log_line(line):
|
||||||
"""Map one raw log line to its cloud-visible form, or None to hide it."""
|
"""Map one raw log line to its cloud-visible form, or None to hide it."""
|
||||||
stripped = line.strip()
|
for seg in _segments(line):
|
||||||
if not stripped:
|
hit = _match(seg)
|
||||||
return None
|
if hit:
|
||||||
for pattern, template in _RULES:
|
return hit[0]
|
||||||
match = pattern.search(stripped)
|
|
||||||
if match:
|
|
||||||
if template is None:
|
|
||||||
return _strip_paths(stripped)
|
|
||||||
return template.format(*match.groups())
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def friendly_logs_timed(logs, times=None):
|
||||||
|
"""Curated (text, time) list for cloud users.
|
||||||
|
|
||||||
|
Consecutive duplicates collapse, and a progress line (download %,
|
||||||
|
transcription %) is updated in place instead of repeated; a line keeps the
|
||||||
|
time it first appeared. ``times`` is a list parallel to ``logs`` (epoch
|
||||||
|
seconds) or None.
|
||||||
|
"""
|
||||||
|
out = [] # [text, time]
|
||||||
|
live = {} # progress kind -> index in out still being updated
|
||||||
|
for i, line in enumerate(logs):
|
||||||
|
t = times[i] if times is not None and i < len(times) else None
|
||||||
|
for seg in _segments(line):
|
||||||
|
hit = _match(seg)
|
||||||
|
if not hit:
|
||||||
|
continue
|
||||||
|
text, kind = hit
|
||||||
|
if kind and kind in live:
|
||||||
|
out[live[kind]][0] = text
|
||||||
|
continue
|
||||||
|
if out and out[-1][0] == text:
|
||||||
|
continue
|
||||||
|
out.append([text, t])
|
||||||
|
# Any other line closes the running progress of other stages only
|
||||||
|
# when it is a new stage of the same kind; different kinds (the
|
||||||
|
# download and the early transcription) run side by side.
|
||||||
|
if kind:
|
||||||
|
live[kind] = len(out) - 1
|
||||||
|
elif text.startswith(('✅ Video downloaded', '✂️')):
|
||||||
|
live.pop('download', None)
|
||||||
|
elif text.startswith(('🔥', '🤖', '🎥')):
|
||||||
|
live.pop('asr', None)
|
||||||
|
return [(text, t) for text, t in out]
|
||||||
|
|
||||||
|
|
||||||
def friendly_logs(logs):
|
def friendly_logs(logs):
|
||||||
"""Curated log list for cloud users, consecutive duplicates collapsed."""
|
"""Curated log list for cloud users (see friendly_logs_timed)."""
|
||||||
out = []
|
return [text for text, _t in friendly_logs_timed(logs)]
|
||||||
for line in logs:
|
|
||||||
friendly = friendly_log_line(line)
|
|
||||||
if friendly and (not out or out[-1] != friendly):
|
|
||||||
out.append(friendly)
|
|
||||||
return out
|
|
||||||
|
|
|
||||||
2
main.py
2
main.py
|
|
@ -2382,6 +2382,8 @@ if __name__ == '__main__':
|
||||||
# dict, so the re-dump after the pool is race-free.
|
# dict, so the re-dump after the pool is race-free.
|
||||||
success = render_clip(clip_temp_path, clip_final_path, output_format,
|
success = render_clip(clip_temp_path, clip_final_path, output_format,
|
||||||
watermark=os.environ.get("WATERMARK") == "1")
|
watermark=os.environ.get("WATERMARK") == "1")
|
||||||
|
if success:
|
||||||
|
print(f" 🎞️ Clip {i+1} framed")
|
||||||
deliver_path = clip_final_path
|
deliver_path = clip_final_path
|
||||||
# Which stretches were stacked (SPLIT): captions go on the
|
# Which stretches were stacked (SPLIT): captions go on the
|
||||||
# seam there, and /api/subtitle needs it again later.
|
# seam there, and /api/subtitle needs it again later.
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,8 @@ RAW_JOB = [
|
||||||
def test_real_job_produces_clean_user_view():
|
def test_real_job_produces_clean_user_view():
|
||||||
assert friendly_logs(RAW_JOB) == [
|
assert friendly_logs(RAW_JOB) == [
|
||||||
"Job started by worker.",
|
"Job started by worker.",
|
||||||
"🎙️ Transcribing audio…",
|
"🎙️ Transcribing audio… 100%", # progress updates its own line
|
||||||
"🎙️ Transcribing… 25% (3s)",
|
"🔥 Found 2 clips!",
|
||||||
"🎙️ Transcribing… 100% (7s)",
|
|
||||||
"🔥 Found 2 viral clips!",
|
|
||||||
"🎬 Creating clip 1…",
|
"🎬 Creating clip 1…",
|
||||||
"✅ Clip 1 ready",
|
"✅ Clip 1 ready",
|
||||||
"Process finished successfully.",
|
"Process finished successfully.",
|
||||||
|
|
@ -59,3 +57,36 @@ def test_errors_kept_without_paths():
|
||||||
def test_consecutive_duplicates_collapse():
|
def test_consecutive_duplicates_collapse():
|
||||||
logs = ["🎙️ Transcribing video...", "🎙️ Transcribing audio from: x.mp4"]
|
logs = ["🎙️ Transcribing video...", "🎙️ Transcribing audio from: x.mp4"]
|
||||||
assert friendly_logs(logs) == ["🎙️ Transcribing audio…"]
|
assert friendly_logs(logs) == ["🎙️ Transcribing audio…"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_progress_glued_to_a_download_bar_is_still_seen():
|
||||||
|
"""yt-dlp redraws its bar with \\r and no newline; the early transcription
|
||||||
|
prints onto the same line."""
|
||||||
|
logs = [
|
||||||
|
"📥 Download attempt: HD-static1",
|
||||||
|
"[download] 17.3% of 404.46MiB at 55MiB/s ETA 00:05\r[download] 24.9% of 404MiB"
|
||||||
|
"🎙️ Transcribing… 25% (2s)",
|
||||||
|
"🎧 Audio ready ahead of the video: .early_audio.m4a",
|
||||||
|
"🎙️ Transcribing… 100% (9s)",
|
||||||
|
"✅ Video downloaded in 28.95s: output/x/video.mp4",
|
||||||
|
"🔥 Found 6 clips!",
|
||||||
|
]
|
||||||
|
assert friendly_logs(logs) == [
|
||||||
|
"📥 Downloading video… 24%",
|
||||||
|
"🎙️ Transcribing audio… 100%",
|
||||||
|
"🎧 Audio ready — transcribing while the video downloads",
|
||||||
|
"✅ Video downloaded",
|
||||||
|
"🔥 Found 6 clips!",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_each_line_keeps_the_time_it_first_appeared():
|
||||||
|
from log_view import friendly_logs_timed
|
||||||
|
logs = ["🎙️ Transcribing video...", "🎙️ Transcribing… 50% (3s)",
|
||||||
|
"🔥 Found 2 clips!", "🎬 Processing Clip 1: 0s - 30s"]
|
||||||
|
times = [100.0, 105.0, 110.0, 111.0]
|
||||||
|
assert friendly_logs_timed(logs, times) == [
|
||||||
|
("🎙️ Transcribing audio… 50%", 100.0),
|
||||||
|
("🔥 Found 2 clips!", 110.0),
|
||||||
|
("🎬 Creating clip 1…", 111.0),
|
||||||
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue