Files
katelyatv/src/app/api/hot-comments/route.ts
T
3970260761 54fdea4f84
Docker Build & Test / build (push) Canceled after 0s
Docker Build & Test / test (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/amd64) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm/v7) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm64) (push) Canceled after 0s
Build & Push Docker image / merge-images (push) Canceled after 0s
Release / release (push) Canceled after 0s
Release / docker (push) Canceled after 0s
fixed73: 通知切授权公告+右上角版本号全页显示
- 首页旧公告弹窗彻底拆除(page.tsx: 删JSX/useSite/showAnnouncement/handleCloseAnnouncement残留)
- layout授权覆盖顺序修复: 先getConfig再hub.getNotice覆盖, 授权公告优先
- HubBell只发open-hub-notice事件, 不再清hasSeenAnnouncement/跳首页
- HubNotice支持铃铛手动打开: 公告/首条/版本兜底, 空指针修复
- 版本号三处补齐: TopRightButtons bar+float, MobileHeader移动端, 对齐fixed73
2026-11-08 00:19:48 +08:00

68 lines
2.2 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server';
export const dynamic = 'force-dynamic';
const SEARXNG = process.env.SEARXNG_URL || 'http://192.168.68.19:4000';
interface HotComment {
title: string;
content: string;
url: string;
source: string;
}
// 评论聚合:SearXNG 全网搜“片名+评价/影评/观后感”,正文长的优先,取前 10 条
export async function GET(req: NextRequest) {
const { searchParams } = new URL(req.url);
const title = (searchParams.get('title') || '').trim();
if (!title) return NextResponse.json({ code: 0, msg: '缺少片名', list: [] });
const queries = [`${title} 评价`, `${title} 影评 观后感`];
const seen = new Set<string>();
const out: HotComment[] = [];
for (const q of queries) {
if (out.length >= 10) break;
let d: any = null;
try {
const r = await fetch(
`${SEARXNG}/search?q=${encodeURIComponent(q)}&format=json&language=zh-CN`,
{ signal: AbortSignal.timeout(15000) }
);
if (!r.ok) continue;
d = await r.json();
} catch {
continue;
}
const results: any[] = Array.isArray(d?.results) ? d.results : [];
// 正文长的优先(一般是真实影评),顺带过滤纯导航/下载站
results.sort(
(a, b) => String(b?.content || '').length - String(a?.content || '').length
);
for (const x of results) {
if (out.length >= 10) break;
const url: string = String(x?.url || '');
const content: string = String(x?.content || '').replace(/\s+/g, ' ').trim();
if (!url || !content || content.length < 40) continue;
if (/rarbg|torrent|magnet|bt\.| JAV|javhd|porn|赌场|博彩|贷款/i.test(url + content)) continue;
let host = '';
try {
host = new URL(url).hostname.replace(/^www\.|^m\.|^wap\./, '');
} catch {
continue;
}
const key = host + '|' + content.slice(0, 60);
if (seen.has(key)) continue;
seen.add(key);
out.push({
title: String(x?.title || host).slice(0, 80),
content: content.slice(0, 600),
url,
source: host,
});
}
}
return NextResponse.json({ code: 1, msg: 'ok', list: out.slice(0, 10) });
}