mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 14:07:54 +08:00
feat: 添加《香港01》 雷达支持&&添加《香港 01》周报订阅 (#4786)
This commit is contained in:
43
assets/radar-rules.js
Executable file → Normal file
43
assets/radar-rules.js
Executable file → Normal file
@@ -1955,4 +1955,47 @@
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
'hk01.com': {
|
||||||
|
_name: '香港01',
|
||||||
|
www: [
|
||||||
|
{
|
||||||
|
title: '最 Hit',
|
||||||
|
docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01',
|
||||||
|
source: ['/hot', '/'],
|
||||||
|
target: '/hk01/hot',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'zone',
|
||||||
|
docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01',
|
||||||
|
source: '/zone/:id/:title',
|
||||||
|
target: '/hk01/zone/:id',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'channel',
|
||||||
|
docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01',
|
||||||
|
source: '/channel/:id/:title',
|
||||||
|
target: '/hk01/channel/:id',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'issue',
|
||||||
|
docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01',
|
||||||
|
source: '/issue/:id/:title',
|
||||||
|
target: '/hk01/issue/:id',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'tag',
|
||||||
|
docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01',
|
||||||
|
source: '/tag/:id/:title',
|
||||||
|
target: '/hk01/tag/:id',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
ebook: [
|
||||||
|
{
|
||||||
|
title: '《香港01》周报',
|
||||||
|
docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01',
|
||||||
|
source: ['/', '/subscribe'],
|
||||||
|
target: '/hk01/ebook',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -423,23 +423,27 @@ category 对应的关键词有
|
|||||||
|
|
||||||
### 热门
|
### 热门
|
||||||
|
|
||||||
<Route author="hoilc" example="/hk01/hot" path="/hk01/hot" />
|
<Route author="hoilc" example="/hk01/hot" path="/hk01/hot" radar="1"/>
|
||||||
|
|
||||||
### 栏目
|
### 栏目
|
||||||
|
|
||||||
<Route author="hoilc" example="/hk01/zone/11" path="/hk01/zone/:id" :paramsDesc="['栏目id, 可在URL中找到']"/>
|
<Route author="hoilc" example="/hk01/zone/11" path="/hk01/zone/:id" :paramsDesc="['栏目id, 可在URL中找到']" radar="1"/>
|
||||||
|
|
||||||
### 子栏目
|
### 子栏目
|
||||||
|
|
||||||
<Route author="hoilc" example="/hk01/channel/391" path="/hk01/channel/:id" :paramsDesc="['子栏目id, 可在URL中找到']"/>
|
<Route author="hoilc" example="/hk01/channel/391" path="/hk01/channel/:id" :paramsDesc="['子栏目id, 可在URL中找到']" radar="1"/>
|
||||||
|
|
||||||
### 专题
|
### 专题
|
||||||
|
|
||||||
<Route author="hoilc" example="/hk01/issue/649" path="/hk01/issue/:id" :paramsDesc="['专题id, 可在URL中找到']"/>
|
<Route author="hoilc" example="/hk01/issue/649" path="/hk01/issue/:id" :paramsDesc="['专题id, 可在URL中找到']" radar="1"/>
|
||||||
|
|
||||||
### 标签
|
### 标签
|
||||||
|
|
||||||
<Route author="hoilc" example="/hk01/tag/2787" path="/hk01/tag/:id" :paramsDesc="['标签id, 可在URL中找到']"/>
|
<Route author="hoilc" example="/hk01/tag/2787" path="/hk01/tag/:id" :paramsDesc="['标签id, 可在URL中找到']" radar="1"/>
|
||||||
|
|
||||||
|
### 《香港 01》周报
|
||||||
|
|
||||||
|
<Route author="MisteryMonster" example="/hk01/ebook" path="/hk01/ebook" radar="1"/>
|
||||||
|
|
||||||
## 香港電台
|
## 香港電台
|
||||||
|
|
||||||
|
|||||||
@@ -2134,6 +2134,7 @@ router.get('/hk01/channel/:id', require('./routes/hk01/channel'));
|
|||||||
router.get('/hk01/issue/:id', require('./routes/hk01/issue'));
|
router.get('/hk01/issue/:id', require('./routes/hk01/issue'));
|
||||||
router.get('/hk01/tag/:id', require('./routes/hk01/tag'));
|
router.get('/hk01/tag/:id', require('./routes/hk01/tag'));
|
||||||
router.get('/hk01/hot', require('./routes/hk01/hot'));
|
router.get('/hk01/hot', require('./routes/hk01/hot'));
|
||||||
|
router.get('/hk01/ebook', require('./routes/hk01/ebook'));
|
||||||
|
|
||||||
// 码农周刊
|
// 码农周刊
|
||||||
router.get('/manong-weekly', require('./routes/manong-weekly/issues'));
|
router.get('/manong-weekly', require('./routes/manong-weekly/issues'));
|
||||||
|
|||||||
87
lib/routes/hk01/ebook.js
Normal file
87
lib/routes/hk01/ebook.js
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const dayjs = require('dayjs');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const tokenresponse = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: `https://emag-api.hk01.com/v1/access_token`,
|
||||||
|
});
|
||||||
|
const hk01Authorization = tokenresponse.data.data[0].token;
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: `https://emag-api.hk01.com/v1/books?devices=web&sourceId=72&p=1&pnum=8&itm_source=service_entrance&itm_medium=web&source_id=72&`,
|
||||||
|
headers: {
|
||||||
|
Authorization: hk01Authorization,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const issuedata = response.data.data[0];
|
||||||
|
// 获取最近周刊的文章
|
||||||
|
const link = `https://emag-api.hk01.com/v1/toc?bookId=${issuedata.book_id}`;
|
||||||
|
const cache = await ctx.cache.get(link);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const response2 = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: link,
|
||||||
|
headers: {
|
||||||
|
Authorization: hk01Authorization,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// 返回单个的issue下的内容。
|
||||||
|
const data2 = response2.data.data;
|
||||||
|
const single = await Promise.all(
|
||||||
|
data2.map(async (item) => {
|
||||||
|
const list2 = item.items;
|
||||||
|
// 每个Category列表下所有的文章,返回的articles里,每个Category为一个数组,底下有N个文章object
|
||||||
|
const articles = Promise.all(
|
||||||
|
list2.map(async (item) => {
|
||||||
|
// 单个Category下单个的文章
|
||||||
|
const iurl = `https://emag-api.hk01.com/v1/articles?articleId=${item.articleId}`;
|
||||||
|
const response3 = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: iurl,
|
||||||
|
headers: {
|
||||||
|
Authorization: hk01Authorization,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const inner = response3.data.data;
|
||||||
|
const ititle = inner.title[0].content;
|
||||||
|
const istory = inner.story;
|
||||||
|
const icat = inner.categoryName;
|
||||||
|
const issue = inner.journalName;
|
||||||
|
const ilink = `https://ebook.hk01.com/article/${item.articleId}`;
|
||||||
|
const idate = dayjs.utc(item.coverImage.match(/com.([0-9]+)./)[1], 'YYYYMMDD');
|
||||||
|
const icontent = {
|
||||||
|
title: `${issue}|${icat}|${ititle}`,
|
||||||
|
link: ilink,
|
||||||
|
description: istory,
|
||||||
|
pubDate: idate,
|
||||||
|
};
|
||||||
|
return Promise.resolve(icontent);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
return Promise.resolve(articles);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
ctx.cache.set(link, JSON.stringify(single));
|
||||||
|
const list = [];
|
||||||
|
single.forEach((issue) => {
|
||||||
|
issue.forEach((item) => {
|
||||||
|
list.push(item);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `《香港01》周報`,
|
||||||
|
link: `https://ebook.hk01.com`,
|
||||||
|
|
||||||
|
item: list.map((item) => ({
|
||||||
|
title: item.title,
|
||||||
|
description: item.description,
|
||||||
|
link: item.link,
|
||||||
|
pubDate: item.pubDate,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user