DIYgod/RSSHub · error

message ?? code

Error message

message ?? code

What it means

Generic Error thrown by the like ('点赞视频') route when Bilibili's /x/space/like/video API returns a non-zero code. The error message is response.data.message if present, otherwise the raw code. This route does NOT require a cookie (it queries public liked-video lists) but can still fail if Bilibili returns an error.

Source

Thrown at lib/routes/bilibili/like.ts:46

    maintainers: ['ygguorun'],
    handler,
};

async function handler(ctx) {
    const uid = ctx.req.param('uid');
    const embed = !ctx.req.param('embed');

    const name = await cache.getUsernameFromUID(uid);

    const response = await got({
        url: `https://api.bilibili.com/x/space/like/video?vmid=${uid}`,
        headers: {
            Referer: `https://space.bilibili.com/${uid}/`,
        },
    });
    const { data, code, message } = response.data;
    if (code) {
        throw new Error(message ?? code);
    }

    return {
        title: `${name} 的 bilibili 点赞视频`,
        link: `https://space.bilibili.com/${uid}`,
        description: `${name} 的 bilibili 点赞视频`,
        item: data.list.map((item) => ({
            title: item.title,
            description: utils.renderUGCDescription(embed, item.pic, item.desc, item.aid, undefined, item.bvid),
            pubDate: parseDate(item.pubdate * 1000),
            link: item.pubdate > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
            author: item.owner.name,
        })),
    };
}

View on GitHub (pinned to bed535e087)

Solutions

  1. Check the server log or reproduce the API call to see the specific code/message.
  2. Reduce request frequency and increase cache expiry.
  3. Verify the uid exists by visiting space.bilibili.com/<uid> in a browser.
  4. If the user hid their liked videos, use a different route — this cannot be bypassed.

Example fix

// before
if (code) {
    throw new Error(message ?? code);
}

// after: include code context for diagnostics
if (code) {
    throw new Error(`Bilibili like/video API error ${code}: ${message ?? 'unknown'}`);
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    const { data, code, message } = response.data;
    if (code) {
        throw new Error(message ?? `Bilibili code ${code}`);
    }
} catch (e) {
    logger.error(`like/video route failed for uid=${uid}: ${e.message}`);
    throw e;
}

Prevention

When it happens

Trigger: The space/like/video endpoint returns a non-zero code. Common causes: the uid doesn't exist, Bilibili rate-limits the request (-509), the user hid their liked videos, or wbi signature verification fails.

Common situations: Polling too frequently from a datacenter IP; uid typo or deleted account; user set liked videos to private; Bilibili enabled wbi verification that the route doesn't satisfy.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/64a6f2fdf02eb6d4. Report an issue: GitHub.