DIYgod/RSSHub · warning

Bad category. See <a href="https://docs.rsshub.app/routes/ne

Error message

Bad category. See <a href="https://docs.rsshub.app/routes/new-media#mei-hua-wang-zuo-pin">docs</a>

What it means

Thrown by the Meihua shots (作品) route (deprecated) when :caty is not a config key. Config maps slugs (e.g. a 'latest' key → shots!2!0!0!0!0 最新, hot → shots!3!0!0!0!0 热门) to multi-field tokens. Miss throws before the scrape and JSON.parse of shotsStore.

Source

Thrown at lib/routes-deprecated/meihua/shots.js:22

const config = {
    recommend: {
        link: 'shots!1!0!0!0!0',
        title: '推荐',
    },
    latest: {
        link: 'shots!2!0!0!0!0',
        title: '最新',
    },
    hot: {
        link: 'shots!3!0!0!0!0',
        title: '热门',
    },
};

module.exports = async (ctx) => {
    const cfg = config[ctx.params.caty];
    if (!cfg) {
        throw new Error('Bad category. See <a href="https://docs.rsshub.app/routes/new-media#mei-hua-wang-zuo-pin">docs</a>');
    }

    const currentUrl = `https://www.meihua.info/${cfg.link}`;
    const response = await got({
        method: 'get',
        url: currentUrl,
    });
    const data = JSON.parse(response.data.match(/"shotsStore":(.*?),"commentStore":/)[1]);

    const shotList = data.shotsData.list.map((item) => ({
        title: item.title,
        link: `https://www.meihua.info/shots/${item.compositionId}`,
        pubDate: new Date(item.gmtPublish).toUTCString(),
    }));

    const items = await Promise.all(
        shotList.map((item) =>
            ctx.cache.tryGet(item.link, async () => {

View on GitHub (pinned to bed535e087)

Solutions

  1. Use a documented slug (e.g. hot).
  2. Confirm keys against the config map at the top of lib/routes-deprecated/meihua/shots.js.
  3. Distinguish this route from meihua/article.js — different config tokens.

Example fix

// before
GET /meihua/shots/latestt   // typo
// after
GET /meihua/shots/hot         // 热门
Defensive patterns

Strategy: validation

Validate before calling

const VALID = ['hot' /* + latest key — see config in lib/routes-deprecated/meihua/shots.js */];
if (!VALID.includes(ctx.params.caty)) throw new Error(`Invalid caty. Valid: ${VALID.join(', ')}`);

Type guard

const isCaty = (v: string): v is 'hot' => v === 'hot';

Try / catch

try { await fetch(route); }
catch (e) {
  if (/Bad category/.test(e.message)) listSlugs();
  else if (/shotsStore/.test(String(e))) reportMarkupChange();
  else throw e;
}

Prevention

When it happens

Trigger: Request with a :caty absent from config; the guard throws.

Common situations: Slug typo, or confusing this route's slugs with the article route's (article! vs shots!). The token format (five !-separated fields) also breaks easily if Meihua changes its filter encoding.

Related errors


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