jackwener/OpenCLI · error · CommandExecutionError

YouTube video metadata is missing membersOnly

Error message

YouTube video metadata is missing membersOnly

What it means

This CommandExecutionError is thrown by requireVideoPayload in clis/youtube/video.js when the scraped YouTube watch-page bootstrap data does not contain a boolean `membersOnly` field. The library validates that the page extraction returned all expected metadata keys (playabilityStatus, playabilityReason, membersOnly); if YouTube's page structure changed, or the extraction produced a partial object, the guard fires so callers never receive incomplete metadata. It indicates a parse/extraction failure rather than a problem with the requested video itself.

Source

Thrown at clis/youtube/video.js:30

    return value;
}

function requireVideoPayload(value) {
    const payload = unwrapBrowserResult(value);
    if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
        throw new CommandExecutionError('Failed to extract video metadata from page');
    }
    if (payload.error) {
        throw new CommandExecutionError(String(payload.error));
    }
    if (typeof payload.playabilityStatus !== 'string') {
        throw new CommandExecutionError('YouTube video metadata is missing playabilityStatus');
    }
    if (typeof payload.playabilityReason !== 'string') {
        throw new CommandExecutionError('YouTube video metadata is missing playabilityReason');
    }
    if (typeof payload.membersOnly !== 'boolean') {
        throw new CommandExecutionError('YouTube video metadata is missing membersOnly');
    }
    return payload;
}

cli({
    site: 'youtube',
    name: 'video',
    access: 'read',
    description: 'Get YouTube video metadata (title, views, description, etc.)',
    domain: 'www.youtube.com',
    strategy: Strategy.COOKIE,
    args: [
        { name: 'url', required: true, positional: true, help: 'YouTube video URL or video ID' },
    ],
    columns: ['field', 'value'],
    func: async (page, kwargs) => {
        const videoId = parseVideoId(kwargs.url);
        await prepareYoutubeApiPage(page);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Update the opencli package to the latest version so the extractor matches current YouTube markup.
  2. Re-run with fresh/valid YouTube cookies (re-login) to rule out consent or bot-check pages serving a degraded page.
  3. Inspect the raw page payload by temporarily logging the extraction result to confirm which fields are missing.
  4. If it persists, report the issue — the extractor likely needs updating for a YouTube markup change.

Example fix

// before
if (typeof payload.membersOnly !== 'boolean') {
    throw new CommandExecutionError('YouTube video metadata is missing membersOnly');
}
// after
if (payload.membersOnly === undefined) {
    payload.membersOnly = payload.playabilityStatus === 'UNPLAYABLE' && /members[- ]only/i.test(payload.playabilityReason || '');
}
Defensive patterns

Strategy: validation

Validate before calling

function isValidVideoPayload(p) {
  return !!p && typeof p === 'object' && !Array.isArray(p)
    && typeof p.playabilityStatus === 'string'
    && typeof p.playabilityReason === 'string'
    && typeof p.membersOnly === 'boolean';
}

Type guard

const isVideoPayload = (p) =>
  typeof p === 'object' && p !== null && !Array.isArray(p) &&
  typeof p.membersOnly === 'boolean';

Try / catch

try {
  const meta = await runYoutubeVideo(url);
} catch (e) {
  if (/missing membersOnly/.test(e.message)) {
    // extraction shape failure: retry once, then surface as site-change issue
  } else throw e;
}

Prevention

When it happens

Trigger: Calling the `youtube video <url>` CLI command when the in-page extraction script returns an object lacking a boolean membersOnly field — typically after a YouTube page markup change, a truncated/consented page render, or a bot-checked page whose ytInitialPlayerResponse differs from the expected shape.

Common situations: YouTube A/B tests or redesigns altering the bootstrap player response; scraping from a datacenter IP that receives a consent or captcha page; stale session cookies yielding a degraded page; the CLI version lagging behind a site change.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/d0531341a9783fdb. Report an issue: GitHub.