feat(route): add 内蒙古广播电视台广播 (#11252)

This commit is contained in:
Ethan Shen
2022-11-10 23:06:34 +08:00
committed by GitHub
parent 1fe5fbb6e2
commit 2ceedf1039
6 changed files with 89 additions and 0 deletions
+14
View File
@@ -1618,6 +1618,20 @@ category 对应的关键词有
</Route>
## 内蒙古广播电视台
### 点播
<Route author="nczitzk" example="/nmtv/column/877" path="/nmtv/column/:id?" :paramsDesc="['栏目 id,可在对应栏目 URL 中找到']">
::: tip 提示
如 [蒙古语卫视新闻联播](http://www.nmtv.cn/folder292/folder663/folder301/folder830/folder877) 的 URL 为 <http://www.nmtv.cn/folder292/folder663/folder301/folder830/folder877>,其栏目 id 为末尾数字编号,即 `877`。可以得到其对应路由为 [`/nmtv/column/877`](https://rsshub.app/nmtv/column/877)
:::
</Route>
## 纽约时报
### 新闻
+47
View File
@@ -0,0 +1,47 @@
const got = require('@/utils/got');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const id = ctx.params.id ?? '877';
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 100;
const hostUrl = 'https://vod.m2oplus.nmtv.cn';
const apiRootUrl = 'https://mapi.m2oplus.nmtv.cn';
const apiUrl = `${apiRootUrl}/api/v1/contents.php?offset=0&count=${limit}&column_id=${id}`;
const response = await got({
method: 'get',
url: apiUrl,
});
const data = response.data;
const items = data.map((item) => ({
title: item.title,
link: item.content_url,
author: item.column_name,
pubDate: timezone(parseDate(item.publish_time), +8),
description: art(path.join(__dirname, 'templates/description.art'), {
type: item.type,
image: item.index_pic,
file: `${hostUrl}/${item.target_path}${item.target_filename}`,
}),
enclosure_url: `${hostUrl}/${item.target_path}${item.target_filename}`,
itunes_duration: item.video.duration,
itunes_item_image: item.index_pic,
}));
const author = data[0].column_name;
const imageUrl = data[0].column_info.indexpic;
ctx.state.data = {
title: `内蒙古广播电视台 - ${author}`,
link: items[0].link.split(/\/\d{4}-\d{2}-\d{2}\//)[0],
item: items,
image: `${imageUrl.host}${imageUrl.filepath}${imageUrl.filename}`,
itunes_author: author,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/column/:id?': ['nczitzk'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'nmtv.cn': {
_name: '内蒙古广播电视台',
'.': [
{
title: '点播',
docs: 'https://docs.rsshub.app/traditional-media.html#nei-meng-gu-guang-bo-dian-shi-tai-dian-bo',
source: ['/'],
target: (params, url) => `/nmtv/column/${new URL(url).toString.split(/\/folder/).pop()}`,
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/column/:id?', require('./column'));
};
+9
View File
@@ -0,0 +1,9 @@
{{ if type === 'audio' }}
<audio controls="controls">
<source src="{{ file }}" type="audio/mp3">
</audio>
{{ else if type === 'video' }}
<video controls poster="{{ image }}">
<source src="{{ file }}" type="video/mp4">
</video>
{{ /if }}