feat(route): add 新唐人電視台 (#9292)
* feat(route): add 新唐人電視台 * Update docs/traditional-media.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/ntdtv/channel.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> Co-authored-by: Tony <TonyRL@users.noreply.github.com>
This commit is contained in:
@@ -1456,6 +1456,18 @@ category 对应的关键词有
|
||||
|
||||
</Route>
|
||||
|
||||
## 新唐人电视台
|
||||
|
||||
### 频道
|
||||
|
||||
<Route author="Fatpandac" example="/ntdtv/b5/prog1201" path="/ntdtv/:language/:id" :paramsDesc="['语言,简体为`gb`,繁体为`b5`', '子频道名称']">
|
||||
|
||||
参数均可在官网获取,如:
|
||||
|
||||
`https://www.ntdtv.com/b5/prog1201` 对应 `/ntdtv/b5/prog1201`
|
||||
|
||||
</Route>
|
||||
|
||||
## 信报财经新闻
|
||||
|
||||
### 即时新闻
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
const host = 'https://www.ntdtv.com';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const language = ctx.params.language;
|
||||
const id = ctx.params.id;
|
||||
const url = `${host}/${language}/${id}`;
|
||||
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const title = $('h1.block_title').text();
|
||||
const list = $('div.list_wrapper > div')
|
||||
.map((_, item) => ({
|
||||
title: $(item).find('div.title').text(),
|
||||
link: $(item).find('div.title > a').attr('href'),
|
||||
description: $(item).find('div.excerpt').text(),
|
||||
}))
|
||||
.get()
|
||||
.filter((item) => item.link);
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got.get(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('div.post_content').html();
|
||||
item.pubDate = timezone(parseDate(content('div.time > span').text()), +8);
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `新唐人电视台 - ${title}`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:language/:id': ['Fatpandac'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'ntdtv.com': {
|
||||
_name: '新唐人电视台',
|
||||
www: [
|
||||
{
|
||||
title: '频道',
|
||||
docs: 'https://docs.rsshub.app/traditional-media.html#xin-tang-ren-dian-shi-tai',
|
||||
source: '/:language/:id',
|
||||
target: '/ntdtv/:language/:id',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/:language/:id', require('./channel'));
|
||||
};
|
||||
Reference in New Issue
Block a user