From f58ef7d8a832cb1d313c103e662b35045a3ab222 Mon Sep 17 00:00:00 2001 From: talengu Date: Fri, 9 Aug 2019 11:54:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=88=B1=E5=A5=87=E8=89=BA=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E4=B8=AD=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E4=B8=BB?= =?UTF-8?q?=E9=A1=B5=E8=B7=AF=E7=94=B1=20(#2792)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/multimedia.md | 4 +++ lib/router.js | 1 + lib/routes/iqiyi/video.js | 56 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 lib/routes/iqiyi/video.js diff --git a/docs/multimedia.md b/docs/multimedia.md index 04e221add..5e1b096ed 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -152,6 +152,10 @@ pageClass: routes ## 爱奇艺 +### 用户视频 + + + ### 动漫 diff --git a/lib/router.js b/lib/router.js index bb52f2aa1..7842f9719 100644 --- a/lib/router.js +++ b/lib/router.js @@ -214,6 +214,7 @@ router.get('/qdaily/:type/:id', require('./routes/qdaily/index')); // 爱奇艺 router.get('/iqiyi/dongman/:id', require('./routes/iqiyi/dongman')); +router.get('/iqiyi/user/video/:uid', require('./routes/iqiyi/video')); // 南方周末 router.get('/infzm/:id', require('./routes/infzm/news')); diff --git a/lib/routes/iqiyi/video.js b/lib/routes/iqiyi/video.js new file mode 100644 index 000000000..016874508 --- /dev/null +++ b/lib/routes/iqiyi/video.js @@ -0,0 +1,56 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +// /iqiyi/user/video/:uid +// http://localhost:1200/iqiyi/user/video/2289191062 +module.exports = async (ctx) => { + const uid = ctx.params.uid; + + const response = await got({ + method: 'get', + url: `http://www.iqiyi.com/u/${uid}/v`, + headers: { + Host: 'www.iqiyi.com', + Referer: `http://www.iqiyi.com/u/${uid}/v`, + }, + responseType: 'document', + }); + + const data = response.data; + const $ = cheerio.load(data); + const description = ''; + + const list = $('li[j-delegate="colitem"]'); + + ctx.state.data = { + title: $('title').text(), + link: `http://www.iqiyi.com/u/${uid}/v`, + description: description, + item: + list && + list + .map((index, item) => { + const title = $(item) + .find('.site-piclist_pic a') + .attr('data-title'); + + return { + title, + description: ``, + pubDate: new Date( + $(item) + .find('.playTimes_status.tl') + .text() + .substring(0, 10) + .replace(/-/g, '/') + ).toUTCString(), + link: $(item) + .find('.site-piclist_pic a') + .attr('href'), + }; + }) + .get(), + // .reverse(), + }; +};