feat(route): add MyGoPen (#8484)

This commit is contained in:
Ethan Shen 2021-11-27 16:50:29 +08:00 committed by GitHub
parent 798aa9157f
commit 119b07a3e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 0 deletions

View File

@ -661,6 +661,17 @@ IPFS 网关有可能失效,那时候换成其他网关。
<Route author="EsuRt queensferryme" example="/mittrchina/hot" path="/mittrchina/:type" :paramsDesc="['类型 type可以是 index首页资讯或 hot本周热榜']"/>
## MyGoPen
### 分類
<Route author="nczitzk" example="/mygopen" path="/mygopen/:label?" :paramsDesc="['分類,见下表,默认为首页']">
| 謠言 | 詐騙 | 真實資訊 | 教學 |
| ---- | ---- | -------- | ---- |
</Route>
## Nautilus
### 话题

29
lib/v2/mygopen/index.js Normal file
View File

@ -0,0 +1,29 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const label = ctx.params.label ?? '';
const rootUrl = 'https://www.mygopen.com';
const currentUrl = `${rootUrl}${label ? `/search/label/${label}` : ''}`;
const apiUrl = `${rootUrl}/feeds/posts/default${label ? `/-/${label}` : ''}?alt=json-in-script&max-results=${ctx.query.limit ? parseInt(ctx.query.limit) : 50}`;
const response = await got({
method: 'get',
url: apiUrl,
});
const items = JSON.parse(response.data.match(/gdata\.io\.handleScriptLoaded\((.*)\);/)[1]).feed.entry.map((item) => ({
title: item.title.$t,
description: item.content.$t,
pubDate: parseDate(item.published.$t),
link: item.link.pop().href,
}));
ctx.state.data = {
title: `MyGoPen${label ? `: ${label}` : ''}`,
link: currentUrl,
item: items,
description: '詐騙與謠言頻傳的年代「MyGoPen這是假消息」提醒網路使用者隨時要用謹慎懷疑的態度面對網路上的消息。',
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/:label?': ['nczitzk'],
};

13
lib/v2/mygopen/radar.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
'mygopen.com': {
_name: 'MyGoPen',
'.': [
{
title: '分類',
docs: 'https://docs.rsshub.app/new-media.html#mygopen-fen-lei',
source: ['/search/label/:label', '/'],
target: '/mygopen/:label?',
},
],
},
};

3
lib/v2/mygopen/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:label?', require('./index'));
};