From 6e2c0821ea24e116b37f704a3313e653ff049d03 Mon Sep 17 00:00:00 2001 From: "Monst.x" Date: Sat, 1 Aug 2020 21:42:06 +0800 Subject: [PATCH] feat: add OneJAV (supportBT)(radar) (#5298) --- assets/radar-rules.js | 38 +++++++++++++++++++++++++++++++ docs/multimedia.md | 48 ++++++++++++++++++++++++++++++++++++++++ lib/router.js | 3 +++ lib/routes/onejav/one.js | 37 +++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 lib/routes/onejav/one.js diff --git a/assets/radar-rules.js b/assets/radar-rules.js index c0ea5734f1..9af4dc4181 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -1925,6 +1925,44 @@ }, ], }, + 'onejav.com': { + _name: 'OneJAV BT', + '.': [ + { + title: '今日种子', + docs: 'https://docs.rsshub.app/multimedia.html#onejav', + source: '/', + target: (params, url, document) => { + const today = document.querySelector('div.card.mb-1.card-overview').getAttribute('data-date').replace(/-/g, ''); + return `/onejav/day/${today}`; + }, + }, + { + title: '今日演员', + docs: 'https://docs.rsshub.app/multimedia.html#onejav', + source: '/', + target: (params, url, document) => { + const star = document.querySelector('div.card-content > div > a').getAttribute('href'); + return `/onejav${star}`; + }, + }, + { + title: '页面种子', + docs: 'https://docs.rsshub.app/multimedia.html#onejav', + source: ['/:type', '/:type/:key', '/:type/:key/:morekey'], + target: (params, url, document) => { + const itype = params.morekey === undefined ? `${params.type}` : params.type === 'tag' ? 'tag' : 'day'; + let ikey = `${itype === 'day' ? params.type : ''}${params.key || ''}${params.morekey || ''}`; + if (ikey === '' && itype === 'tag') { + ikey = document.querySelector('div.thumbnail.is-inline > a').getAttribute('href').replace('/tag/', '').replace('/', '%2F'); + } else if (ikey === '' && itype === 'actress') { + ikey = document.querySelector('div.card > a').getAttribute('href').replace('/actress/', ''); + } + return `/onejav/${itype}/${ikey}`; + }, + }, + ], + }, 'sexinsex.net': { _name: 'sexinsex', '.': [ diff --git a/docs/multimedia.md b/docs/multimedia.md index c7cee505a4..76659975b7 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -215,6 +215,54 @@ pageClass: routes +## OneJAV + +::: tip 提示 + +官方提供的订阅源不支持 BT 下载订阅,地址为 + +::: + +### OneJAV BT + + + +**类型** + +| 最新 | 热门 | 随机 | 指定演员 | 指定标签 | 指定日期 | +| ---- | ------- | ------ | -------- | -------- | -------- | +| new | popular | random | actress | tag | day | + +**关键词** + +| 空 | 日期范围 | 演员名 | 标签名 | 日期 | +| -- | ----------- | ------------ | -------------- | -------- | +| | 7 / 30 / 60 | Yua%20Mikami | Adult%20Awards | YYYYMMDD | + +**示例说明** + +- `/onejav/new` + + 仅当类型为 `new` `popular` 或 `random` 时关键词可为 **空** + +- `/onejav/popular/30` + + `popular` `random` 类型的关键词可填写 `7` `30` 或 `60` 三个 **日期范围** 之一 + +- `/onejav/actress/Yua%20Mikami` + + `actress` 类型的关键词必须填写 **演员名** ,可在 [此处](https://onejav.com/actress/) 演员单页链接中获取 + +- `/onejav/tag/Adult%20Awards` + + `tag` 类型的关键词必须填写 **标签名** 且标签中的 `/` 必须替换为 `%2F` ,可在 [此处](https://onejav.com/tag/) 标签单页链接中获取 + +- `/onejav/day/20200730` + + `day` 类型的关键词必须填写 **日期** ,按照示例写成形如 `20200730` 的格式 + + + ## rs05 人生 05 电影 ### rs05 电影列表 diff --git a/lib/router.js b/lib/router.js index bd743f1610..ac56e016e0 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3037,4 +3037,7 @@ router.get('/hfut/tzgg', require('./routes/universities/hfut/tzgg')); // Darwin Awards router.get('/darwinawards/all', require('./routes/darwinawards/articles')); +// OneJAV +router.get('/onejav/:type/:key?', require('./routes/onejav/one')); + module.exports = router; diff --git a/lib/routes/onejav/one.js b/lib/routes/onejav/one.js new file mode 100644 index 0000000000..054f0f733f --- /dev/null +++ b/lib/routes/onejav/one.js @@ -0,0 +1,37 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const type = ctx.params.type || 'new'; + const key = type === 'day' ? ctx.params.key.slice(0, 4) + '/' + ctx.params.key.slice(4, 6) + '/' + ctx.params.key.slice(6, 8) : ctx.params.key || ''; + const link = 'https://onejav.com' + `/${type === 'day' ? '' : type}${type === 'new' ? '' : '/' + key}`.replace('//', '/'); + const response = await got({ + method: 'get', + url: link, + }); + + const $ = cheerio.load(response.data); + const list = $('div.columns'); + + let itemPicUrl; + + ctx.state.data = { + title: `OneJAV - ${type} ${key}`, + link: link, + item: + list && + list + .map((index, item) => { + item = $(item); + itemPicUrl = item.find('img').attr('src'); + return { + title: '【' + item.find('div.card-content.is-flex > h5 > a').text() + '】' + item.find('div.card-content.is-flex > h5 > span').text(), + description: `
Time: ${item.find('p.subtitle.is-6 > a').text()}
Desc: ${item.find('p.level.has-text-grey-dark').text()}`, + link: item.find('div.card-content.is-flex > h5 > a').attr('href'), + enclosure_url: 'https://onejav.com' + item.find('p.control.is-expanded > a').attr('href'), + enclosure_type: 'application/x-bittorrent', + }; + }) + .get(), + }; +};