From 42dfd5cc8166f8bbf555f74eb242c18ae5bf2875 Mon Sep 17 00:00:00 2001 From: x2009again Date: Thu, 21 Apr 2022 23:18:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20=E5=A2=9E=E5=8A=A0=E5=BE=AE?= =?UTF-8?q?=E8=AF=AD=E7=AE=80=E6=8A=A5=E6=BA=90=20(#9577)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 添加微语简报源 * 精简列表描述 * 优化微语简报排版,增加文档说明 * 修复部分序号错误问题 * 增加v2版微语简报源 * 时区修改 * 删除微语简报旧路由 * 按建议修改 * 修改微语简报网址 --- docs/new-media.md | 6 ++++++ lib/v2/yunspe/maintainer.js | 3 +++ lib/v2/yunspe/newsflash.js | 42 +++++++++++++++++++++++++++++++++++++ lib/v2/yunspe/radar.js | 13 ++++++++++++ lib/v2/yunspe/router.js | 3 +++ 5 files changed, 67 insertions(+) create mode 100644 lib/v2/yunspe/maintainer.js create mode 100644 lib/v2/yunspe/newsflash.js create mode 100644 lib/v2/yunspe/radar.js create mode 100644 lib/v2/yunspe/router.js diff --git a/docs/new-media.md b/docs/new-media.md index 828d86813..e196f0ea1 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -3995,3 +3995,9 @@ QueryString: | | zh-hk | zh-tw | + +## 云奇网 + +### 微语简报 + + diff --git a/lib/v2/yunspe/maintainer.js b/lib/v2/yunspe/maintainer.js new file mode 100644 index 000000000..53e4b251c --- /dev/null +++ b/lib/v2/yunspe/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/newsflash': ['x2009again'], +}; diff --git a/lib/v2/yunspe/newsflash.js b/lib/v2/yunspe/newsflash.js new file mode 100644 index 000000000..c1402811b --- /dev/null +++ b/lib/v2/yunspe/newsflash.js @@ -0,0 +1,42 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +module.exports = async (ctx) => { + const response = await got({ + method: 'post', + url: 'https://www.yunspe.com/wp-json/b2/v1/getNewsflashesList', + headers: { + Referer: 'https://www.yunspe.com/newsflashes', + 'content-type': 'application/x-www-form-urlencoded', + }, + body: 'paged=1&term=0&post_paged=1', + }); + const data = response.data.data; + + const out = data.map((item) => { + const title = item[0].title.replace('【微语简报】', ''); + const link = item[0].link; + const datematch = item[0]._date.match(/datetime="(.*)" itemprop/); + const date = datematch && datematch[1]; + const description = item[0].content + .substring(item[0].content.indexOf('【今日简报】') + 6) + .replace(/(\d*\.\s)|(【)/g, '
$1$2') + .substring(4); + + const single = { + title, + link, + pubDate: date && timezone(parseDate(date, 'YYYY-M-D H:mm:ss'), +8), + description, + }; + + return single; + }); + ctx.state.data = { + title: '微语简报', + link: 'https://www.yunspe.com/newsflashes', + description: '微语简报', + item: out, + }; +}; diff --git a/lib/v2/yunspe/radar.js b/lib/v2/yunspe/radar.js new file mode 100644 index 000000000..28c821545 --- /dev/null +++ b/lib/v2/yunspe/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'yunspe.com': { + _name: '云奇网', + '.': [ + { + title: '微语简报', + docs: 'https://docs.rsshub.app/new-media.html#wei-yu-jian-bao', + source: ['/newsflashes/微语简报', '/newsflashes', '/'], + target: '/yunspe/newsflashes', + }, + ], + }, +}; diff --git a/lib/v2/yunspe/router.js b/lib/v2/yunspe/router.js new file mode 100644 index 000000000..5dff2f4fa --- /dev/null +++ b/lib/v2/yunspe/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/newsflash', require('./newsflash')); +};