diff --git a/lib/router.js b/lib/router.js index ccc3a1bf3..0661dad13 100644 --- a/lib/router.js +++ b/lib/router.js @@ -992,11 +992,6 @@ router.get('/ddrk/index', lazyloadRouteHandler('./routes/ddrk/list')); router.get('/avgle/videos/:order?/:time?/:top?', lazyloadRouteHandler('./routes/avgle/videos.js')); router.get('/avgle/search/:keyword/:order?/:time?/:top?', lazyloadRouteHandler('./routes/avgle/videos.js')); -// 公主链接公告 -// router.get('/pcr/news', lazyloadRouteHandler('./routes/pcr/news')); -router.get('/pcr/news-tw', lazyloadRouteHandler('./routes/pcr/news-tw')); -router.get('/pcr/news-cn', lazyloadRouteHandler('./routes/pcr/news-cn')); - // project-zero issues router.get('/project-zero-issues', lazyloadRouteHandler('./routes/project-zero-issues/index')); diff --git a/lib/routes-deprecated/pcr/news-cn.js b/lib/routes-deprecated/pcr/news-cn.js deleted file mode 100644 index 55986a9d1..000000000 --- a/lib/routes-deprecated/pcr/news-cn.js +++ /dev/null @@ -1,28 +0,0 @@ -const got = require('@/utils/got'); - -module.exports = async (ctx) => { - const response = await got({ - method: 'get', - url: `https://api.biligame.com/news/list?gameExtensionId=267&positionId=2&typeId=&pageNum=1&pageSize=5`, - }); - const data = response.data; - ctx.state.data = { - title: '公主链接国服-最新公告', - link: 'https://game.bilibili.com/pcr/news.html', - item: data - ? await Promise.all( - data.data.map(async (item) => ({ - title: item.title, - description: await ctx.cache.tryGet(`pcrcn_${item.id}`, async () => { - const resp = await got({ method: 'get', url: `https://api.biligame.com/news/${item.id}` }); - return resp.data.data.content; - }), - link: `https://game.bilibili.com/pcr/news.html#detail=${item.id}`, - pubDate: item.ctime ?? item.createTime, - })) - ) - : { - title: '获取失败!', - }, - }; -}; diff --git a/lib/routes-deprecated/pcr/news-tw.js b/lib/routes-deprecated/pcr/news-tw.js deleted file mode 100644 index 327cbfbc2..000000000 --- a/lib/routes-deprecated/pcr/news-tw.js +++ /dev/null @@ -1,67 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -const base = 'http://www.princessconnect.so-net.tw'; - -module.exports = async (ctx) => { - const url = `${base}/news`; - - const list_response = await got.get(url); - const $ = cheerio.load(list_response.data); - - const list = $('.news_con dl dd').get(); - - const parseContent = (htmlString) => { - const $ = cheerio.load(htmlString); - - $('.news_con h2 > span').remove(); - const time = $('.news_con h2').text().trim(); - $('.news_con section h4').first().remove(); - const content = $('.news_con section'); - - return { - description: content.html(), - pubDate: new Date(time), - }; - }; - - const out = await Promise.all( - list.map(async (item) => { - const $ = cheerio.load(item); - - const title = $('a'); - const path = title.attr('href'); - - const link = base + path; - - const cache = await ctx.cache.get(link); - if (cache) { - return JSON.parse(cache); - } - - const rssitem = { - title: title.text().trim(), - link, - }; - - try { - const response = await got.get(link); - const result = parseContent(response.data); - - rssitem.author = '《超異域公主連結☆Re:Dive》營運團隊'; - rssitem.description = result.description; - rssitem.pubDate = result.pubDate; - } catch { - return ''; - } - ctx.cache.set(link, JSON.stringify(rssitem)); - return rssitem; - }) - ); - - ctx.state.data = { - title: '公主连结 - 台服公告', - link: url, - item: out.filter((item) => item !== ''), - }; -}; diff --git a/lib/routes/priconne-redive/news.ts b/lib/routes/priconne-redive/news.ts index 5c6fe7349..278885b82 100644 --- a/lib/routes/priconne-redive/news.ts +++ b/lib/routes/priconne-redive/news.ts @@ -5,10 +5,10 @@ import cache from '@/utils/cache'; import { load } from 'cheerio'; export const route: Route = { - path: '/news/:location?', + path: '/news/:server?', categories: ['game'], example: '/priconne-redive/news', - parameters: { location: '区域,默认日服' }, + parameters: { server: '服务器,默认日服' }, features: { requireConfig: false, requirePuppeteer: false, @@ -20,23 +20,32 @@ export const route: Route = { radar: [ { source: ['priconne-redive.jp/news'], + target: '/news/jp', + }, + { + source: ['princessconnect.so-net.tw/news'], + target: '/news/zh-tw', + }, + { + source: ['game.bilibili.com/pcr/news.html'], + target: '/news/zh-cn', }, ], name: '最新公告', maintainers: ['SayaSS', 'frankcwl'], handler, url: 'priconne-redive.jp/news', - description: `location + description: `服务器 - | 国服 | 台服 | 日服 | - | ----- | ----- | ---- | - | zh-cn | zh-tw | jp |`, + | 国服 | 台服 | 日服 | + | ----- | ----- | ---- | + | zh-cn | zh-tw | jp |`, }; async function handler(ctx) { - const { location = 'jp' } = ctx.req.param(); + const { server = 'jp' } = ctx.req.param(); - switch (location) { + switch (server) { case 'jp': { const parseContent = (htmlString) => { const $ = load(htmlString);