From 1892e139a12e9ef0600c3bd4e9fab16cfa8cbf94 Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Tue, 22 Feb 2022 21:39:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E7=A7=8B=E7=88=B8?= =?UTF-8?q?=E6=97=A5=E5=AD=97=20(#7715)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(route): add 秋爸日字 * refactor: migrate to v2 Co-authored-by: TonyRL --- docs/multimedia.md | 12 ++++++++ lib/v2/qq88/index.js | 60 +++++++++++++++++++++++++++++++++++++++ lib/v2/qq88/maintainer.js | 3 ++ lib/v2/qq88/radar.js | 13 +++++++++ lib/v2/qq88/router.js | 3 ++ 5 files changed, 91 insertions(+) create mode 100644 lib/v2/qq88/index.js create mode 100644 lib/v2/qq88/maintainer.js create mode 100644 lib/v2/qq88/radar.js create mode 100644 lib/v2/qq88/router.js diff --git a/docs/multimedia.md b/docs/multimedia.md index c0710fdce..5df70c198 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -1238,6 +1238,18 @@ JavDB 有多个备用域名,本路由默认使用永久域名 +## 秋爸日字 + +### 分类 + + + +| 首页 | オトナの土ドラ | 日剧 | 日剧 SP | +| ---- | -------------- | ---- | ------- | +| | 10 | 5 | 11 | + + + ## 人人影视 ### 评测推荐 diff --git a/lib/v2/qq88/index.js b/lib/v2/qq88/index.js new file mode 100644 index 000000000..5bc35a9f3 --- /dev/null +++ b/lib/v2/qq88/index.js @@ -0,0 +1,60 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const category = ctx.params.category ?? ''; + + const rootUrl = 'https://qq88.info'; + const currentUrl = category ? `${rootUrl}/?cat=${category}` : rootUrl; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.entry-title a') + .slice(0, 15) + .map((_, item) => { + item = $(item); + + return { + title: item.text(), + link: item.attr('href'), + pubDate: parseDate(item.parent().next().find('.mh-meta-date').eq(-1).text().split(':')[1]), + }; + }) + .get(); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + const links = content('.entry-content').find('a[download]'); + + item.enclosure_type = 'video/mp4'; + item.enclosure_url = links.eq(-1).attr('href'); + item.description = `
`; + + links.each(function () { + item.description += `
  • ${content(this).text()}
  • `; + }); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `${$('.page-title').text() || '首页'} - 秋爸日字`, + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/qq88/maintainer.js b/lib/v2/qq88/maintainer.js new file mode 100644 index 000000000..81eb78d73 --- /dev/null +++ b/lib/v2/qq88/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:category?': ['nczitzk'], +}; diff --git a/lib/v2/qq88/radar.js b/lib/v2/qq88/radar.js new file mode 100644 index 000000000..90b29ccc7 --- /dev/null +++ b/lib/v2/qq88/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'qq88.info': { + _name: '秋爸日字', + '.': [ + { + title: '分类', + docs: 'https://docs.rsshub.app/multimedia.html#qiu-ba-ri-zi', + source: '/', + target: (_params, url) => (new URL(url).searchParams.get('cat') ? `/qq88/${new URL(url).searchParams.get('cat')}` : '/qq88'), + }, + ], + }, +}; diff --git a/lib/v2/qq88/router.js b/lib/v2/qq88/router.js new file mode 100644 index 000000000..19b84c05d --- /dev/null +++ b/lib/v2/qq88/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/:category?', require('./')); +};