jackwener/OpenCLI · warning · EmptyResultError

youtube playlist

Error message

youtube playlist

What it means

EmptyResultError thrown when playlist data was fetched successfully but the extracted videos array is empty (data.videos is missing or zero-length). It signals a well-formed playlist page with no parseable video entries rather than a hard failure.

Source

Thrown at clis/youtube/playlist.js:92

          const contData = await fetchBrowse(apiKey, { context, continuation: token });
          if (contData.error) break;
          const newItems = contData.onResponseReceivedActions?.[0]?.appendContinuationItemsAction?.continuationItems || [];
          if (!newItems.length) break;
          videos = videos.concat(extractVideos(newItems));
          contItem = newItems[newItems.length - 1];
        }

        return { title, channelName, stats, videos: videos.slice(0, limit) };
      })()
    `);
        if (!data || typeof data !== 'object') {
            throw new CommandExecutionError('Failed to fetch playlist data');
        }
        if (data.error) {
            throw new CommandExecutionError(String(data.error));
        }
        if (!data.videos?.length) {
            throw new EmptyResultError('youtube playlist');
        }
        const statsStr = (data.stats || []).join(' | ');
        process.stderr.write(`${data.title}  [${data.channelName}]  ${statsStr}\n`);
        return data.videos;
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Confirm the playlist actually shows videos in a browser
  2. Re-run with a larger --limit or default settings in case a small-limit filter emptied the result
  3. Update the CLI if extraction selectors no longer match YouTube's DOM

Example fix

// before
opencli youtube playlist PL_EMPTY  // 0 videos
// after
opencli youtube playlist PL_WITH_VIDEOS --limit 20
Defensive patterns

Strategy: type-guard

Validate before calling

null

Type guard

function hasVideos(result) {
  return Array.isArray(result) && result.length > 0;
}
// caller:
const videos = await run('youtube playlist', [id]).catch(() => []);
if (!hasVideos(videos)) console.warn(`Playlist ${id} yielded no videos`);

Try / catch

try {
  const videos = await run('youtube playlist', [id]);
  if (!videos.length) console.warn('Playlist is empty or unparseable');
} catch (e) {
  if (/Empty result/i.test(e.message)) console.warn(`No videos in playlist ${id}`);
  else throw e;
}

Prevention

When it happens

Trigger: A playlist that exists but contains zero videos, or a page where video extraction selectors matched nothing (YouTube markup change, unexpanded continuation content, or a saved/hidden playlist variant).

Common situations: Freshly created empty playlist, playlist whose videos are all deleted/private, or YouTube DOM changes so the scraper finds the playlist header but no video rows.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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