feat(route): pixiv search filter AI-generated content (#16286)

This commit is contained in:
uhq9e
2024-07-29 20:47:15 +08:00
committed by GitHub
parent 12b45b27e4
commit 783c823d1c
+20 -1
View File
@@ -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`,