jackwener/OpenCLI · error · EmptyResultError

douyin user-videos

Error message

douyin user-videos

What it means

An EmptyResultError thrown by the douyin user-videos command when fetchDouyinUserVideos returns no videos for the given sec_uid. The library treats an empty video list as an error rather than returning [] so callers can distinguish 'user has no listable videos' from a successful (possibly filtered) run. The message includes the sec_uid and points at account-existence or session validity.

Source

Thrown at clis/douyin/user-videos.js:79

    domain: 'www.douyin.com',
    strategy: Strategy.COOKIE,
    args: [
        { name: 'sec_uid', type: 'string', required: true, positional: true, help: '用户 sec_uid(个人主页 URL 末尾部分,也可直接传整条主页 URL)' },
        { name: 'limit', type: 'int', default: 20, help: '获取数量(最大 20)' },
        { name: 'with_comments', type: 'bool', default: true, help: '包含热门评论(默认: true)' },
        { name: 'comment_limit', type: 'int', default: 10, help: '每个视频获取多少条评论(最大 10)' },
    ],
    columns: ['index', 'aweme_id', 'title', 'duration', 'digg_count', 'play_url', 'top_comments'],
    func: async (page, kwargs) => {
        const secUid = normalizeSecUid(kwargs.sec_uid);
        const limit = normalizeUserVideosLimit(kwargs.limit);
        const withComments = kwargs.with_comments !== false;
        const commentLimit = normalizeCommentLimit(kwargs.comment_limit);
        await page.goto(`https://www.douyin.com/user/${secUid}`);
        await page.wait(3);
        const awemeList = (await fetchDouyinUserVideos(page, secUid, limit)).slice(0, limit);
        if (awemeList.length === 0) {
            throw new EmptyResultError('douyin user-videos', `No videos were returned for sec_uid ${secUid}. Confirm the user exists and the Douyin session is valid.`);
        }
        const videos = withComments
            ? await mapInBatches(awemeList, USER_VIDEO_COMMENT_CONCURRENCY, async (video) => ({
                ...video,
                top_comments: await fetchTopComments(page, video.aweme_id, commentLimit),
            }))
            : awemeList.map((video) => ({ ...video, top_comments: [] }));
        return videos.map((video, index) => {
            const playUrl = video.video?.play_addr?.url_list?.[0] ?? '';
            return {
                index: index + 1,
                aweme_id: video.aweme_id,
                title: video.desc ?? '',
                duration: Math.round((video.video?.duration ?? 0) / 1000),
                digg_count: video.statistics?.digg_count ?? 0,
                play_url: playUrl,
                top_comments: video.top_comments ?? [],
            };

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open https://www.douyin.com/user/<sec_uid> in a normal browser and confirm the profile exists and shows videos.
  2. Refresh the Douyin login session (re-run the auth flow) and retry.
  3. Confirm the sec_uid corresponds to a non-deactivated account; if so, treat EmptyResultError as 'user has no videos' in your code.
  4. Retry later if Douyin is serving a verification/captcha page that suppresses the video list.

Example fix

// before
const { videos } = await run('douyin user-videos', { sec_uid });
// after
let result;
try {
  result = await run('douyin user-videos', { sec_uid });
} catch (e) {
  if (e.name === 'EmptyResultError') return { videos: [] };
  throw e;
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const { videos } = await run('douyin user-videos', { sec_uid });
} catch (e) {
  if (e.name === 'EmptyResultError') return { videos: [] }; // user has no listable videos
  throw e;
}

Prevention

When it happens

Trigger: Calling `douyin user-videos --sec-uid <valid-format-sec-uid>` where the user profile page loads but fetchDouyinUserVideos yields an empty awemeList — no published videos, region/login restrictions hiding the list, or the page rendering as an error/verify page the scraper reads as empty.

Common situations: Target account deleted, renamed, or has zero public videos; account is private or shadow-restricted; the browsing session is logged out or flagged so Douyin serves an empty list; sec_uid belongs to a deactivated account.

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/27885181711a3d23. Report an issue: GitHub.