From cee613d9bb6c7e30850754974bf145dbe1c565cd Mon Sep 17 00:00:00 2001 From: Andie Date: Sun, 11 Nov 2018 11:45:07 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E8=85=BE=E8=AE=AF=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E6=92=AD=E6=94=BE=E5=88=97=E8=A1=A8=20(#1107)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 4 ++++ router.js | 3 +++ routes/tencent/video/playlist.js | 26 ++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 routes/tencent/video/playlist.js diff --git a/docs/README.md b/docs/README.md index 671597d68..d8cad0902 100644 --- a/docs/README.md +++ b/docs/README.md @@ -802,6 +802,10 @@ GitHub 官方也提供了一些 RSS: +### 腾讯视频 + + + ### 喜马拉雅 diff --git a/router.js b/router.js index 9c45cdd46..ceb671b00 100644 --- a/router.js +++ b/router.js @@ -784,4 +784,7 @@ router.get('/xiachufang/popular/:timeframe?', require('./routes/xiachufang/popul // 经济观察报 router.get('/eeo/:category?', require('./routes/eeo/index')); +// 腾讯视频 +router.get('/tencentvideo/playlist/:id', require('./routes/tencent/video/playlist')); + module.exports = router; diff --git a/routes/tencent/video/playlist.js b/routes/tencent/video/playlist.js new file mode 100644 index 000000000..982a1efd0 --- /dev/null +++ b/routes/tencent/video/playlist.js @@ -0,0 +1,26 @@ +const axios = require('../../../utils/axios'); +const cheerio = require('cheerio'); +module.exports = async (ctx) => { + const id = ctx.params.id; + const link = `https://v.qq.com/detail/${id[0]}/${id}.html`; + const { data } = await axios.get(link); + const $ = cheerio.load(data); + const episodeName = $('[itemprop=episodeNumber]') + .toArray() + .reverse() + .slice(0, 20); + const items = []; + for (const one of episodeName) { + const ele = $(one); + items.push({ + title: ele.text(), + link: ele.parent().attr('href'), + }); + } + ctx.state.data = { + title: $('title').text(), + link, + description: $('meta[name=description]').attr('content'), + item: items, + }; +};