From 2ceedf1039b96d7f46ca432dda210b333e5f50cd Mon Sep 17 00:00:00 2001
From: Ethan Shen <42264778+nczitzk@users.noreply.github.com>
Date: Thu, 10 Nov 2022 23:06:34 +0800
Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E5=86=85=E8=92=99?=
=?UTF-8?q?=E5=8F=A4=E5=B9=BF=E6=92=AD=E7=94=B5=E8=A7=86=E5=8F=B0=E5=B9=BF?=
=?UTF-8?q?=E6=92=AD=20(#11252)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/traditional-media.md | 14 ++++++++
lib/v2/nmtv/column.js | 47 +++++++++++++++++++++++++++
lib/v2/nmtv/maintainer.js | 3 ++
lib/v2/nmtv/radar.js | 13 ++++++++
lib/v2/nmtv/router.js | 3 ++
lib/v2/nmtv/templates/description.art | 9 +++++
6 files changed, 89 insertions(+)
create mode 100644 lib/v2/nmtv/column.js
create mode 100644 lib/v2/nmtv/maintainer.js
create mode 100644 lib/v2/nmtv/radar.js
create mode 100644 lib/v2/nmtv/router.js
create mode 100644 lib/v2/nmtv/templates/description.art
diff --git a/docs/traditional-media.md b/docs/traditional-media.md
index 49e3f29d8b..557579f72f 100644
--- a/docs/traditional-media.md
+++ b/docs/traditional-media.md
@@ -1618,6 +1618,20 @@ category 对应的关键词有
+## 内蒙古广播电视台
+
+### 点播
+
+
+
+::: tip 提示
+
+如 [蒙古语卫视新闻联播](http://www.nmtv.cn/folder292/folder663/folder301/folder830/folder877) 的 URL 为 ,其栏目 id 为末尾数字编号,即 `877`。可以得到其对应路由为 [`/nmtv/column/877`](https://rsshub.app/nmtv/column/877)
+
+:::
+
+
+
## 纽约时报
### 新闻
diff --git a/lib/v2/nmtv/column.js b/lib/v2/nmtv/column.js
new file mode 100644
index 0000000000..2ef7a77931
--- /dev/null
+++ b/lib/v2/nmtv/column.js
@@ -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,
+ };
+};
diff --git a/lib/v2/nmtv/maintainer.js b/lib/v2/nmtv/maintainer.js
new file mode 100644
index 0000000000..e4549b7256
--- /dev/null
+++ b/lib/v2/nmtv/maintainer.js
@@ -0,0 +1,3 @@
+module.exports = {
+ '/column/:id?': ['nczitzk'],
+};
diff --git a/lib/v2/nmtv/radar.js b/lib/v2/nmtv/radar.js
new file mode 100644
index 0000000000..acf5641b09
--- /dev/null
+++ b/lib/v2/nmtv/radar.js
@@ -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()}`,
+ },
+ ],
+ },
+};
diff --git a/lib/v2/nmtv/router.js b/lib/v2/nmtv/router.js
new file mode 100644
index 0000000000..9bf44c0854
--- /dev/null
+++ b/lib/v2/nmtv/router.js
@@ -0,0 +1,3 @@
+module.exports = function (router) {
+ router.get('/column/:id?', require('./column'));
+};
diff --git a/lib/v2/nmtv/templates/description.art b/lib/v2/nmtv/templates/description.art
new file mode 100644
index 0000000000..e5d730bc7b
--- /dev/null
+++ b/lib/v2/nmtv/templates/description.art
@@ -0,0 +1,9 @@
+{{ if type === 'audio' }}
+
+{{ else if type === 'video' }}
+
+{{ /if }}
\ No newline at end of file