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