Files
RSSHub/lib/v2/ehentai/search.js
T
Howard YinandTonyRL 67d87e2eea feat(route): E站增加封面图嵌入RSS和封面图替换为代理网址的功能 (#9344)
* 增加封面图嵌入RSS的功能

* 增加EH封面图代理的功能

* 改用URLSearchParams代替querystring
增加对"Minimal", "Minimal+" and "Extended"页面模式的支持

* fix: matching logic

* refactor: migrate to v2

* docs: add missing description of EH_IMG_PROXY

* docs: remove ignoring EH_SK

Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
2022-04-21 23:03:55 +08:00

37 lines
1.2 KiB
JavaScript

const EhAPI = require('./ehapi');
module.exports = async (ctx) => {
const page = ctx.params.page;
let params = ctx.params.params;
const routeParams = new URLSearchParams(ctx.params.routeParams);
const bittorrent = routeParams.get('bittorrent') || false;
const embed_thumb = routeParams.get('embed_thumb') || false;
let items;
if (page) {
// 如果定义了page,就要覆盖params
params = params.replace(/&*page=[^&]$/, '').replace(/page=[^&]&/, '');
items = await EhAPI.getSearchItems(ctx.cache, params, parseInt(page), bittorrent, embed_thumb);
} else {
items = await EhAPI.getSearchItems(ctx.cache, params, undefined, bittorrent, embed_thumb);
}
let title = params;
const match = /f_search=([^&]+)/.exec(title);
if (match !== null) {
title = match[1];
}
if (EhAPI.from_ex) {
ctx.state.data = {
title: title + ' - ExHentai Search ',
link: `https://exhentai.org/?${params}`,
item: items,
};
} else {
ctx.state.data = {
title: title + ' - E-Hentai Search ',
link: `https://e-hentai.org/?${params}`,
item: items,
};
}
};