Skip to content

Commit

Permalink
feat(route): add 河北电视台的1个节目 (#13689)
Browse files Browse the repository at this point in the history
* 添加文档

* 河北电视台

---------
  • Loading branch information
iamqiz authored Nov 3, 2023
1 parent 2a2aa6d commit 70dc17d
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/v2/hebtv/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/nbszxd': ['iamqiz'],
};
39 changes: 39 additions & 0 deletions lib/v2/hebtv/nong-bo-shi-zai-xing-dong.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');

const baseUrl = 'https://web.cmc.hebtv.com/cms/rmt0336/19/19js/st/ds/nmpd/nbszxd/index.shtml';
const sizeTitle = '农博士在行动-河北广播电视台';

module.exports = async (ctx) => {
const response = await got(baseUrl);
const $ = cheerio.load(response.data);

// 获取当前页面的 list
const list = $('.video_box .tv_items')
.first()
.children()
.toArray()
.map((item) => {
item = $(item);
const a = item.find('a').first();
const timeMatch = a.text().match(/\d+/);
const timestr = timeMatch ? timeMatch[0] : '';

return {
title: a.text(),
// `link` 需要一个绝对 URL,但 `a.attr('href')` 返回一个相对 URL。
link: `${baseUrl}/../${a.attr('href')}`,
pubDate: timestr ? timezone(parseDate(timestr, 'YYYYMMDD'), +8) : null,
author: '时间|' + timestr,
};
});

ctx.state.data = {
title: sizeTitle,
link: baseUrl,
description: '农博士在行动-河北广播电视台',
item: list,
};
};
13 changes: 13 additions & 0 deletions lib/v2/hebtv/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'hebtv.com': {
_name: '河北网络广播电视台',
'web.cmc': [
{
title: '农博士在行动',
docs: 'https://docs.rsshub.app/routes/traditional-media#he-bei-wang-luo-guang-bo-dian-shi-tai',
source: '/cms/rmt0336/19/19js/st/ds/nmpd/nbszxd/index.shtml',
target: '/hebtv/nbszxd',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/hebtv/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/nbszxd', require('./nong-bo-shi-zai-xing-dong.js'));
};
6 changes: 6 additions & 0 deletions website/docs/routes/traditional-media.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,12 @@ IT・科学 tech_science

</Route>

## 河北网络广播电视台 {#he-bei-wang-luo-guang-bo-dian-shi-tai}

### 农博士在行动 {#he-bei-wang-luo-guang-bo-dian-shi-tai-nong-bo-shi-zai-xing-dong}

<Route author="iamqiz" example="/hebtv/nbszxd" path="/hebtv/nbszxd"/>

## 衡阳全搜索 {#heng-yang-quan-sou-suo}

### 衡阳日报 {#heng-yang-quan-sou-suo-heng-yang-ri-bao}
Expand Down

0 comments on commit 70dc17d

Please sign in to comment.