jackwener/OpenCLI · error · CommandExecutionError
captured.error
Error message
captured.error
What it means
In the segments command, after the player-extraction path fails, the CLI falls back to extractSegmentsFromNetworkCapture over the browser's network capture. If that function returns {error}, the error is thrown as a CommandExecutionError. The capture path reports an error when captured timedtext entries exist but none could be parsed into segments.
Source
Thrown at clis/youtube/transcript.js:384
const parsed = parseJson3(text);
if (parsed.error) return { error: parsed.error };
if (parsed.rows.length > 0) return parsed.rows;
}
return null;
} finally {
try { player?.pauseVideo?.(); } catch {}
if (originalFetch) globalThis.fetch = originalFetch;
if (OriginalXHR) globalThis.XMLHttpRequest = OriginalXHR;
}
})()
`);
let segments = normalizeSegmentsPayload(playerResult, 'player caption extraction', { allowNull: true });
if (!segments && canCapture) {
try {
const captured = extractSegmentsFromNetworkCapture(await page.readNetworkCapture(), lang, videoId);
if (captured.error) {
throw new CommandExecutionError(captured.error);
}
if (captured.segments.length > 0) {
segments = captured.segments;
}
}
catch (err) {
if (err instanceof CommandExecutionError)
throw err;
// Keep existing fallback path when capture is unavailable.
}
}
if (!segments) {
await prepareYoutubeApiPage(page);
}
// Fallback: get caption track URL from watch page HTML
const captionData = segments ? null : unwrapBrowserResult(await page.evaluate(`
(async () => {
const extractJsonAssignmentFromHtml = ${extractJsonAssignmentFromHtml.toString()};View on GitHub (pinned to 49907e53dc)
Solutions
- Restart the browser session to clear stale network captures, then reload the video page so fresh timedtext requests are captured.
- Check the embedded captured.error message for the underlying parse failure cause.
- Ensure consent/bot checks passed in the automated tab before the timedtext request fires.
- Update the CLI if YouTube changed the timedtext response format or pot token requirements.
Example fix
// before
const captured = extractSegmentsFromNetworkCapture(await page.readNetworkCapture(), lang, videoId);
if (captured.error) throw new CommandExecutionError(captured.error);
// after
const captured = extractSegmentsFromNetworkCapture(await page.readNetworkCapture(), lang, videoId);
if (captured.error) {
console.error('network capture fallback failed:', captured.error);
// trigger a fresh page reload to recapture timedtext
} Defensive patterns
Strategy: fallback
Validate before calling
const capture = await page.readNetworkCapture();
const hasTimedtext = Array.isArray(capture) && capture.some(e => String(e?.url || '').includes('/api/timedtext'));
if (!hasTimedtext) {
// nothing captured yet; reload the page before using the fallback path
} Type guard
function isCaptureResult(v) {
return !!v && typeof v === 'object' && (Array.isArray(v.segments) || typeof v.error === 'string');
} Try / catch
try {
const captured = extractSegmentsFromNetworkCapture(await page.readNetworkCapture(), lang, videoId);
if (captured.error) throw new Error(captured.error);
} catch (err) {
console.error('capture fallback failed:', err.message);
// reload page and recapture fresh timedtext responses
} Prevention
- Restart browser sessions to clear stale daemon-shared network captures
- Reload the video page so fresh pot-signed timedtext requests are captured
- Verify video/lang scoping filters are intact in your CLI version
- Keep the CLI updated for pot token / timedtext format changes
When it happens
Trigger: `segments` -> fallback path where page.readNetworkCapture() contains timedtext entries matching lang/video, but parseJson3Segments fails on every responsePreview, so extractSegmentsFromNetworkCapture returns {error: '...'} which is rethrown.
Common situations: Stale signed timedtext URLs in the daemon-shared tab returning error bodies; YouTube serving bot-check HTML in captured timedtext responses; SPA navigation leaving captures from prior videos that pass URL filtering but have expired pot tokens.
Related errors
- Gmail ${operation} requires browser response interception
- Gmail ${operation} could not start browser response intercep
- Gmail ${operation} capture included a response without a bod
- Gmail ${operation} capture
- Unexpected YouTube probe: ${JSON.stringify(probe)}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/3cfb60e950862cb9.
Report an issue: GitHub.