mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
feat: 增加 Javlibrary 最佳评论 (#4008)
This commit is contained in:
@@ -1152,6 +1152,12 @@
|
||||
source: '/cn',
|
||||
target: '/javlibrary/videos/bestrated',
|
||||
},
|
||||
{
|
||||
title: '最佳评论',
|
||||
docs: 'https://docs.rsshub.app/multimedia.html#javlibrary',
|
||||
source: '/cn',
|
||||
target: '/javlibrary/bestreviews',
|
||||
},
|
||||
{
|
||||
title: '影星',
|
||||
docs: 'https://docs.rsshub.app/multimedia.html#javlibrary',
|
||||
|
||||
@@ -50,6 +50,10 @@ Official RSS: https://eztv.io/ezrss.xml
|
||||
|userwanted|userwatched|userowned|userposts|
|
||||
</Route>
|
||||
|
||||
### Bestreviews
|
||||
|
||||
<Route author="DCJaous" example="/javlibrary/bestreviews" path="/javlibrary/bestreviews" radar="1" />
|
||||
|
||||
## Nyaa
|
||||
|
||||
### Seatch Result
|
||||
|
||||
@@ -146,6 +146,10 @@ pageClass: routes
|
||||
|userwanted|userwatched|userowned|userposts|
|
||||
</Route>
|
||||
|
||||
### 最佳评论
|
||||
|
||||
<Route author="DCJaous" example="/javlibrary/bestreviews" path="/javlibrary/bestreviews" radar="1" />
|
||||
|
||||
## Last.fm
|
||||
|
||||
### 用户播放记录
|
||||
|
||||
@@ -2210,6 +2210,7 @@ router.get('/netease/ds/:id', require('./routes/netease/ds'));
|
||||
router.get('/javlibrary/users/:uid/:utype', require('./routes/javlibrary/users'));
|
||||
router.get('/javlibrary/videos/:vtype', require('./routes/javlibrary/videos'));
|
||||
router.get('/javlibrary/stars/:sid', require('./routes/javlibrary/stars'));
|
||||
router.get('/javlibrary/bestreviews', require('./routes/javlibrary/bestreviews'));
|
||||
|
||||
// Last.FM
|
||||
router.get('/lastfm/recent/:user', require('./routes/lastfm/recent'));
|
||||
|
||||
11
lib/routes/javlibrary/bestreviews.js
Normal file
11
lib/routes/javlibrary/bestreviews.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const { getVideoComments } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = 'http://www.javlibrary.com/cn/tl_bestreviews.php';
|
||||
const items = await getVideoComments(link);
|
||||
ctx.state.data = {
|
||||
title: 'Javlibrary - 最佳评论',
|
||||
link: link,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
const template = require('./utils');
|
||||
const { template } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const sid = ctx.params.sid;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
const cheerio = require('cheerio');
|
||||
const dateUtil = require('@/utils/date');
|
||||
const cloudscraper = require('cloudscraper');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const uid = ctx.params.uid;
|
||||
const link = `http://www.javlibrary.com/cn/userposts.php?u=${uid}`;
|
||||
const response = await cloudscraper.get(link);
|
||||
const $ = cheerio.load(response);
|
||||
const list = $('#video_comments > table');
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Javlibrary - ${uid} 发表的文章`,
|
||||
link: link,
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
// 文章内容只能抓取到 td.t textarea,若含有图片则替换[img]image-link[/img] => <img src="image-link" />
|
||||
let comments = item.find('textarea').text();
|
||||
comments = comments.replace(new RegExp('\\[img\\]', 'g'), '<img src="').replace(new RegExp('\\[\\/img\\]', 'g'), '" />');
|
||||
return {
|
||||
title: item.find('tbody > tr:nth-child(1) > td:nth-child(2)').text(),
|
||||
link: item.find('tbody > tr:nth-child(1) > td:nth-child(2) > a').attr('href'),
|
||||
description: `
|
||||
<table><tbody>
|
||||
<tr><td>${item.find('tbody > tr:nth-child(1) > td:nth-child(2)').html()}</td></tr>
|
||||
<tr><td>${comments}</td></tr>
|
||||
</tbody></table>`,
|
||||
pubDate: dateUtil(item.find('tbody > tr:nth-child(3) > td.date')),
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
@@ -1,12 +1,18 @@
|
||||
const template = require('./utils');
|
||||
const userposts = require('./userposts');
|
||||
const { template, getVideoComments } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const utype = ctx.params.utype;
|
||||
const uid = ctx.params.uid;
|
||||
|
||||
// userposts 页面结构不同,单独写路由
|
||||
if (utype === 'userposts') {
|
||||
await userposts(ctx);
|
||||
const uid = ctx.params.uid;
|
||||
const link = `http://www.javlibrary.com/cn/userposts.php?u=${uid}`;
|
||||
const items = await getVideoComments(link);
|
||||
ctx.state.data = {
|
||||
title: `Javlibrary - ${uid} 发表的文章`,
|
||||
link: link,
|
||||
item: items,
|
||||
};
|
||||
} else {
|
||||
ctx.state.data = {
|
||||
link: `http://www.javlibrary.com/cn/${utype}.php?u=${uid}`,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
const url = require('url');
|
||||
const cheerio = require('cheerio');
|
||||
const cloudscraper = require('cloudscraper');
|
||||
const dateUtil = require('@/utils/date');
|
||||
|
||||
// 通过传入不同的ctx.state.data.link 返回javlibrary 不同link的rss
|
||||
module.exports = async function template(ctx) {
|
||||
exports.template = async function template(ctx) {
|
||||
const link = ctx.state.data.link;
|
||||
const response = await cloudscraper.get(link);
|
||||
const $ = cheerio.load(response);
|
||||
@@ -37,3 +38,31 @@ module.exports = async function template(ctx) {
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
||||
exports.getVideoComments = async function getVideoComments(link) {
|
||||
const response = await cloudscraper.get(link);
|
||||
const $ = cheerio.load(response);
|
||||
const list = $('#video_comments > table');
|
||||
|
||||
return (
|
||||
list &&
|
||||
list
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
// 文章内容只能抓取到 td.t textarea,若含有图片则替换[img]image-link[/img] => <img src="image-link" />
|
||||
let comments = item.find('textarea').text();
|
||||
comments = comments.replace(new RegExp('\\[img\\]', 'g'), '<img src="').replace(new RegExp('\\[\\/img\\]', 'g'), '" />');
|
||||
return {
|
||||
title: item.find('tbody > tr:nth-child(1) > td:nth-child(2)').text(),
|
||||
link: item.find('tbody > tr:nth-child(1) > td:nth-child(2) > a').attr('href'),
|
||||
description: `
|
||||
<table><tbody>
|
||||
<tr><td>${item.find('tbody > tr:nth-child(1) > td:nth-child(2)').html()}</td></tr>
|
||||
<tr><td>${comments}</td></tr>
|
||||
</tbody></table>`,
|
||||
pubDate: dateUtil(item.find('tbody > tr:nth-child(3) > td.date')),
|
||||
};
|
||||
})
|
||||
.get()
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const template = require('./utils');
|
||||
const { template } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const vtype = ctx.params.vtype;
|
||||
|
||||
Reference in New Issue
Block a user