fix: 修复E站翻页功能 (#11780)
* fix: 修复E站翻页功能 * Update docs/picture.md * Update docs/picture.md * Update docs/picture.md ---------
This commit is contained in:
parent
c92e99304a
commit
36fe2e1d06
|
|
@ -155,15 +155,15 @@ pageClass: routes
|
|||
|
||||
### 收藏
|
||||
|
||||
<Route author="yindaheng98" example="/ehentai/favorites/0/posted/1" path="/ehentai/favorites/:favcat?/:order?/:page?/:routeParams?" :paramsDesc="['收藏夹编号','顺序:posted-按画廊发布时间排序,favorited-按添加收藏的时间排序', '爬获取第多少页的数据', '额外参数;请参阅上面的说明和表格']" anticrawler="1" supportBT="1" />
|
||||
<Route author="yindaheng98" example="/ehentai/favorites/0/posted" path="/ehentai/favorites/:favcat?/:order?/:page?/:routeParams?" :paramsDesc="['收藏夹编号','顺序:posted-按画廊发布时间排序,favorited-按添加收藏的时间排序', '翻页参数,对应E站地址中的next参数', '额外参数;请参阅上面的说明和表格']" anticrawler="1" supportBT="1" />
|
||||
|
||||
### 标签
|
||||
|
||||
<Route author="yindaheng98" example="/ehentai/tag/language:chinese/1" path="/ehentai/tag/:tag/:page?/:routeParams?" :paramsDesc="['标签', '爬获取第多少页的数据', '额外参数;请参阅上面的说明和表格']" anticrawler="1" supportBT="1" />
|
||||
<Route author="yindaheng98" example="/ehentai/tag/language:chinese" path="/ehentai/tag/:tag/:page?/:routeParams?" :paramsDesc="['标签', '翻页参数,对应E站地址中的next参数', '额外参数;请参阅上面的说明和表格']" anticrawler="1" supportBT="1" />
|
||||
|
||||
### 搜索
|
||||
|
||||
<Route author="yindaheng98" example="/ehentai/search/f_search=artist%3Amana%24/1" path="/ehentai/search/:params?/:page?/:routeParams?" :paramsDesc="['用于搜索的关键词。可在原网站搜索后复制 `https://e-hentai.org/?` 后面的内容', '爬获取第多少页的数据', '额外参数;请参阅上面的说明和表格']" anticrawler="1" supportBT="1" />
|
||||
<Route author="yindaheng98" example="/ehentai/search/f_search=artist%3Amama%24" path="/ehentai/search/:params?/:page?/:routeParams?" :paramsDesc="['用于搜索的关键词。可在原网站搜索后复制 `https://e-hentai.org/?` 后面的内容', '翻页参数,对应E站地址中的next参数', '额外参数;请参阅上面的说明和表格']" anticrawler="1" supportBT="1" />
|
||||
|
||||
## Elite Babes
|
||||
|
||||
|
|
|
|||
|
|
@ -192,25 +192,30 @@ async function gatherItemsByPage(cache, url, get_bittorrent = false, embed_thumb
|
|||
return updateBittorrent_url(cache, items);
|
||||
}
|
||||
|
||||
async function getFavoritesItems(cache, page, favcat, inline_set, get_bittorrent = false, embed_thumb = false) {
|
||||
async function getFavoritesItems(cache, favcat, inline_set, page = undefined, get_bittorrent = false, embed_thumb = false) {
|
||||
const response = await ehgot(`favorites.php?favcat=${favcat}&inline_set=${inline_set}`);
|
||||
if (parseInt(page) === 0) {
|
||||
if (page) {
|
||||
return gatherItemsByPage(cache, `favorites.php?favcat=${favcat}&next=${page}`, get_bittorrent, embed_thumb);
|
||||
} else {
|
||||
const items = await parsePage(cache, response.data, get_bittorrent, embed_thumb);
|
||||
return updateBittorrent_url(cache, items);
|
||||
}
|
||||
return gatherItemsByPage(cache, `favorites.php?page=${page}&favcat=${favcat}`, get_bittorrent, embed_thumb);
|
||||
}
|
||||
|
||||
function getSearchItems(cache, params, page = undefined, get_bittorrent = false, embed_thumb = false) {
|
||||
if (page) {
|
||||
return gatherItemsByPage(cache, `?page=${page}&${params}`, get_bittorrent, embed_thumb);
|
||||
return gatherItemsByPage(cache, `?${params}&next=${page}`, get_bittorrent, embed_thumb);
|
||||
} else {
|
||||
return gatherItemsByPage(cache, `?${params}`, get_bittorrent, embed_thumb);
|
||||
}
|
||||
}
|
||||
|
||||
function getTagItems(cache, tag, page, get_bittorrent = false, embed_thumb = false) {
|
||||
return gatherItemsByPage(cache, `tag/${tag}/${page}`, get_bittorrent, embed_thumb);
|
||||
if (page) {
|
||||
return gatherItemsByPage(cache, `tag/${tag}?next=${page}`, get_bittorrent, embed_thumb);
|
||||
} else {
|
||||
return gatherItemsByPage(cache, `tag/${tag}`, get_bittorrent, embed_thumb);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { getFavoritesItems, getSearchItems, getTagItems, has_cookie, from_ex };
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ module.exports = async (ctx) => {
|
|||
throw 'Ehentai favorites RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
|
||||
}
|
||||
const favcat = ctx.params.favcat ? parseInt(ctx.params.favcat) : 0;
|
||||
const page = ctx.params.page ? parseInt(ctx.params.page) : 0;
|
||||
const page = ctx.params.page;
|
||||
const routeParams = new URLSearchParams(ctx.params.routeParams);
|
||||
const bittorrent = routeParams.get('bittorrent') || false;
|
||||
const embed_thumb = routeParams.get('embed_thumb') || false;
|
||||
const inline_set = ctx.params.order === 'posted' ? 'fs_p' : 'fs_f';
|
||||
const items = await EhAPI.getFavoritesItems(ctx.cache, page, favcat, inline_set, bittorrent, embed_thumb);
|
||||
const items = await EhAPI.getFavoritesItems(ctx.cache, favcat, inline_set, page, bittorrent, embed_thumb);
|
||||
|
||||
if (EhAPI.from_ex) {
|
||||
ctx.state.data = {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ module.exports = async (ctx) => {
|
|||
let items;
|
||||
if (page) {
|
||||
// 如果定义了page,就要覆盖params
|
||||
params = params.replace(/&*page=[^&]$/, '').replace(/page=[^&]&/, '');
|
||||
items = await EhAPI.getSearchItems(ctx.cache, params, parseInt(page), bittorrent, embed_thumb);
|
||||
params = params.replace(/&*next=[^&]$/, '').replace(/next=[^&]&/, '');
|
||||
items = await EhAPI.getSearchItems(ctx.cache, params, page, bittorrent, embed_thumb);
|
||||
} else {
|
||||
items = await EhAPI.getSearchItems(ctx.cache, params, undefined, bittorrent, embed_thumb);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const EhAPI = require('./ehapi');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const page = ctx.params.page ? parseInt(ctx.params.page) : 0;
|
||||
const page = ctx.params.page;
|
||||
const tag = ctx.params.tag;
|
||||
const routeParams = new URLSearchParams(ctx.params.routeParams);
|
||||
const bittorrent = routeParams.get('bittorrent') || false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue