From bba6a46d19c582ecb2fdd0aeade9ba18033aba74 Mon Sep 17 00:00:00 2001 From: bao1991213 Date: Wed, 27 Apr 2022 23:01:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E4=BA=BA=E4=BA=BA?= =?UTF-8?q?=E5=BD=B1=E8=A7=86-=E4=BB=8A=E6=97=A5=E6=92=AD=E5=87=BA=20(#961?= =?UTF-8?q?9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(route): add 人人影视-今日播出 * feat(route): 人人影视-今日更新 v2 standard * refactor: migrate to v2 * fix: apply suggestion --- docs/multimedia.md | 14 +++++++--- lib/router.js | 7 +++-- lib/routes/rrys/review.js | 30 --------------------- lib/routes/yyets/todayfilelist.js | 34 ----------------------- lib/v2/yyets/article.js | 45 +++++++++++++++++++++++++++++++ lib/v2/yyets/maintainer.js | 4 +++ lib/v2/yyets/radar.js | 19 +++++++++++++ lib/v2/yyets/router.js | 4 +++ lib/v2/yyets/today.js | 37 +++++++++++++++++++++++++ 9 files changed, 122 insertions(+), 72 deletions(-) delete mode 100644 lib/routes/rrys/review.js delete mode 100644 lib/routes/yyets/todayfilelist.js create mode 100644 lib/v2/yyets/article.js create mode 100644 lib/v2/yyets/maintainer.js create mode 100644 lib/v2/yyets/radar.js create mode 100644 lib/v2/yyets/router.js create mode 100644 lib/v2/yyets/today.js diff --git a/docs/multimedia.md b/docs/multimedia.md index 31bfabef8..c8c6ecbef 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -1290,13 +1290,19 @@ JavDB 有多个备用域名,本路由默认使用永久域名 + -### 今日更新 +| 全部 | 影视资讯 | 收视快报 | 人人影评 | 人人剧评 | 新剧评测 | 片单推荐 | +| -- | ---- | ------ | -------- | -------- | ---------- | ----- | +| | news | report | m_review | t_review | new_review | recom | - + + +### 今日播出 + + ## 色花堂中文论坛 diff --git a/lib/router.js b/lib/router.js index 82069b69a..c8fe4cc92 100644 --- a/lib/router.js +++ b/lib/router.js @@ -869,11 +869,10 @@ router.get('/dytt/index', lazyloadRouteHandler('./routes/dytt/index')); // 废 // 人生05电影网 router.get('/rs05/rs05', lazyloadRouteHandler('./routes/rs05/rs05')); -// 人人影视 (评测推荐) -router.get('/rrys/review', lazyloadRouteHandler('./routes/rrys/review')); - +// 人人影视 (评测推荐) migrated to v2 +// router.get('/rrys/review', lazyloadRouteHandler('./routes/rrys/review')); // 人人影视(每日更新) -router.get('/yyets/todayfilelist', lazyloadRouteHandler('./routes/yyets/todayfilelist')); +// router.get('/yyets/todayfilelist', lazyloadRouteHandler('./routes/yyets/todayfilelist')); // 趣头条 router.get('/qutoutiao/category/:cid', lazyloadRouteHandler('./routes/qutoutiao/category')); diff --git a/lib/routes/rrys/review.js b/lib/routes/rrys/review.js deleted file mode 100644 index 35c67cd1f..000000000 --- a/lib/routes/rrys/review.js +++ /dev/null @@ -1,30 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -const baseURL = 'http://www.rrys2019.com'; - -module.exports = async (ctx) => { - const response = await got.get(baseURL + '/article'); - - const $ = cheerio.load(response.data); - const list = $('.article-list li'); - ctx.state.data = { - title: '人人影视-评测推荐', - link: baseURL + '/article', - item: - list && - list - .map((index, item) => { - item = $(item); - const itemPicUrl = item.find('.fl-img img').attr('src'); - const itemDesc = item.find('.fl-info p').text().split('By')[0]; - return { - title: item.find('.fl-info h3 a').text(), - author: item.find('.fl-info p a').text(), - description: `描述:${itemDesc}
`, - link: baseURL + item.find('.fl-info h3 a').attr('href'), - }; - }) - .get(), - }; -}; diff --git a/lib/routes/yyets/todayfilelist.js b/lib/routes/yyets/todayfilelist.js deleted file mode 100644 index b1e30f970..000000000 --- a/lib/routes/yyets/todayfilelist.js +++ /dev/null @@ -1,34 +0,0 @@ -const got = require('@/utils/got'); - -module.exports = async (ctx) => { - // 发起 HTTP GET 请求 - const response = await got({ - method: 'get', - url: `http://file.apicvn.com/file/list`, - }); - - const data = response.data; // response.data 为 HTTP GET 请求返回的数据对象 - // 这个对象中包含了数组名为 data,所以 response.data.data 则为需要的数据 - - ctx.state.data = { - // 源标题 - title: `yyets 的今日更新`, - // 源链接 - link: `http://file.apicvn.com/file/list`, - // 源说明 - description: `yyets 的今日更新视频列表`, - // 遍历此前获取的数据 - item: data.map((item) => ({ - // 文章标题 - title: item.file_name, - // 文章正文 - description: ``, - // 文章发布时间 - pubDate: item.create_time, - // 文章链接 - link: `${item.magnet_url}&tr=http://tr.cili001.com:8070/announce&tr=udp://p4p.arenabg.com:1337&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://open.demonii.com:1337`, - enclosure_url: `${item.magnet_url}&tr=http://tr.cili001.com:8070/announce&tr=udp://p4p.arenabg.com:1337&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://open.demonii.com:1337`, // 磁力链接 - enclosure_type: 'application/x-bittorrent', // 固定为 'application/x-bittorrent' - })), - }; -}; diff --git a/lib/v2/yyets/article.js b/lib/v2/yyets/article.js new file mode 100644 index 000000000..a43b9a161 --- /dev/null +++ b/lib/v2/yyets/article.js @@ -0,0 +1,45 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +const baseURL = 'https://yysub.net'; + +module.exports = async (ctx) => { + const type = ctx.params.type ?? ''; + const url = `${baseURL}/article${type ? '?type=' + type : ''}`; + + const response = await got(url); + const $ = cheerio.load(response.data); + + let items = $('.article-list li .fl-info') + .toArray() + .map((e) => { + e = $(e); + return { + title: e.find('h3 a').text(), + link: `${baseURL}${e.find('h3 a').attr('href')}`, + author: e.find('p a').text(), + pubDate: timezone(parseDate(e.find('p').eq(2).text()), +8), + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got(item.link); + const content = cheerio.load(detailResponse.data); + + item.description = content('.information-desc').html(); + return item; + }) + ) + ); + + ctx.state.data = { + title: `${$('title').text()} - 人人影视`, + description: $('meta[name="description"]').attr('content'), + link: url, + item: items, + }; +}; diff --git a/lib/v2/yyets/maintainer.js b/lib/v2/yyets/maintainer.js new file mode 100644 index 000000000..6a341e491 --- /dev/null +++ b/lib/v2/yyets/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '/article/:type?': ['wb121017405'], + '/today': ['bao1991213'], +}; diff --git a/lib/v2/yyets/radar.js b/lib/v2/yyets/radar.js new file mode 100644 index 000000000..1a6556042 --- /dev/null +++ b/lib/v2/yyets/radar.js @@ -0,0 +1,19 @@ +module.exports = { + 'yysub.net': { + _name: '人人影视', + '.': [ + { + title: '影视资讯', + docs: 'https://docs.rsshub.app/multimedia#ren-ren-ying-shi', + source: '/article', + target: (_params, url) => `/yyets/article${new URL(url).searchParams.has('type') ? '/' + new URL(url).searchParams.get('type') : ''}`, + }, + { + title: '今日播出', + docs: 'https://docs.rsshub.app/multimedia#ren-ren-ying-shi', + source: ['/tv/schedule', '/'], + target: '/yyets/today', + }, + ], + }, +}; diff --git a/lib/v2/yyets/router.js b/lib/v2/yyets/router.js new file mode 100644 index 000000000..a904c4269 --- /dev/null +++ b/lib/v2/yyets/router.js @@ -0,0 +1,4 @@ +module.exports = function (router) { + router.get('/article/:type?', require('./article')); + router.get('/today', require('./today')); +}; diff --git a/lib/v2/yyets/today.js b/lib/v2/yyets/today.js new file mode 100644 index 000000000..48b060e27 --- /dev/null +++ b/lib/v2/yyets/today.js @@ -0,0 +1,37 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + // 发起 HTTP GET 请求 + const response = await got({ + method: 'get', + url: 'https://yysub.net', + }); + + const data = response.data; // response.data 为 HTTP GET 请求返回的 HTML,也就是简书首页的所有 HTML + + const $ = cheerio.load(data); // 使用 cheerio 加载返回的 HTML + const list = $('.today-list-wrap').find('ul').find('li'); + // 使用 cheerio 选择器,选择带有 data-item_id 属性的所有 div 元素,返回 cheerio node 对象数组 + + // 注:每一个 cheerio node 对应一个 HTML DOM + // 注:cheerio 选择器与 jquery 选择器几乎相同 + // 参考 cheerio 文档:https://cheerio.js.org/ + + ctx.state.data = { + title: '人人影视-今日播出', + link: 'https://yysub.net', + item: + list && + list + .map((index, item) => { + item = $(item); + return { + title: item.find('a').first().text(), + link: item.find('a').attr('href'), + guid: item.find('a').first().text(), + }; + }) + .get(), + }; +};