fix(route): JavDB (#8578)

This commit is contained in:
Ethan Shen 2021-11-27 17:12:20 +08:00 committed by GitHub
parent ee270e75c6
commit 5ef2466ce2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 191 additions and 113 deletions

View File

@ -379,9 +379,27 @@ BT 之家的域名会变更,本路由以 <https://www.btbtt20.com> 为默认
## JavDB
::: tip 提示
JavDB 有多个备用域名,本路由以 <https://javdb7.com> 为默认域名,若该域名无法访问,可以通过在路由后方加上 `?domain=<域名>` 指定路由访问的域名。如指定域名为 <https://javdb.com>,则在所有 JavDB 路由后加上 `?domain=javdb.com` 即可,此时路由为 [`/javdb?domain=javdb.com`](https://rsshub.app/javdb?domain=javdb.com)
如果加入了 **分類** 参数,直接在分類参数后加入 `?domain=<域名>` 即可。如指定分類 URL 为 <https://javdb.com/tags?c2=5&c10=1> 并指定域名为 <https://javdb.com>,即在 `/javdb/tags/c2=5&c10=1` 后加上 `?domain=javdb.com`,此时路由为 [`/javdb/tags/c2=5&c10=1?domain=javdb.com`](https://rsshub.app/javdb/tags/c2=5&c10=1?domain=javdb.com)
**排行榜**、**搜索**、**演員**、**片商** 参数同适用于 **分類** 参数的上述规则
:::
::: tip 提示
你可以通过指定 `limit` 参数来获取特定数量的条目,即可以通过在路由后方加上 `?limit=25`,默认为单次获取 20 个条目,即默认 `?limit=20`
因为该站有反爬检测,所以不应将此值调整过高
:::
### 主页
<Route author="nczitzk" example="/javdb" path="/javdb/:category?/:sort?/:filter?" :paramsDesc="['分类,见下表,默认为 `有碼`', '排序,见下表,默认为 `磁鏈更新排序`', '过滤,见下表,默认为 `可下载`']">
<Route author="nczitzk" example="/javdb" path="/javdb/:category?/:sort?/:filter?" :paramsDesc="['分类,见下表,默认为 `有碼`', '排序,见下表,默认为 `磁鏈更新排序`', '过滤,见下表,默认为 `可下载`']" anticrawler="1">
分类
@ -405,7 +423,7 @@ BT 之家的域名会变更,本路由以 <https://www.btbtt20.com> 为默认
### 分類
<Route author="nczitzk" example="/javdb/tags/c2=5&c10=1" path="/javdb/tags/:query?/:category?" :paramsDesc="['筛选,默认为 `c10=1`', '分类,见下表,默认为 `有碼`']">
<Route author="nczitzk" example="/javdb/tags/c2=5&c10=1" path="/javdb/tags/:query?/:category?" :paramsDesc="['筛选,默认为 `c10=1`', '分类,见下表,默认为 `有碼`']" anticrawler="1">
::: tip 提示
@ -425,7 +443,7 @@ BT 之家的域名会变更,本路由以 <https://www.btbtt20.com> 为默认
### 排行榜
<Route author="nczitzk" example="/javdb/rankings" path="/javdb/rankings/:category?/:time?" :paramsDesc="['分类,见下表,默认为 `有碼`', '时间,见下表,默认为 `日榜`']">
<Route author="nczitzk" example="/javdb/rankings" path="/javdb/rankings/:category?/:time?" :paramsDesc="['分类,见下表,默认为 `有碼`', '时间,见下表,默认为 `日榜`']" anticrawler="1">
分类
@ -443,7 +461,7 @@ BT 之家的域名会变更,本路由以 <https://www.btbtt20.com> 为默认
### 搜索
<Route author="nczitzk" example="/javdb/search/巨乳" path="/javdb/search/:keyword?/:filter?" :paramsDesc="['关键字,默认为空', '过滤,见下表,默认为 `可播放`']">
<Route author="nczitzk" example="/javdb/search/巨乳" path="/javdb/search/:keyword?/:filter?" :paramsDesc="['关键字,默认为空', '过滤,见下表,默认为 `可播放`']" anticrawler="1">
| 全部 | 可播放 | 單體作品 | 演員 | 片商 | 導演 | 系列 | 番號 | 可下載 | 字幕 | 預覽圖 |
| ---- | -------- | -------- | ----- | ----- | -------- | ------ | ---- | -------- | ----- | ------- |
@ -453,7 +471,7 @@ BT 之家的域名会变更,本路由以 <https://www.btbtt20.com> 为默认
### 演員
<Route author="nczitzk" example="/javdb/actors/R2Vg" path="/javdb/actors/:id/:filter?" :paramsDesc="['编号,可在演员页 URL 中找到', '过滤,见下表,默认为 `全部`']">
<Route author="nczitzk" example="/javdb/actors/R2Vg" path="/javdb/actors/:id/:filter?" :paramsDesc="['编号,可在演员页 URL 中找到', '过滤,见下表,默认为 `全部`']" anticrawler="1">
| 全部 | 可播放 | 單體作品 | 可下載 | 含字幕 |
| ---- | ------ | -------- | ------ | ------ |
@ -465,7 +483,7 @@ BT 之家的域名会变更,本路由以 <https://www.btbtt20.com> 为默认
### 系列
<Route author="nczitzk" example="/javdb/series/1NW" path="/javdb/series/:id/:filter?" :paramsDesc="['编号,可在系列页 URL 中找到', '过滤,见下表,默认为 `全部`']">
<Route author="nczitzk" example="/javdb/series/1NW" path="/javdb/series/:id/:filter?" :paramsDesc="['编号,可在系列页 URL 中找到', '过滤,见下表,默认为 `全部`']" anticrawler="1">
| 全部 | 可播放 | 單體作品 | 可下載 | 字幕 | 預覽圖 |
| ---- | -------- | -------- | -------- | ----- | ------- |
@ -477,7 +495,7 @@ BT 之家的域名会变更,本路由以 <https://www.btbtt20.com> 为默认
### 片商
<Route author="nczitzk" example="/javdb/makers/7R" path="/javdb/makers/:id/:filter?" :paramsDesc="['编号,可在片商页 URL 中找到', '过滤,见下表,默认为 `全部`']">
<Route author="nczitzk" example="/javdb/makers/7R" path="/javdb/makers/:id/:filter?" :paramsDesc="['编号,可在片商页 URL 中找到', '过滤,见下表,默认为 `全部`']" anticrawler="1">
| 全部 | 可播放 | 單體作品 | 可下載 | 字幕 | 預覽圖 |
| ---- | -------- | -------- | -------- | ----- | ------- |

View File

@ -3443,14 +3443,14 @@ router.get('/mercari/:type/:id', lazyloadRouteHandler('./routes/mercari/index'))
router.get('/notefolio/:caty?/:order?/:time?/:query?', lazyloadRouteHandler('./routes/notefolio/index'));
// JavDB
router.get('/javdb/home/:category?/:sort?/:filter?', lazyloadRouteHandler('./routes/javdb'));
router.get('/javdb/search/:keyword?/:filter?', lazyloadRouteHandler('./routes/javdb/search'));
router.get('/javdb/tags/:query?/:caty?', lazyloadRouteHandler('./routes/javdb/tags'));
router.get('/javdb/actors/:id/:filter?', lazyloadRouteHandler('./routes/javdb/actors'));
router.get('/javdb/makers/:id/:filter?', lazyloadRouteHandler('./routes/javdb/makers'));
router.get('/javdb/series/:id/:filter?', lazyloadRouteHandler('./routes/javdb/series'));
router.get('/javdb/rankings/:caty?/:time?', lazyloadRouteHandler('./routes/javdb/rankings'));
router.get('/javdb/:category?/:sort?/:filter?', lazyloadRouteHandler('./routes/javdb'));
// router.get('/javdb/home/:category?/:sort?/:filter?', lazyloadRouteHandler('./routes/javdb'));
// router.get('/javdb/search/:keyword?/:filter?', lazyloadRouteHandler('./routes/javdb/search'));
// router.get('/javdb/tags/:query?/:caty?', lazyloadRouteHandler('./routes/javdb/tags'));
// router.get('/javdb/actors/:id/:filter?', lazyloadRouteHandler('./routes/javdb/actors'));
// router.get('/javdb/makers/:id/:filter?', lazyloadRouteHandler('./routes/javdb/makers'));
// router.get('/javdb/series/:id/:filter?', lazyloadRouteHandler('./routes/javdb/series'));
// router.get('/javdb/rankings/:caty?/:time?', lazyloadRouteHandler('./routes/javdb/rankings'));
// router.get('/javdb/:category?/:sort?/:filter?', lazyloadRouteHandler('./routes/javdb'));
// World Economic Forum
router.get('/weforum/report/:lang?/:year?/:platform?', lazyloadRouteHandler('./routes/weforum/report'));

View File

@ -1,82 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
let rootUrl = 'https://javdb.com';
module.exports = {
ProcessItems: async (ctx, currentUrl, title) => {
let data;
try {
const response = await got({
method: 'get',
url: `${rootUrl}${currentUrl}`,
});
data = response.data;
} catch (err) {
rootUrl = rootUrl.replace('javdb', 'javdb7');
const response = await got({
method: 'get',
url: `${rootUrl}${currentUrl}`,
});
data = response.data;
}
const $ = cheerio.load(data);
$('.tags').remove();
const list = $('.grid-item a')
.slice(0, 15)
.map((_, item) => {
item = $(item);
return {
title: item.text(),
link: `${rootUrl}${item.attr('href')}`,
pubDate: Date.parse(item.find('.meta').text()),
};
})
.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);
item.enclosure_url = content('#magnets-content button[data-clipboard-text]').eq(0).attr('data-clipboard-text');
item.enclosure_type = 'application/x-bittorrent';
content('icon, .review-buttons, .copy-to-clipboard').remove();
content('#modal-review-watched, #modal-save-list').remove();
content('.video-cover').eq(1).remove();
content('img.video-cover').attr('src', content(this).parent().attr('href'));
content('.preview-images img').each(function () {
content(this).removeAttr('data-src');
content(this).attr('src', content(this).parent().attr('href'));
});
content('#preview-video').css('display', 'block');
item.description = content('.movie-info-panel .columns').html() + content('#magnets-content').html() + content('.preview-images').html();
return item;
})
)
);
const htmlTitle = $('title').text();
const subject = htmlTitle.indexOf('|') === -1 ? '' : htmlTitle.split('|')[0];
return {
title: subject === '' ? title : `${subject} - ${title}`,
link: `${rootUrl}${currentUrl}`,
item: items,
};
},
};

View File

@ -2,9 +2,9 @@ const utils = require('./utils');
module.exports = async (ctx) => {
const id = ctx.params.id;
const filter = ctx.params.filter || '';
const filter = ctx.params.filter ?? '';
const currentUrl = `/actors/${id}?t=${filter}`;
const currentUrl = `/actors/${id}${filter ? `?t=${filter}` : ''}`;
const filters = {
'': '',

View File

@ -1,9 +1,9 @@
const utils = require('./utils');
module.exports = async (ctx) => {
const category = ctx.params.caty || 'censored';
const sort = ctx.params.sort || '2';
const filter = ctx.params.filter || '1';
const category = ctx.params.category ?? 'censored';
const sort = ctx.params.sort ?? '2';
const filter = ctx.params.filter ?? '1';
const currentUrl = `${category === 'censored' ? '' : category}?vft=${filter}&vst=${sort}`;

View File

@ -0,0 +1,10 @@
module.exports = {
'/home/:category?/:sort?/:filter?': ['nczitzk'],
'/search/:keyword?/:filter?': ['nczitzk'],
'/tags/:query?/:category?': ['nczitzk'],
'/actors/:id/:filter?': ['nczitzk'],
'/makers/:id/:filter?': ['nczitzk'],
'/series/:id/:filter?': ['nczitzk'],
'/rankings/:category?/:time?': ['nczitzk'],
'/:category?/:sort?/:filter?': ['nczitzk'],
};

View File

@ -2,9 +2,9 @@ const utils = require('./utils');
module.exports = async (ctx) => {
const id = ctx.params.id;
const filter = ctx.params.filter || '';
const filter = ctx.params.filter ?? '';
const currentUrl = `/makers/${id}?f=${filter}`;
const currentUrl = `/makers/${id}${filter ? `?f=${filter}` : ''}`;
const filters = {
'': '',

49
lib/v2/javdb/radar.js Normal file
View File

@ -0,0 +1,49 @@
module.exports = {
'javdb.com': {
_name: 'JavDB',
'.': [
{
title: '主页',
docs: 'https://docs.rsshub.app/multimedia.html#javdb-zhu-ye',
source: ['/'],
target: '/javdb',
},
{
title: '分類',
docs: 'https://docs.rsshub.app/multimedia.html#javdb-fen-lei',
source: ['/tags/:category', '/'],
target: (params, url) => `/javdb/tags/:category/${new URL(url).searchParams.toString()}`,
},
{
title: '排行榜',
docs: 'https://docs.rsshub.app/multimedia.html#javdb-pai-hang-bang',
source: ['/rankings/:category', '/'],
target: (params, url) => `/javdb/rankings/:category/${new URL(url).searchParams.get('period') ?? ''}`,
},
{
title: '搜索',
docs: 'https://docs.rsshub.app/multimedia.html#javdb-sou-suo',
source: ['/search', '/'],
target: (params, url) => `/javdb/search/${new URL(url).searchParams.toString()}`,
},
{
title: '演員',
docs: 'https://docs.rsshub.app/multimedia.html#javdb-yan-yuan',
source: ['/actors/:id', '/'],
target: (params, url) => `/javdb/actors/:id/${new URL(url).searchParams.toString()}`,
},
{
title: '系列',
docs: 'https://docs.rsshub.app/multimedia.html#javdb-xi-lie',
source: ['/series/:id', '/'],
target: (params, url) => `/javdb/series/:id/${new URL(url).searchParams.toString()}`,
},
{
title: '片商',
docs: 'https://docs.rsshub.app/multimedia.html#javdb-pian-shang',
source: ['/makers/:id', '/'],
target: (params, url) => `/javdb/makers/:id/${new URL(url).searchParams.toString()}`,
},
],
},
};

View File

@ -1,8 +1,8 @@
const utils = require('./utils');
module.exports = async (ctx) => {
const category = ctx.params.category || 'censored';
const time = ctx.params.time || 'daily';
const category = ctx.params.category ?? 'censored';
const time = ctx.params.time ?? 'daily';
const currentUrl = `/rankings/video_${category}?period=${time}`;

10
lib/v2/javdb/router.js Normal file
View File

@ -0,0 +1,10 @@
module.exports = function (router) {
router.get('/home/:category?/:sort?/:filter?', require('./index'));
router.get('/search/:keyword?/:filter?', require('./search'));
router.get('/tags/:query?/:category?', require('./tags'));
router.get('/actors/:id/:filter?', require('./actors'));
router.get('/makers/:id/:filter?', require('./makers'));
router.get('/series/:id/:filter?', require('./series'));
router.get('/rankings/:category?/:time?', require('./rankings'));
router.get('/:category?/:sort?/:filter?', require('./index'));
};

View File

@ -1,10 +1,10 @@
const utils = require('./utils');
module.exports = async (ctx) => {
const filter = ctx.params.filter || '';
const keyword = ctx.params.keyword || '';
const filter = ctx.params.filter ?? '';
const keyword = ctx.params.keyword ?? '';
const currentUrl = `/search?q=${keyword}&f=${filter}`;
const currentUrl = `/search?q=${keyword}${filter ? `&f=${filter}` : ''}`;
const filters = {
'': '',

View File

@ -2,9 +2,9 @@ const utils = require('./utils');
module.exports = async (ctx) => {
const id = ctx.params.id;
const filter = ctx.params.filter || '';
const filter = ctx.params.filter ?? '';
const currentUrl = `/series/${id}?f=${filter}`;
const currentUrl = `/series/${id}${filter ? `?f=${filter}` : ''}`;
const filters = {
'': '',

View File

@ -1,8 +1,8 @@
const utils = require('./utils');
module.exports = async (ctx) => {
const category = ctx.params.category || 'censored';
const query = ctx.params.query || '';
const category = ctx.params.category ?? 'censored';
const query = ctx.params.query ?? '';
const currentUrl = `/tags${category === 'censored' ? '' : `/${category}`}?${query}`;

73
lib/v2/javdb/utils.js Normal file
View File

@ -0,0 +1,73 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = {
ProcessItems: async (ctx, currentUrl, title) => {
const domain = ctx.query.domain ?? 'javdb7.com';
const rootUrl = `https://${domain}`;
const response = await got({
method: 'get',
url: `${rootUrl}${currentUrl}`,
});
const $ = cheerio.load(response.data);
$('.tags, .tag-can-play').remove();
let items = $('.grid-item a')
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 20)
.toArray()
.map((item) => {
item = $(item);
return {
title: item.text(),
link: `${rootUrl}${item.attr('href')}`,
pubDate: parseDate(item.find('.meta').text()),
};
});
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
item.enclosure_type = 'application/x-bittorrent';
item.enclosure_url = content('#magnets-content button[data-clipboard-text]').first().attr('data-clipboard-text');
content('icon').remove();
content('#modal-review-watched, #modal-comment-warning, #modal-save-list').remove();
content('.review-buttons, .copy-to-clipboard, .preview-video-container, .play-button').remove();
content('.preview-images img').each(function () {
content(this).removeAttr('data-src');
content(this).attr('src', content(this).parent().attr('href'));
});
item.category = content('.panel-block .value a')
.toArray()
.map((v) => content(v).text());
item.author = content('.panel-block .value').last().parent().find('.value a').first().text();
item.description = content('.cover-container, .column-video-cover').html() + content('.movie-panel-info').html() + content('#magnets-content').html() + content('.preview-images').html();
return item;
})
)
);
const htmlTitle = $('title').text();
const subject = htmlTitle.indexOf('|') === -1 ? '' : htmlTitle.split('|')[0];
return {
title: subject === '' ? title : `${subject} - ${title}`,
link: `${rootUrl}${currentUrl}`,
item: items,
};
},
};