From 961636aebdcfe3965521821f67eff9dad4e9ffe7 Mon Sep 17 00:00:00 2001 From: Toby Tso Date: Tue, 29 Dec 2020 19:59:57 +0800 Subject: [PATCH] WIP: add Media Digest --- docs/traditional-media.md | 17 +++++++++++++++++ lib/routes/mediadigest/category.js | 14 ++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/docs/traditional-media.md b/docs/traditional-media.md index c9347c4f1..ec3c01e65 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -957,3 +957,20 @@ category 对应的关键词有 ### 九江新闻 + +### RTHK 傳媒透視 + + + +细则: + +- `:range` 时间范围参数 + (可为 `latest` 或 `四位数字的年份`) + + - `latest`: 最新的 50 篇文章 + - `2020`: 2020 年的所有文章 + +- 全文输出转换为简体字: `?opencc=t2s` + (`opencc` 是 RSSHub 的通用参数,详情请参阅 [「中文简繁体转换」](https://docs.rsshub.app/parameter.html#zhong-wen-jian-fan-ti-zhuan-huan)) + + diff --git a/lib/routes/mediadigest/category.js b/lib/routes/mediadigest/category.js index 3fae548b7..9c41c61b7 100644 --- a/lib/routes/mediadigest/category.js +++ b/lib/routes/mediadigest/category.js @@ -39,10 +39,11 @@ module.exports = async (ctx) => { // for range validation const num = /^[1-9][0-9]{3}$/; const current_year = new Date().getFullYear(); - // placeholder for rss + // placeholders + let title = '傳媒透視'; let rss = [ { - description: '

Invalid :category? input.

所輸入:category?參數有誤。

所输入:category?参数有误。

', + description: '

Invalid :range input.

所輸入:range參數有誤。

所输入:range参数有误。

', }, ]; // cid @@ -53,7 +54,7 @@ module.exports = async (ctx) => { // latest (50 articles): // if 'all' (latest 50 articles of the site); - // else if 'cid' (all articles of a specific category); + // else if 'cid' (deprecated) (latest 50 articles of a specific category); // else 'error'. if (range === 'latest') { if (category === 'all') { @@ -91,7 +92,7 @@ module.exports = async (ctx) => { } } // year (specific year range): - // if 'all' (all articles in a specific year range); + // if 'all' (latest 200 articles in a specific year range); // else 'error'. else if (num.test(range)) { const range_num = parseInt(range); @@ -117,12 +118,13 @@ module.exports = async (ctx) => { }) ); const list = [...new Set(list_all.flat())]; // removed duplicates and flatten - rss = await getArticle(ctx, list.slice(0, 50)); + rss = await getArticle(ctx, list.slice(0, 200)); + title = `傳媒透視 - ${range}`; } } ctx.state.data = { - title: '傳媒透視', + title: title, link: 'https://app3.rthk.hk/mediadigest/index.php', item: rss, };