diff --git a/lib/routes/pixiv/search.ts b/lib/routes/pixiv/search.ts index 315da57f2..f0ea18a99 100644 --- a/lib/routes/pixiv/search.ts +++ b/lib/routes/pixiv/search.ts @@ -9,7 +9,7 @@ import { parseDate } from '@/utils/parse-date'; import ConfigNotFoundError from '@/errors/types/config-not-found'; export const route: Route = { - path: '/search/:keyword/:order?/:mode?', + path: '/search/:keyword/:order?/:mode?/:include_ai?', categories: ['social-media', 'popular'], view: ViewType.Pictures, example: '/pixiv/search/Nezuko/popular', @@ -47,6 +47,20 @@ export const route: Route = { }, ], }, + include_ai: { + description: 'whether AI-generated content is included', + default: 'yes', + options: [ + { + label: 'does not include AI-generated content', + value: 'no', + }, + { + label: 'include AI-generated content', + value: 'yes', + }, + ], + }, }, features: { requireConfig: false, @@ -69,6 +83,7 @@ async function handler(ctx) { const keyword = ctx.req.param('keyword'); const order = ctx.req.param('order') || 'date'; const mode = ctx.req.param('mode'); + const includeAI = ctx.req.param('include_ai'); const token = await getToken(cache.tryGet); if (!token) { @@ -84,6 +99,10 @@ async function handler(ctx) { illusts = illusts.filter((item) => item.x_restrict === 1); } + if (includeAI === 'no' || includeAI === '0') { + illusts = illusts.filter((item) => item.illust_ai_type <= 1); + } + return { title: `${keyword} 的 pixiv ${order === 'popular' ? '热门' : ''}内容`, link: `https://www.pixiv.net/tags/${keyword}/artworks`,