From 1dd268c1b17b60716a79bce11086ac560f6e408a Mon Sep 17 00:00:00 2001
From: momizi <56447020+shinanory@users.noreply.github.com>
Date: Sun, 7 May 2023 22:27:45 +0800
Subject: [PATCH 1/4] =?UTF-8?q?feat(route):=20=E6=96=B0=E5=A2=9E=E5=B4=A9?=
=?UTF-8?q?=E5=9D=8F=E6=98=9F=E7=A9=B9=E9=93=81=E9=81=93=E8=AE=A2=E9=98=85?=
=?UTF-8?q?=20(#12466)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 崩坏星穹铁道
* 修改
* 修改调整
* 新增星穹铁道国际服
---
docs/game.md | 12 ++++++
lib/v2/mihoyo/maintainer.js | 1 +
lib/v2/mihoyo/radar.js | 16 ++++++++
lib/v2/mihoyo/router.js | 1 +
lib/v2/mihoyo/sr/news.js | 74 +++++++++++++++++++++++++++++++++++++
5 files changed, 104 insertions(+)
create mode 100644 lib/v2/mihoyo/sr/news.js
diff --git a/docs/game.md b/docs/game.md
index ef6837f68bb0cd..46a637cd3a01d6 100644
--- a/docs/game.md
+++ b/docs/game.md
@@ -701,6 +701,18 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547`
+### 崩坏:星穹铁道
+
+#### 新闻
+
+
+
+| 最新 | 新闻 | 公告 | 活动 |
+| -------- | ---- | ------ | -------- |
+| news-all | news | notice | activity |
+
+
+
## 明日方舟
### 游戏公告与新闻
diff --git a/lib/v2/mihoyo/maintainer.js b/lib/v2/mihoyo/maintainer.js
index 1346058213b94d..4d7a38452c7896 100644
--- a/lib/v2/mihoyo/maintainer.js
+++ b/lib/v2/mihoyo/maintainer.js
@@ -1,4 +1,5 @@
module.exports = {
'/bbs/official/:gids/:type?/:page_size?/:last_id?': ['CaoMeiYouRen'],
+ '/sr/:location?/:category?': ['shinanory'],
'/ys/:location?/:category?': ['nczitzk'],
};
diff --git a/lib/v2/mihoyo/radar.js b/lib/v2/mihoyo/radar.js
index a4d14a88d87ac3..5888de9de6df90 100644
--- a/lib/v2/mihoyo/radar.js
+++ b/lib/v2/mihoyo/radar.js
@@ -9,6 +9,14 @@ module.exports = {
target: '/mihoyo/ys/:location',
},
],
+ hsr: [
+ {
+ title: '崩坏:星穹铁道 - 新闻',
+ docs: 'https://docs.rsshub.app/game.html##mi-ha-you',
+ source: '/:location/news',
+ target: '/mihoyo/sr/:location'
+ },
+ ]
},
'mihoyo.com': {
_name: '米哈游',
@@ -38,6 +46,14 @@ module.exports = {
},
},
],
+ sr: [
+ {
+ title: '崩坏:星穹铁道 - 新闻',
+ docs: 'https://docs.rsshub.app/game.html##mi-ha-you',
+ source: '/news',
+ target: '/mihoyo/sr'
+ },
+ ],
ys: [
{
title: '原神 - 新闻',
diff --git a/lib/v2/mihoyo/router.js b/lib/v2/mihoyo/router.js
index 1e16b7cb2ee21e..e6933cfbef6d3d 100644
--- a/lib/v2/mihoyo/router.js
+++ b/lib/v2/mihoyo/router.js
@@ -1,4 +1,5 @@
module.exports = function (router) {
router.get('/bbs/official/:gids/:type?/:page_size?/:last_id?', require('./bbs'));
+ router.get('/sr/:location?/:category?', require('./sr/news'));
router.get('/ys/:location?/:category?', require('./ys/news'));
};
diff --git a/lib/v2/mihoyo/sr/news.js b/lib/v2/mihoyo/sr/news.js
new file mode 100644
index 00000000000000..cf3bc23e881dc4
--- /dev/null
+++ b/lib/v2/mihoyo/sr/news.js
@@ -0,0 +1,74 @@
+const got = require('@/utils/got');
+const { parseDate } = require('@/utils/parse-date');
+
+const categories = {
+ 'zh-cn':{
+ 'news-all':{
+ id: '255',
+ title: '最新',
+ },
+ news:{
+ id: '256',
+ title: '新闻'
+ },
+ notice:{
+ id: '257',
+ title: '公告',
+ },
+ activity:{
+ id: '258',
+ title: '活动',
+ },
+ link: 'https://sr.mihoyo.com/news',
+ },
+ 'zh-tw':{
+ 'news-all':{
+ id: '248',
+ title: '最新',
+ },
+ news:{
+ id: '249',
+ title: '資訊'
+ },
+ notice:{
+ id: '250',
+ title: '公告',
+ },
+ activity:{
+ id: '251',
+ title: '活動',
+ },
+ link: 'https://hsr.hoyoverse.com/zh-tw/news',
+ },
+};
+
+module.exports = async (ctx) => {
+ // location 地区 category 类型
+ const { location = 'zh-cn', category = 'news-all' } = ctx.params;
+ const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 50;
+ let url = '';
+ if (location === 'zh-cn')
+ {
+ url = `https://api-takumi-static.mihoyo.com/content_v2_user/app/1963de8dc19e461c/getContentList?iPage=1&iPageSize=${limit}&sLangKey=zh-cn&isPreview=0&iChanId=${categories[location][category].id}`;
+ }
+ else
+ {
+ url = `https://api-os-takumi-static.hoyoverse.com/content_v2_user/app/113fe6d3b4514cdd/getContentList?iPage=1&iPageSize=${limit}&sLangKey=${location}&isPreview=0&iChanId=${categories[location][category].id}`;
+ };
+
+ const response = await got(url);
+ const list = response.data.data.list;
+ const items = list.map((item) => ({
+ title: item.sTitle,
+ description: item.sContent,
+ link: `${categories[location].link}/${item.iInfoId}`,
+ pubDate: parseDate(item.dtStartTime),
+ category: item.sCategoryName
+ }));
+
+ ctx.state.data = {
+ title: `${categories[location][category].title}-崩坏:星穹铁道`,
+ link: url,
+ item: items,
+ };
+};
\ No newline at end of file
From 6083aa9a9afe5d9ea48207a85eac6e0522f1aa2d Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Sun, 7 May 2023 14:30:13 +0000
Subject: [PATCH 2/4] style: auto format
---
docs/game.md | 2 +-
lib/v2/mihoyo/radar.js | 6 ++---
lib/v2/mihoyo/sr/news.js | 47 +++++++++++++++++++---------------------
3 files changed, 26 insertions(+), 29 deletions(-)
diff --git a/docs/game.md b/docs/game.md
index 46a637cd3a01d6..577afd0baecada 100644
--- a/docs/game.md
+++ b/docs/game.md
@@ -707,7 +707,7 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547`
-| 最新 | 新闻 | 公告 | 活动 |
+| 最新 | 新闻 | 公告 | 活动 |
| -------- | ---- | ------ | -------- |
| news-all | news | notice | activity |
diff --git a/lib/v2/mihoyo/radar.js b/lib/v2/mihoyo/radar.js
index 5888de9de6df90..40e1df7783a308 100644
--- a/lib/v2/mihoyo/radar.js
+++ b/lib/v2/mihoyo/radar.js
@@ -14,9 +14,9 @@ module.exports = {
title: '崩坏:星穹铁道 - 新闻',
docs: 'https://docs.rsshub.app/game.html##mi-ha-you',
source: '/:location/news',
- target: '/mihoyo/sr/:location'
+ target: '/mihoyo/sr/:location',
},
- ]
+ ],
},
'mihoyo.com': {
_name: '米哈游',
@@ -51,7 +51,7 @@ module.exports = {
title: '崩坏:星穹铁道 - 新闻',
docs: 'https://docs.rsshub.app/game.html##mi-ha-you',
source: '/news',
- target: '/mihoyo/sr'
+ target: '/mihoyo/sr',
},
],
ys: [
diff --git a/lib/v2/mihoyo/sr/news.js b/lib/v2/mihoyo/sr/news.js
index cf3bc23e881dc4..19a258ea71e3f7 100644
--- a/lib/v2/mihoyo/sr/news.js
+++ b/lib/v2/mihoyo/sr/news.js
@@ -2,39 +2,39 @@ const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const categories = {
- 'zh-cn':{
- 'news-all':{
+ 'zh-cn': {
+ 'news-all': {
id: '255',
title: '最新',
},
- news:{
+ news: {
id: '256',
- title: '新闻'
+ title: '新闻',
},
- notice:{
+ notice: {
id: '257',
title: '公告',
},
- activity:{
+ activity: {
id: '258',
title: '活动',
},
link: 'https://sr.mihoyo.com/news',
},
- 'zh-tw':{
- 'news-all':{
+ 'zh-tw': {
+ 'news-all': {
id: '248',
title: '最新',
},
- news:{
+ news: {
id: '249',
- title: '資訊'
+ title: '資訊',
},
- notice:{
+ notice: {
id: '250',
title: '公告',
},
- activity:{
+ activity: {
id: '251',
title: '活動',
},
@@ -47,28 +47,25 @@ module.exports = async (ctx) => {
const { location = 'zh-cn', category = 'news-all' } = ctx.params;
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 50;
let url = '';
- if (location === 'zh-cn')
- {
+ if (location === 'zh-cn') {
url = `https://api-takumi-static.mihoyo.com/content_v2_user/app/1963de8dc19e461c/getContentList?iPage=1&iPageSize=${limit}&sLangKey=zh-cn&isPreview=0&iChanId=${categories[location][category].id}`;
- }
- else
- {
+ } else {
url = `https://api-os-takumi-static.hoyoverse.com/content_v2_user/app/113fe6d3b4514cdd/getContentList?iPage=1&iPageSize=${limit}&sLangKey=${location}&isPreview=0&iChanId=${categories[location][category].id}`;
- };
+ }
const response = await got(url);
const list = response.data.data.list;
const items = list.map((item) => ({
- title: item.sTitle,
- description: item.sContent,
- link: `${categories[location].link}/${item.iInfoId}`,
- pubDate: parseDate(item.dtStartTime),
- category: item.sCategoryName
- }));
+ title: item.sTitle,
+ description: item.sContent,
+ link: `${categories[location].link}/${item.iInfoId}`,
+ pubDate: parseDate(item.dtStartTime),
+ category: item.sCategoryName,
+ }));
ctx.state.data = {
title: `${categories[location][category].title}-崩坏:星穹铁道`,
link: url,
item: items,
};
-};
\ No newline at end of file
+};
From c93e63559a6ca05e93845c74c0ff7944591fab21 Mon Sep 17 00:00:00 2001
From: drgnchan <40224023+drgnchan@users.noreply.github.com>
Date: Mon, 8 May 2023 02:35:44 +0800
Subject: [PATCH 3/4] =?UTF-8?q?feat(route):=20=E6=96=B0=E5=A2=9E=E7=BD=91?=
=?UTF-8?q?=E4=BF=A1=E5=8A=9E=E8=AE=A2=E9=98=85=20(#12444)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat(route): 新增网信办订阅
* refactor: 时区设置
* polish
* polish
* refactor: cache path map
---
docs/government.md | 17 +++++++++++
lib/v2/gov/cac/index.js | 64 ++++++++++++++++++++++++++++++++++++++++
lib/v2/gov/maintainer.js | 1 +
lib/v2/gov/radar.js | 11 +++++++
lib/v2/gov/router.js | 1 +
5 files changed, 94 insertions(+)
create mode 100644 lib/v2/gov/cac/index.js
diff --git a/docs/government.md b/docs/government.md
index 08ebe3ae676768..ad419b470492a8 100644
--- a/docs/government.md
+++ b/docs/government.md
@@ -1634,3 +1634,20 @@ pageClass: routes
:::
+
+## 中央网信办
+
+### 分类
+
+
+
+::: tip 提示
+
+路径填写对应页面 URL 中间部分。例如:
+
+首页 > 权威发布 > 办公室发布:
+此时,path 参数为:/qwfb/bgsfb
+
+:::
+
+
diff --git a/lib/v2/gov/cac/index.js b/lib/v2/gov/cac/index.js
new file mode 100644
index 00000000000000..e7cbc1ffd84c3f
--- /dev/null
+++ b/lib/v2/gov/cac/index.js
@@ -0,0 +1,64 @@
+const got = require('@/utils/got');
+const cheerio = require('cheerio');
+const { parseDate } = require('@/utils/parse-date');
+const timezone = require('@/utils/timezone');
+const config = require('@/config').value;
+
+module.exports = async (ctx) => {
+ const path = ctx.params[0];
+ const host = 'http://www.cac.gov.cn';
+ const homepage = `${host}/index.htm`;
+ // 在首页查找出所有的目录完整路径,比如http://www.cac.gov.cn/xxh/A0906index_1.htm
+ // xxh --> {"path": "/xxh", "completeUrl": "http://www.cac.gov.cn/xxh/A0906index_1.htm"}
+ const pathList = await ctx.cache.tryGet(
+ 'gov:cac:pathList',
+ async () => {
+ const { data: homepageResponse } = await got(homepage);
+ const $ = cheerio.load(homepageResponse);
+ return $('a')
+ .toArray()
+ .map((item) => {
+ const href = $(item).attr('href');
+ if (href && href.startsWith('http://www.cac.gov.cn/')) {
+ const matchArray = href.match(/http:\/\/www\.cac\.gov\.cn(.*?)\/(A.*?\.htm)/);
+ if (matchArray && matchArray.length > 2) {
+ const path = matchArray[1];
+ const htmlName = matchArray[2];
+ return {
+ path,
+ completeUrl: `${host}${path}/${htmlName}`,
+ };
+ }
+ }
+ return null;
+ })
+ .filter((item) => item);
+ },
+ config.cache.routeExpire,
+ false,
+ );
+
+ const completeUrl = pathList.find((item) => item && item.path === path).completeUrl;
+ const { data: channelResponse } = await got(completeUrl);
+ const $1 = cheerio.load(channelResponse);
+ const items = $1('li.clearfix')
+ .toArray()
+ .map((item) => {
+ const c = $1(item);
+ const a = c.find('a');
+ const articleHref = a.attr('href');
+ const title = a.text();
+ const date = parseDate(c.find('span.times').text());
+ return {
+ link: articleHref,
+ pubDate: timezone(date),
+ title,
+ description: title,
+ };
+ });
+ ctx.state.data = {
+ title: $1('head title').text(),
+ link: completeUrl,
+ item: items,
+ };
+};
diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js
index 7430e6c34afc92..95610711b5bc2b 100644
--- a/lib/v2/gov/maintainer.js
+++ b/lib/v2/gov/maintainer.js
@@ -1,5 +1,6 @@
module.exports = {
// ministry
+ '/cac/:path+': ['drgnchan'],
'/ccdi/:path+': ['bigfei'],
'/cmse/xwzx/zhxw': ['nczitzk'],
'/cmse/xwzx/yzjz': ['nczitzk'],
diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js
index d1355eee1db66f..535cd8dbc468f7 100644
--- a/lib/v2/gov/radar.js
+++ b/lib/v2/gov/radar.js
@@ -308,6 +308,17 @@ module.exports = {
},
],
},
+ 'cac.gov.cn': {
+ _name: '中央网信办',
+ '.': [
+ {
+ title: '分类',
+ docs: 'https://docs.rsshub.app/government.html#zhong-yang-wang-xin-ban',
+ source: ['/*'],
+ target: (params, url) => `/gov/cac/${new URL(url).href.match(/cac\.gov\.cn(.*?)\/(A.*?\.htm)/)[1]}`,
+ },
+ ],
+ },
'ccdi.gov.cn': {
_name: '中央纪委国家监委',
www: [
diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js
index 94140dbe0c8d69..a82b03e2242707 100644
--- a/lib/v2/gov/router.js
+++ b/lib/v2/gov/router.js
@@ -1,5 +1,6 @@
module.exports = function (router) {
// ministry
+ router.get(/cac(\/[\w/-]+)?/, require('./cac/index'));
router.get(/ccdi(\/[\w/-]+)?/, require('./ccdi'));
router.get('/cmse/fxrw', require('./cmse/fxrw'));
router.get(/cmse(\/[\w/-]+)?/, require('./cmse'));
From 3450e4c5ba5e5b36f614c8791a395beb2a26f0ce Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Sun, 7 May 2023 18:38:24 +0000
Subject: [PATCH 4/4] style: auto format
---
lib/v2/gov/cac/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/v2/gov/cac/index.js b/lib/v2/gov/cac/index.js
index e7cbc1ffd84c3f..ac6b9060c527ea 100644
--- a/lib/v2/gov/cac/index.js
+++ b/lib/v2/gov/cac/index.js
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
.filter((item) => item);
},
config.cache.routeExpire,
- false,
+ false
);
const completeUrl = pathList.find((item) => item && item.path === path).completeUrl;