mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-01 14:57:14 +08:00
fix(route): 18comic (#12911)
* fix(route): 18comic * feat: allow user provided domain
This commit is contained in:
@@ -662,6 +662,12 @@ Sources
|
||||
|
||||
## 禁漫天堂
|
||||
|
||||
::: tip 提示
|
||||
|
||||
禁漫天堂有多个备用域名,本路由默认使用域名 <https://jmcomic.me>,若该域名无法访问,可以通过在路由最后加上 `?domain=<域名>` 指定路由访问的域名。如指定备用域名为 <https://jmcomic1.me>,则在所有禁漫天堂路由最后加上 `?domain=jmcomic1.me` 即可,此时路由为 [`/18comic?domain=jmcomic1.me`](https://rsshub.app/18comic?domain=jmcomic1.me)
|
||||
|
||||
:::
|
||||
|
||||
### 成人 A 漫
|
||||
|
||||
<Route author="nczitzk" example="/18comic" path="/18comic/:category?/:time?/:order?/:keyword?" :paramsDesc="['分类,见下表,默认为 `all` 即全部', '时间范围,见下表,默认为 `a` 即全部', '排列顺序,见下表,默认为 `mr` 即最新', '关键字,见下表,默认为空']">
|
||||
|
||||
@@ -2,10 +2,12 @@ const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const { rootUrl } = require('./utils');
|
||||
const { defaultDomain, getRootUrl } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
const { domain = defaultDomain } = ctx.query;
|
||||
const rootUrl = getRootUrl(domain, ctx);
|
||||
|
||||
const currentUrl = `${rootUrl}/album/${id}`;
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@ const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const { rootUrl } = require('./utils');
|
||||
const { defaultDomain, getRootUrl } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? '';
|
||||
const { domain = defaultDomain } = ctx.query;
|
||||
const rootUrl = getRootUrl(domain, ctx);
|
||||
|
||||
const currentUrl = `${rootUrl}/blogs${category ? `/${category}` : ''}`;
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
const { rootUrl, ProcessItems } = require('./utils');
|
||||
const { defaultDomain, getRootUrl, ProcessItems } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'all';
|
||||
const keyword = ctx.params.keyword ?? '';
|
||||
const time = ctx.params.time ?? 'a';
|
||||
const order = ctx.params.order ?? 'mr';
|
||||
const { domain = defaultDomain } = ctx.query;
|
||||
const rootUrl = getRootUrl(domain, ctx);
|
||||
|
||||
const currentUrl = `${rootUrl}/albums${category !== 'all' ? `/${category}` : ''}${keyword ? `?screen=${keyword}` : '?'}${time !== 'a' ? `&t=${time}` : ''}${order !== 'mr' ? `&o=${order}` : ''}`;
|
||||
|
||||
ctx.state.data = await ProcessItems(ctx, currentUrl);
|
||||
ctx.state.data = await ProcessItems(ctx, currentUrl, rootUrl);
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { rootUrl, ProcessItems } = require('./utils');
|
||||
const { defaultDomain, getRootUrl, ProcessItems } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const option = ctx.params.option ?? 'photos';
|
||||
@@ -6,8 +6,10 @@ module.exports = async (ctx) => {
|
||||
const keyword = ctx.params.keyword ?? '';
|
||||
const time = ctx.params.time ?? 'a';
|
||||
const order = ctx.params.order ?? 'mr';
|
||||
const { domain = defaultDomain } = ctx.query;
|
||||
const rootUrl = getRootUrl(domain, ctx);
|
||||
|
||||
const currentUrl = `${rootUrl}/search/${option}${category !== 'all' ? `/${category}` : ''}${keyword ? `?search_query=${keyword}` : '?'}${time !== 'a' ? `&t=${time}` : ''}${order !== 'mr' ? `&o=${order}` : ''}`;
|
||||
|
||||
ctx.state.data = await ProcessItems(ctx, currentUrl);
|
||||
ctx.state.data = await ProcessItems(ctx, currentUrl, rootUrl);
|
||||
};
|
||||
|
||||
+15
-4
@@ -3,13 +3,24 @@ const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const config = require('@/config').value;
|
||||
|
||||
const rootUrl = 'https://jmcomic.me';
|
||||
// list of address: https://jmcomic1.bet
|
||||
const defaultDomain = 'jmcomic1.me';
|
||||
// list of address: https://jmcomic2.bet
|
||||
const allowDomain = ['18comic.vip', '18comic.org', 'jmcomic.me', 'jmcomic1.me', 'jm-comic3.art', 'jm-comic.club', 'jm-comic2.ark'];
|
||||
|
||||
const getRootUrl = (domain, ctx) => {
|
||||
if (!config.feature.allow_user_supply_unsafe_domain && !allowDomain.includes(domain)) {
|
||||
ctx.throw(403, `This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`);
|
||||
}
|
||||
|
||||
return `https://${domain}`;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
rootUrl,
|
||||
ProcessItems: async (ctx, currentUrl) => {
|
||||
defaultDomain,
|
||||
getRootUrl,
|
||||
ProcessItems: async (ctx, currentUrl, rootUrl) => {
|
||||
currentUrl = currentUrl.replace(/\?$/, '');
|
||||
|
||||
const response = await got(currentUrl);
|
||||
|
||||
Reference in New Issue
Block a user