mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-29 18:06:31 +08:00
style: auto format
This commit is contained in:
+3
-3
@@ -429,9 +429,9 @@ Sources
|
||||
|
||||
<Route author="xueli-sherryli" example="/oreno3d/search/bronya/latest/1" path="/oreno3d/search/:keyword/:sort/:pagelimit?" :paramsDesc="['关键词', '排序方法,见下表', '最大爬取页面数量,默认为 1']" radar="1" rssbud="1">
|
||||
|
||||
| 高評価 | 急上昇 | 新着 | 人気 |
|
||||
| --------- | ------ | ------ | ---------- |
|
||||
| favorites | hot | latest | popularity |
|
||||
| 高評価 | 急上昇 | 新着 | 人気 |
|
||||
| --------- | --- | ------ | ---------- |
|
||||
| favorites | hot | latest | popularity |
|
||||
|
||||
</Route>
|
||||
|
||||
|
||||
+60
-59
@@ -2,7 +2,7 @@ const got = require('@/utils/got');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const cheerio = require('cheerio');
|
||||
const get_sec_page_data = require("./get_sec_page_data");
|
||||
const get_sec_page_data = require('./get_sec_page_data');
|
||||
|
||||
const rootUrl = 'https://oreno3d.com';
|
||||
|
||||
@@ -14,25 +14,21 @@ const sortRename = {
|
||||
};
|
||||
|
||||
function get_user_url(rootUrl, ctx, sort) {
|
||||
let userUrl = "";
|
||||
let userUrl = '';
|
||||
// 判断userurl获取位置
|
||||
if (ctx.params.keyword) {
|
||||
const keyword = ctx.params.keyword;
|
||||
userUrl = `${rootUrl}/search?sort=${sort}&keyword=${keyword}`;
|
||||
}
|
||||
else if (ctx.params.characterid) {
|
||||
} else if (ctx.params.characterid) {
|
||||
const characterid = ctx.params.characterid;
|
||||
userUrl = `${rootUrl}/characters/${characterid}?sort=${sort}`;
|
||||
}
|
||||
else if (ctx.params.authorid) {
|
||||
} else if (ctx.params.authorid) {
|
||||
const authorid = ctx.params.authorid;
|
||||
userUrl = `${rootUrl}/authors/${authorid}?sort=${sort}`;
|
||||
}
|
||||
else if (ctx.params.tagid) {
|
||||
} else if (ctx.params.tagid) {
|
||||
const tagid = ctx.params.tagid;
|
||||
userUrl = `${rootUrl}/tags/${tagid}?sort=${sort}`;
|
||||
}
|
||||
else if (ctx.params.originid) {
|
||||
} else if (ctx.params.originid) {
|
||||
const originid = ctx.params.originid;
|
||||
userUrl = `${rootUrl}/origins/${originid}?sort=${sort}`;
|
||||
}
|
||||
@@ -43,9 +39,9 @@ module.exports = async (ctx) => {
|
||||
function getLinksTitle(response) {
|
||||
const selector = 'a.box';
|
||||
const $ = cheerio.load(response.data);
|
||||
const title = $("div.g-main-list").find("h1.main-h").text();
|
||||
const title = $('div.g-main-list').find('h1.main-h').text();
|
||||
const list = $(selector);
|
||||
return {title, list};
|
||||
return { title, list };
|
||||
}
|
||||
// 数据爬取和分析
|
||||
async function getData(response) {
|
||||
@@ -54,48 +50,50 @@ module.exports = async (ctx) => {
|
||||
const title = getLinksTitle(response).title;
|
||||
const list = getLinksTitle(response).list;
|
||||
const items = await Promise.all(
|
||||
list.map(async(_, item) => {
|
||||
// 第一页,获取搜各视频地址
|
||||
const link = $(item).attr('href');
|
||||
// 第二页数据分析+缓存
|
||||
const sec_data = await get_sec_page_data(link);
|
||||
// 传递
|
||||
const raw_pic_link = sec_data.raw_pic_link;
|
||||
const video_name = sec_data.video_name;
|
||||
const authors = sec_data.authors;
|
||||
const origins = sec_data.origins;
|
||||
const characters = sec_data.characters;
|
||||
const tags = sec_data.tags;
|
||||
const desc = sec_data.desc;
|
||||
const iwara_link = sec_data.iwara_link;
|
||||
const oreno3d_link = sec_data.oreno3d_link;
|
||||
// 打包,缓存HTML
|
||||
const description = art(path.join(__dirname, 'templates/description.art'), {
|
||||
raw_pic_link,
|
||||
video_name,
|
||||
authors,
|
||||
origins,
|
||||
characters,
|
||||
tags,
|
||||
desc,
|
||||
iwara_link,
|
||||
oreno3d_link
|
||||
list
|
||||
.map(async (_, item) => {
|
||||
// 第一页,获取搜各视频地址
|
||||
const link = $(item).attr('href');
|
||||
// 第二页数据分析+缓存
|
||||
const sec_data = await get_sec_page_data(link);
|
||||
// 传递
|
||||
const raw_pic_link = sec_data.raw_pic_link;
|
||||
const video_name = sec_data.video_name;
|
||||
const authors = sec_data.authors;
|
||||
const origins = sec_data.origins;
|
||||
const characters = sec_data.characters;
|
||||
const tags = sec_data.tags;
|
||||
const desc = sec_data.desc;
|
||||
const iwara_link = sec_data.iwara_link;
|
||||
const oreno3d_link = sec_data.oreno3d_link;
|
||||
// 打包,缓存HTML
|
||||
const description = art(path.join(__dirname, 'templates/description.art'), {
|
||||
raw_pic_link,
|
||||
video_name,
|
||||
authors,
|
||||
origins,
|
||||
characters,
|
||||
tags,
|
||||
desc,
|
||||
iwara_link,
|
||||
oreno3d_link,
|
||||
});
|
||||
const title = `${video_name} - ${authors}`;
|
||||
const realData = await ctx.cache.tryGet(oreno3d_link, () => {
|
||||
const result = {
|
||||
title,
|
||||
author:authors,
|
||||
link: oreno3d_link,
|
||||
category: tags.split(' '),
|
||||
description
|
||||
};
|
||||
return result;
|
||||
});
|
||||
return realData;
|
||||
}).get(),
|
||||
);
|
||||
return {items, title};
|
||||
const title = `${video_name} - ${authors}`;
|
||||
const realData = await ctx.cache.tryGet(oreno3d_link, () => {
|
||||
const result = {
|
||||
title,
|
||||
author: authors,
|
||||
link: oreno3d_link,
|
||||
category: tags.split(' '),
|
||||
description,
|
||||
};
|
||||
return result;
|
||||
});
|
||||
return realData;
|
||||
})
|
||||
.get()
|
||||
);
|
||||
return { items, title };
|
||||
}
|
||||
// 参数定义
|
||||
const sort = ctx.params.sort;
|
||||
@@ -105,14 +103,17 @@ module.exports = async (ctx) => {
|
||||
// 确认最大页数并比较修改(同时也是获取第一页的内容)
|
||||
const response = await got(userUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
const maxPageSelector = "div.container > main > div.g-main-list > ul.pagination > li:last-child > a";
|
||||
const maxPageSelector = 'div.container > main > div.g-main-list > ul.pagination > li:last-child > a';
|
||||
// 页码判断
|
||||
if ($(maxPageSelector)) {
|
||||
const pageLink = new URLSearchParams($(maxPageSelector).attr('href'));
|
||||
const actualNum = pageLink.get("page");// 获取最大页数
|
||||
if (parseInt(pagelimit) >= parseInt(actualNum)) {pagelimit = actualNum;}
|
||||
const actualNum = pageLink.get('page'); // 获取最大页数
|
||||
if (parseInt(pagelimit) >= parseInt(actualNum)) {
|
||||
pagelimit = actualNum;
|
||||
}
|
||||
else {pagelimit = 1;}
|
||||
} else {
|
||||
pagelimit = 1;
|
||||
}
|
||||
// 构造网页数据的对应数组
|
||||
const responseList = [];
|
||||
// 将第一页的数据加入数组
|
||||
@@ -144,8 +145,8 @@ module.exports = async (ctx) => {
|
||||
}
|
||||
// 构造最终data
|
||||
const data = {
|
||||
title:tempData[0].title,
|
||||
item:realItem,
|
||||
title: tempData[0].title,
|
||||
item: realItem,
|
||||
};
|
||||
// 生成RSS源码
|
||||
ctx.state.data = {
|
||||
|
||||
Reference in New Issue
Block a user