From 0cafed6a51b865ca00cd4580833b17b21fd2fcf6 Mon Sep 17 00:00:00 2001 From: HAL9000 Date: Thu, 9 Mar 2023 19:36:21 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20=E6=B5=99=E6=B1=9F=E6=96=B0?= =?UTF-8?q?=E9=97=BB=E8=81=94=E6=92=AD=20(#12030)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(route): 浙江新闻联播 * Update lib/v2/cztv/maintainer.js * feat: 浙江新闻联播排除标题 * feat: 浙江新闻联播单条展示 * feat: use art-template --------- --- docs/traditional-media.md | 10 ++++++++ lib/v2/cztv/daily.js | 41 ++++++++++++++++++++++++++++++++ lib/v2/cztv/maintainer.js | 4 ++++ lib/v2/cztv/radar.js | 19 +++++++++++++++ lib/v2/cztv/router.js | 4 ++++ lib/v2/cztv/templates/daily.art | 4 ++++ lib/v2/cztv/templates/zjxwlb.art | 3 +++ lib/v2/cztv/zjxwlb.js | 38 +++++++++++++++++++++++++++++ 8 files changed, 123 insertions(+) create mode 100644 lib/v2/cztv/daily.js create mode 100644 lib/v2/cztv/maintainer.js create mode 100644 lib/v2/cztv/radar.js create mode 100644 lib/v2/cztv/router.js create mode 100644 lib/v2/cztv/templates/daily.art create mode 100644 lib/v2/cztv/templates/zjxwlb.art create mode 100644 lib/v2/cztv/zjxwlb.js diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 508a361b2..6c51a4780 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -2278,6 +2278,16 @@ category 对应的关键词有 +## 新蓝网(浙江广播电视集团) + +### 浙江新闻联播 + + + +### 浙江新闻联播 - 每日合集 + + + ## 新浪科技 ### 科学探索 diff --git a/lib/v2/cztv/daily.js b/lib/v2/cztv/daily.js new file mode 100644 index 000000000..3e22784ed --- /dev/null +++ b/lib/v2/cztv/daily.js @@ -0,0 +1,41 @@ +const cheerio = require('cheerio'); +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); +const path = require('path'); +const { art } = require('@/utils/render'); + +const renderDesc = (item) => art(path.join(__dirname, 'templates/daily.art'), item); + +module.exports = async (ctx) => { + const url = 'http://www.cztv.com/videos/zjxwlb'; + + const { data: res } = await got(url); + const $ = cheerio.load(res); + const list = $('#videolistss li') + .toArray() + .map((item) => { + item = $(item); + const title = item.find('span.t1').text(); + const link = item.find('input[name=data-url]').attr('value'); + + return { + title, + link, + pubDate: timezone(parseDate(item.find('span.t2').text() + ' 16:30', 'YYYY-MM-DD hh:mm'), +8), + }; + }); + + const out = { + title: list[0].title, + link: list[0].link, + pubDate: list[0].pubDate, + description: renderDesc({ list: list.slice(1) }), + }; + + ctx.state.data = { + title: '浙江新闻联播-每日合集', + link: url, + item: [out], + }; +}; diff --git a/lib/v2/cztv/maintainer.js b/lib/v2/cztv/maintainer.js new file mode 100644 index 000000000..adc628f68 --- /dev/null +++ b/lib/v2/cztv/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '/zjxwlb': ['yhkang'], + '/zjxwlb/daily': ['yhkang'], +}; diff --git a/lib/v2/cztv/radar.js b/lib/v2/cztv/radar.js new file mode 100644 index 000000000..3b94226fc --- /dev/null +++ b/lib/v2/cztv/radar.js @@ -0,0 +1,19 @@ +module.exports = { + 'cztv.com': { + _name: '新蓝网', + '.': [ + { + title: '浙江新闻联播', + docs: 'https://docs.rsshub.app/traditional-media.html#xin-lan-wang-zhe-jiang-guang-bo-dian-shi-ji-tuan', + source: ['/videos/zjxwlb', '/'], + target: '/cztv/zjxwlb', + }, + { + title: '浙江新闻联播-每日合集', + docs: 'https://docs.rsshub.app/traditional-media.html#xin-lan-wang-zhe-jiang-guang-bo-dian-shi-ji-tuan', + source: ['/videos/zjxwlb', '/'], + target: '/cztv/zjxwlb/daily', + }, + ], + }, +}; diff --git a/lib/v2/cztv/router.js b/lib/v2/cztv/router.js new file mode 100644 index 000000000..71e9623f9 --- /dev/null +++ b/lib/v2/cztv/router.js @@ -0,0 +1,4 @@ +module.exports = (router) => { + router.get('/zjxwlb', require('./zjxwlb')); + router.get('/zjxwlb/daily', require('./daily')); +}; diff --git a/lib/v2/cztv/templates/daily.art b/lib/v2/cztv/templates/daily.art new file mode 100644 index 000000000..ee32cbd19 --- /dev/null +++ b/lib/v2/cztv/templates/daily.art @@ -0,0 +1,4 @@ +{{each list item}} + {{item.title}} +
+{{/each}} diff --git a/lib/v2/cztv/templates/zjxwlb.art b/lib/v2/cztv/templates/zjxwlb.art new file mode 100644 index 000000000..9eb64b4b1 --- /dev/null +++ b/lib/v2/cztv/templates/zjxwlb.art @@ -0,0 +1,3 @@ + diff --git a/lib/v2/cztv/zjxwlb.js b/lib/v2/cztv/zjxwlb.js new file mode 100644 index 000000000..d242e4af0 --- /dev/null +++ b/lib/v2/cztv/zjxwlb.js @@ -0,0 +1,38 @@ +const cheerio = require('cheerio'); +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); +const path = require('path'); +const { art } = require('@/utils/render'); + +const renderDesc = (item) => art(path.join(__dirname, 'templates/zjxwlb.art'), item); + +module.exports = async (ctx) => { + const url = 'http://www.cztv.com/videos/zjxwlb'; + + const { data: res } = await got(url); + const $ = cheerio.load(res); + const list = $('#videolistss li') + .toArray() + .map((item) => { + item = $(item); + + const title = item.find('span.t1').text(); + const link = item.find('input[name=data-url]').attr('value'); + const videoUrl = item.find('input[name=video]').attr('value'); + const posterUrl = item.find('input[name=videoimage]').attr('value'); + + return { + title, + link, + pubDate: timezone(parseDate(item.find('span.t2').text() + ' 16:30', 'YYYY-MM-DD hh:mm'), +8), + description: renderDesc({ title, videoUrl, posterUrl }), + }; + }); + + ctx.state.data = { + title: '浙江新闻联播', + link: url, + item: list, + }; +};