From ccb708846d4e3d4a416cd1346d1d6c3eca6b36d8 Mon Sep 17 00:00:00 2001 From: Andvari <31068367+dzx-dzx@users.noreply.github.com> Date: Mon, 28 Apr 2025 02:48:18 +0800 Subject: [PATCH] feat(route/copernicium)!: remove route which is no longer valid (#18890) --- lib/routes/copernicium/index.ts | 75 ----------------------------- lib/routes/copernicium/namespace.ts | 7 --- 2 files changed, 82 deletions(-) delete mode 100644 lib/routes/copernicium/index.ts delete mode 100644 lib/routes/copernicium/namespace.ts diff --git a/lib/routes/copernicium/index.ts b/lib/routes/copernicium/index.ts deleted file mode 100644 index d88bc793c..000000000 --- a/lib/routes/copernicium/index.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { Route } from '@/types'; -import ofetch from '@/utils/ofetch'; - -import cache from '@/utils/cache'; -import { load } from 'cheerio'; -import { parseDate } from '@/utils/parse-date'; - -export const route: Route = { - path: '/:category?', - categories: ['new-media'], - radar: [{ source: ['www.copernicium.tw'] }], - name: '分类', - example: '/copernicium/环球视角', - parameters: { category: '分类名' }, - maintainers: ['dzx-dzx'], - handler, -}; - -async function handler(ctx) { - const category = ctx.req.param('category'); - let res; - if (category) { - const CATEGORY_TO_ARG_MAP = new Map([ - ['环球视角', '4_1'], - ['人文叙述', '4_3'], - ['观点评论', '4_5'], - ['专题报道', '4_7'], - ]); - if (!CATEGORY_TO_ARG_MAP.get(category)) { - throw new Error('The requested category does not exist or is not supported.'); - } - const reqArgs = { - args: { - _jcp: CATEGORY_TO_ARG_MAP.get(category), - m31pageno: 1, - }, - type: 0, - }; - res = await ofetch('http://www.copernicium.tw/nr.jsp', { - query: { _reqArgs: reqArgs }, - }); - } else { - res = await ofetch('http://www.copernicium.tw/sys-nr/', { - query: { _reqArgs: { args: {}, type: 15 } }, - }); - } - const $ = load(res); - const list = $('.J_newsResultLine a.mixNewsStyleTitle') - .toArray() - .map((e) => { - e = $(e); - return { - title: e.text(), - link: e.attr('href'), - }; - }); - const items = await Promise.all( - list.map((item) => - cache.tryGet(item.link, async () => { - const detailResponse = await ofetch(item.link); - const content = load(detailResponse); - return { - pubDate: parseDate(content('span.newsInfo').text().substring(5)), - description: content('.richContent').html(), - ...item, - }; - }) - ) - ); - return { - title: `日新说 - ${category ?? '全部文章'}`, - link: 'http://www.copernicium.tw', - item: items, - }; -} diff --git a/lib/routes/copernicium/namespace.ts b/lib/routes/copernicium/namespace.ts deleted file mode 100644 index fe1ccb9ac..000000000 --- a/lib/routes/copernicium/namespace.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { Namespace } from '@/types'; - -export const namespace: Namespace = { - name: '日新说', - url: 'www.copernicium.tw', - lang: 'zh-TW', -};