DIYgod/RSSHub · error

It looks like something went wrong when querying the Bilibil

Error message

It looks like something went wrong when querying the Bilibili API: code = ${data.code}, message = ${data.message}

What it means

Thrown by /bilibili/user/bangumi/:uid when the user's bangumi follow-list API (https://api.bilibili.com/x/space/bangumi/follow/list) returns a non-zero business code. The handler re-throws the upstream code and message verbatim as a plain Error. The endpoint needs the requester's own session for private follow lists and a valid Referer for public ones; non-zero codes commonly reflect visibility/permission or anti-crawler states.

Source

Thrown at lib/routes/bilibili/user-bangumi.ts:45

    handler,
};

async function handler(ctx) {
    const uid = ctx.req.param('uid');
    const type = Number(ctx.req.param('type') || 1);
    const type_name = ((t) => ['', 'bangumi', 'cinema'][t])(type);
    const name = await cache.getUsernameFromUID(uid);

    const response = await got({
        method: 'get',
        url: `https://api.bilibili.com/x/space/bangumi/follow/list?type=${type}&follow_status=0&pn=1&ps=15&vmid=${uid}`,
        headers: {
            Referer: `https://space.bilibili.com/${uid}/${type_name}`,
        },
    });
    const data = response.data;
    if (data.code !== 0) {
        throw new Error(`It looks like something went wrong when querying the Bilibili API: code = ${data.code}, message = ${data.message}`);
    }

    return {
        title: `${name} 的追番列表`,
        link: `https://space.bilibili.com/${uid}/${type_name}`,
        description: `${name} 的追番列表`,
        item:
            data.data &&
            data.data.list &&
            data.data.list.map((item) => ({
                title: `[${item.new_ep.index_show}]${item.title}`,
                description: `${item.evaluate}<br><img src="${item.cover}">`,
                pubDate: new Date(item.new_ep.pub_time ?? Date.now()).toUTCString(),
                link: 'https://www.bilibili.com/bangumi/play/' + (item.new_ep.id ? `ep${item.new_ep.id}` : `ss${item.season_id}`),
            })),
    };
}

View on GitHub (pinned to bed535e087)

Solutions

  1. Confirm the uid is valid and the user's 番剧 follow list is public on space.bilibili.com/{uid}/bangumi.
  2. Set a BILIBILI_COOKIE_* so the request is authenticated (though this route currently does not forward one — patching it to send Cookie + wbi signature is the robust fix).
  3. Retry after a cooldown if the code looks like risk control (-352/-799).
  4. Decode the code/message in the error text to pinpoint permission (-403) vs anti-crawler (-352) vs not-found.

Example fix

// before
const response = await got({
    url: `https://api.bilibili.com/x/space/bangumi/follow/list?type=${type}&...&vmid=${uid}`,
    headers: { Referer: `https://space.bilibili.com/${uid}/${type_name}` },
});
if (data.code !== 0) {
    throw new Error(`It looks like something went wrong when querying the Bilibili API: code = ${data.code}, message = ${data.message}`);
}

// after (authenticate + classify)
const cookie = await cache.getCookie();
const response = await got({
    url: `https://api.bilibili.com/x/space/bangumi/follow/list?type=${type}&...&vmid=${uid}`,
    headers: { Referer: `https://space.bilibili.com/${uid}/${type_name}`, Cookie: cookie },
});
if (data.code !== 0) {
    if (data.code === -403) {
        throw new Error(`User ${uid}'s bangumi list is private`);
    }
    throw new Error(`Bilibili API error: code = ${data.code}, message = ${data.message}`);
}
Defensive patterns

Strategy: retry

Validate before calling

// Confirm the uid exists and the bangumi list is public before subscribing.
import got from '@/utils/got';
async function bangumiListAccessible(uid: string, type: number) {
  const { data } = await got(`https://api.bilibili.com/x/space/bangumi/follow/list`, {
    searchParams: { type, follow_status: 0, pn: 1, ps: 1, vmid: uid },
    headers: { Referer: `https://space.bilibili.com/${uid}/bangumi` },
  });
  return data.code === 0;
}

Type guard

interface BangumiEnv<T> { code: number; message?: string; data?: { list?: T[] } }
function isBangumiOk<T>(r: BangumiEnv<T>): r is BangumiEnv<T> & { code: 0 } { return r.code === 0; }

Try / catch

try {
  if (data.code !== 0) throw new Error(`code=${data.code} message=${data.message}`);
} catch (e) {
  const m = e instanceof Error ? e.message : '';
  if (m.includes('-403')) throw new Error(`User ${uid}'s bangumi list is private`);
  if (m.includes('-352') || m.includes('-799')) await backoffRetry();
  throw e;
}

Prevention

When it happens

Trigger: GET /bilibili/user/bangumi/:uid where the target user hid their follow list (code -403), the uid does not exist, or Bilibili returned risk-control code -352 because the call lacks a Cookie/wbi signature. The route uses got() with only a Referer header and no Cookie, so it is more exposed to anti-crawler blocks.

Common situations: Target user set their bangumi list to private; RSSHub IP flagged by anti-crawler; bilibili now requires wbi signing on this endpoint which the route does not perform; uid typo.

Related errors


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