From 0acae72394c4f34ffa148d891c8da9082b23889b Mon Sep 17 00:00:00 2001 From: Ethan Shen <42264778+nczitzk@users.noreply.github.com> Date: Thu, 2 Nov 2023 21:23:18 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E9=BD=90=E9=B2=81?= =?UTF-8?q?=E7=BD=91=E7=94=B5=E8=A7=86=E8=8A=82=E7=9B=AE=20(#13676)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps-dev): bump @tsconfig/docusaurus in /website (#686) Bumps [@tsconfig/docusaurus](https://github.com/tsconfig/bases/tree/HEAD/bases) from 2.0.1 to 2.0.2. - [Commits](https://github.com/tsconfig/bases/commits/HEAD/bases) --- updated-dependencies: - dependency-name: "@tsconfig/docusaurus" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat(route): add 齐鲁网电视节目 * fix template --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- lib/v2/iqilu/maintainer.js | 3 + lib/v2/iqilu/program.js | 98 +++++++++++++++++++++ lib/v2/iqilu/radar.js | 107 +++++++++++++++++++++++ lib/v2/iqilu/router.js | 3 + lib/v2/iqilu/templates/description.art | 24 +++++ website/docs/routes/traditional-media.md | 26 ++++++ 6 files changed, 261 insertions(+) create mode 100644 lib/v2/iqilu/maintainer.js create mode 100644 lib/v2/iqilu/program.js create mode 100644 lib/v2/iqilu/radar.js create mode 100644 lib/v2/iqilu/router.js create mode 100644 lib/v2/iqilu/templates/description.art diff --git a/lib/v2/iqilu/maintainer.js b/lib/v2/iqilu/maintainer.js new file mode 100644 index 000000000..fcaa86e3c --- /dev/null +++ b/lib/v2/iqilu/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/v/category?': ['nczitzk'], +}; diff --git a/lib/v2/iqilu/program.js b/lib/v2/iqilu/program.js new file mode 100644 index 000000000..e05fcbdc1 --- /dev/null +++ b/lib/v2/iqilu/program.js @@ -0,0 +1,98 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const { category = 'sdws/sdxwlb' } = ctx.params; + const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30; + + const rootUrl = 'http://v.iqilu.com'; + const currentUrl = new URL(category, rootUrl).href; + + const { data: response } = await got(currentUrl); + + const $ = cheerio.load(response); + + let items = $('#jmzhanshi1 dl') + .slice(0, limit) + .toArray() + .map((item) => { + item = $(item); + + const a = item.find('a').first(); + const image = item.find('img').first(); + + item.find('dd').last().remove(); + + return { + title: a.prop('title'), + link: a.prop('href'), + description: art(path.join(__dirname, 'templates/description.art'), { + image: { + src: image.prop('src'), + alt: image.prop('alt'), + }, + }), + pubDate: parseDate( + item + .find('dd') + .last() + .text() + .match(/(\d{4}-\d{2}-\d{2})/)[1] + ), + itunes_item_image: image.prop('src'), + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const { data: detailResponse } = await got(item.link); + + const content = cheerio.load(detailResponse); + + item.title = content('div.vtitle').text(); + item.enclosure_url = content('#copy_mp4text').prop('value'); + item.enclosure_type = item.enclosure_url ? `video/${item.enclosure_url.split(/\./).pop()}` : undefined; + + item.description = art(path.join(__dirname, 'templates/description.art'), { + image: { + src: item.itunes_item_image, + alt: item.title, + }, + video: { + src: item.enclosure_url, + type: item.enclosure_type, + }, + description: content('div.vinfo').text().trim(), + }); + + return item; + }) + ) + ); + + const icon = new URL($('link[rel="icon"]').prop('href'), rootUrl).href; + const author = $('div.host_pic dl dd a') + .toArray() + .map((a) => $(a).text()) + .join('/'); + + ctx.state.data = { + item: items, + title: $('title').text(), + link: currentUrl, + description: $('meta[name="description"]').prop('content'), + language: $('html').prop('lang'), + image: $('div.s_logo img').prop('src'), + icon, + logo: icon, + subtitle: $('meta[name="keywords"]').prop('content'), + author, + itunes_author: author, + itunes_category: 'News', + allowEmpty: true, + }; +}; diff --git a/lib/v2/iqilu/radar.js b/lib/v2/iqilu/radar.js new file mode 100644 index 000000000..065e84886 --- /dev/null +++ b/lib/v2/iqilu/radar.js @@ -0,0 +1,107 @@ +module.exports = { + 'iqilu.com': { + _name: '齐鲁网', + v: [ + { + title: '电视节目', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/:category*'], + target: (params) => { + const category = params.category; + + return `/iqilu/v${category ? `/${category}` : ''}`; + }, + }, + { + title: '山东新闻联播', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/sdws/sdxwlb'], + target: '/iqilu/v/sdws/sdxwlb', + }, + { + title: '闪电大视野', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/ggpd/sddsy'], + target: '/iqilu/v/ggpd/sddsy', + }, + { + title: '山东三农新闻联播', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/nkpd/snxw'], + target: '/iqilu/v/nkpd/snxw', + }, + { + title: '每日新闻', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/qlpd/mrxw'], + target: '/iqilu/v/qlpd/mrxw', + }, + { + title: '新闻午班车', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/ggpd/xwwbc'], + target: '/iqilu/v/ggpd/xwwbc', + }, + { + title: '戏宇宙', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/sdws/xyz/'], + target: '/iqilu/v/sdws/xyz/', + }, + { + title: '中国礼 中国乐', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/qlpd/zglzgy'], + target: '/iqilu/v/qlpd/zglzgy', + }, + { + title: '超级语文课', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/sdws/cjywk'], + target: '/iqilu/v/sdws/cjywk', + }, + { + title: '文物里的山东', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/yspd/wwldsd'], + target: '/iqilu/v/yspd/wwldsd', + }, + { + title: '拉呱', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/qlpd/l0'], + target: '/iqilu/v/qlpd/l0', + }, + { + title: '生活帮', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/shpd/shb'], + target: '/iqilu/v/shpd/shb', + }, + { + title: '快乐大赢家', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/zypd/kldyj'], + target: '/iqilu/v/zypd/kldyj', + }, + { + title: '乡村季风', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/nkpd/xcjf'], + target: '/iqilu/v/nkpd/xcjf', + }, + { + title: '健康是1', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/ggpd/jks1'], + target: '/iqilu/v/ggpd/jks1', + }, + { + title: '此时此刻', + docs: 'https://docs.rsshub.app/routes/traditional-media#qi-lu-wang-dian-shi-jie-mu', + source: ['/sdws/cishicike'], + target: '/iqilu/v/sdws/cishicike', + }, + ], + }, +}; diff --git a/lib/v2/iqilu/router.js b/lib/v2/iqilu/router.js new file mode 100644 index 000000000..0f8a24a90 --- /dev/null +++ b/lib/v2/iqilu/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/v/:category*', require('./program')); +}; diff --git a/lib/v2/iqilu/templates/description.art b/lib/v2/iqilu/templates/description.art new file mode 100644 index 000000000..df4b1523c --- /dev/null +++ b/lib/v2/iqilu/templates/description.art @@ -0,0 +1,24 @@ +{{ if image && !video }} +
+ {{ image.alt }} +
+{{ /if }} + +{{ if video }} + +{{ /if }} + +{{ if description }} +

{{ description }}

+{{ /if }} diff --git a/website/docs/routes/traditional-media.md b/website/docs/routes/traditional-media.md index adcd75bbd..e47d80e95 100644 --- a/website/docs/routes/traditional-media.md +++ b/website/docs/routes/traditional-media.md @@ -2205,6 +2205,32 @@ category 对应的关键词有 +## 齐鲁网 {#qi-lu-wang} + +### 电视节目 {#qi-lu-wang-dian-shi-jie-mu} + + + +| 节目名称 | 节目 id | +| ---------------- | -------------- | +| 山东新闻联播 | sdws/sdxwlb | +| 闪电大视野 | ggpd/sddsy | +| 山东三农新闻联播 | nkpd/snxw | +| 每日新闻 | qlpd/mrxw | +| 新闻午班车 | ggpd/xwwbc | +| 戏宇宙 | sdws/xyz/ | +| 中国礼 中国乐 | qlpd/zglzgy | +| 超级语文课 | sdws/cjywk | +| 文物里的山东 | yspd/wwldsd | +| 拉呱 | qlpd/l0 | +| 生活帮 | shpd/shb | +| 快乐大赢家 | zypd/kldyj | +| 乡村季风 | nkpd/xcjf | +| 健康是1 | ggpd/jks1 | +| 此时此刻 | sdws/cishicike | + + + ## 人民网 {#ren-min-wang} ### 通用 {#ren-min-wang-tong-yong}