From 90a593c2e47f3308c3dbfbbc30717063e0400254 Mon Sep 17 00:00:00 2001 From: Ethan Shen <42264778+nczitzk@users.noreply.github.com> Date: Fri, 28 Oct 2022 13:51:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E5=9B=9B=E5=B7=9D?= =?UTF-8?q?=E5=B9=BF=E6=92=AD=E7=94=B5=E8=A7=86=E5=8F=B0=E7=94=B5=E8=A7=86?= =?UTF-8?q?=E5=9B=9E=E6=94=BE=20(#11166)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/traditional-media.md | 62 +++++++++++++++++++++++++++ lib/v2/sctv/maintainer.js | 3 ++ lib/v2/sctv/programme.js | 58 +++++++++++++++++++++++++ lib/v2/sctv/radar.js | 13 ++++++ lib/v2/sctv/router.js | 3 ++ lib/v2/sctv/templates/description.art | 3 ++ 6 files changed, 142 insertions(+) create mode 100644 lib/v2/sctv/maintainer.js create mode 100644 lib/v2/sctv/programme.js create mode 100644 lib/v2/sctv/radar.js create mode 100644 lib/v2/sctv/router.js create mode 100644 lib/v2/sctv/templates/description.art diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 21cf744a7..6a4981286 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -1931,6 +1931,68 @@ category 对应的关键词有 +## 四川广播电视台 + +### 电视回放 + + + +::: tip 提示 + +查看更多电视节目请前往 [电视回放](https://www.sctv.com/column/list) + +::: + +| 节目 | id | +| ----------- | ------- | +| 四川新闻联播 | 1 | +| 早安四川 | 2 | +| 今日视点 | 3 | +| 龙门阵摆四川 | 10523 | +| 非常话题 | 1014756 | +| 新闻现场 | 8385 | +| 黄金三十分 | 8386 | +| 全媒直播间 | 8434 | +| 晚报十点半 | 8435 | +| 现场快报 | 8436 | +| 四川乡村新闻 | 3673 | +| 四川文旅报道 | 8174 | +| 乡村会客厅 | 3674 | +| 金字招牌 | 3675 | +| 问您所 “?” | 3677 | +| 蜀你最能 | 3679 | +| 美丽乡村印象 | 3678 | +| 美丽乡村 | 3676 | +| 乡村大篷车 | 3680 | +| 华西论健 | 3681 | +| 乡村聚乐部 | 3682 | +| 医保近距离 | 6403 | +| 音你而来 | 7263 | +| 吃八方 | 7343 | +| 世界那么大 | 7344 | +| 风云川商 | 7345 | +| 麻辣烫 | 7346 | +| 财经快报 | 7473 | +| 医生来了 | 7873 | +| 安逸的旅途 | 8383 | +| 运动 + | 8433 | +| 好戏连台 | 9733 | +| 防癌大讲堂 | 1018673 | +| 消费新观察 | 1017153 | +| 天天耍大牌 | 1014753 | +| 廉洁四川 | 1014754 | +| 看世界 | 1014755 | +| 金熊猫说教育(资讯版) | 1014757 | +| 她说 | 1014759 | +| 嗨宝贝 | 1014762 | +| 萌眼看世界 | 1014764 | +| 乡村大讲堂 | 1014765 | +| 四川党建 | 1014766 | +| 健康四川 | 1014767 | +| 技能四川 | 12023 | + + + ## 台湾中央通讯社 ### 分类 diff --git a/lib/v2/sctv/maintainer.js b/lib/v2/sctv/maintainer.js new file mode 100644 index 000000000..02fe62c97 --- /dev/null +++ b/lib/v2/sctv/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/programme/:id?': ['nczitzk'], +}; diff --git a/lib/v2/sctv/programme.js b/lib/v2/sctv/programme.js new file mode 100644 index 000000000..a8ba92d7f --- /dev/null +++ b/lib/v2/sctv/programme.js @@ -0,0 +1,58 @@ +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 ?? '1'; + + const rootUrl = 'https://www.sctv.com'; + const apiRootUrl = 'https://kscgc.sctv-tf.com'; + const apiUrl = `${apiRootUrl}//sctv/lookback/${id}/index.json`; + const listUrl = `${apiRootUrl}//sctv/lookback/index/lookbackList.json`; + const currentUrl = `${rootUrl}/column/detail?programmeIndex=/sctv/lookback/${id}/index.json`; + + let response = await got({ + method: 'get', + url: apiUrl, + }); + + const programmeUrl = `${apiRootUrl}/${response.data.data.programmeUrl}`; + + response = await got({ + method: 'get', + url: programmeUrl, + }); + + const items = response.data.data.programmeList.map((item) => ({ + title: item.programmeTitle, + link: item.programmeUrl, + pubDate: timezone(parseDate(item.pubTime), +8), + description: art(path.join(__dirname, 'templates/description.art'), { + cover: item.programmeImage, + video: item.programmeUrl, + }), + })); + + response = await got({ + method: 'get', + url: listUrl, + }); + + let name, cover; + for (const p of response.data.data.programme_official) { + if (p.programmeId === id) { + name = p.programmeName; + cover = p.programmeCover; + break; + } + } + + ctx.state.data = { + title: `四川广播电视台 - ${name}`, + link: currentUrl, + item: items, + image: cover, + }; +}; diff --git a/lib/v2/sctv/radar.js b/lib/v2/sctv/radar.js new file mode 100644 index 000000000..81b1cadcf --- /dev/null +++ b/lib/v2/sctv/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'sctv.com': { + _name: '四川广播电视台', + '.': [ + { + title: '电视回放', + docs: 'https://docs.rsshub.app/traditional-media.html#si-chuan-guang-bo-dian-shi-tai-dian-shi-hui-fang', + source: ['/column/list', '/column/detail', '/'], + target: (params, url) => `/sctv/programme/${new URL(url).searchParams.get('programmeId')}`, + }, + ], + }, +}; diff --git a/lib/v2/sctv/router.js b/lib/v2/sctv/router.js new file mode 100644 index 000000000..493311a8f --- /dev/null +++ b/lib/v2/sctv/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/programme/:id?', require('./programme')); +}; diff --git a/lib/v2/sctv/templates/description.art b/lib/v2/sctv/templates/description.art new file mode 100644 index 000000000..d802a1ac6 --- /dev/null +++ b/lib/v2/sctv/templates/description.art @@ -0,0 +1,3 @@ + \ No newline at end of file