diff --git a/docs/traditional-media.md b/docs/traditional-media.md index dda316069..0ffa3bf1f 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -1456,6 +1456,18 @@ category 对应的关键词有 +## 新唐人电视台 + +### 频道 + + + +参数均可在官网获取,如: + +`https://www.ntdtv.com/b5/prog1201` 对应 `/ntdtv/b5/prog1201` + + + ## 信报财经新闻 ### 即时新闻 diff --git a/lib/v2/ntdtv/channel.js b/lib/v2/ntdtv/channel.js new file mode 100644 index 000000000..0aea69b6c --- /dev/null +++ b/lib/v2/ntdtv/channel.js @@ -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, + }; +}; diff --git a/lib/v2/ntdtv/maintainer.js b/lib/v2/ntdtv/maintainer.js new file mode 100644 index 000000000..52d2f169d --- /dev/null +++ b/lib/v2/ntdtv/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:language/:id': ['Fatpandac'], +}; diff --git a/lib/v2/ntdtv/radar.js b/lib/v2/ntdtv/radar.js new file mode 100644 index 000000000..0ccd75e3c --- /dev/null +++ b/lib/v2/ntdtv/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/ntdtv/router.js b/lib/v2/ntdtv/router.js new file mode 100644 index 000000000..d7693882b --- /dev/null +++ b/lib/v2/ntdtv/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:language/:id', require('./channel')); +};