rsshub 1.0.0-master.af2252a → 1.0.0-master.af81923
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config.ts +41 -1
- package/lib/errors/index.tsx +2 -1
- package/lib/index.ts +48 -14
- package/lib/middleware/debug.ts +6 -4
- package/lib/middleware/header.ts +4 -2
- package/lib/registry.test.ts +24 -1
- package/lib/registry.ts +39 -8
- package/lib/router.js +0 -3
- package/lib/routes/141jav/index.ts +3 -0
- package/lib/routes/141ppv/index.ts +3 -0
- package/lib/routes/18comic/album.ts +59 -64
- package/lib/routes/18comic/index.ts +1 -0
- package/lib/routes/18comic/search.ts +53 -4
- package/lib/routes/18comic/utils.ts +70 -1
- package/lib/routes/2048/index.ts +1 -0
- package/lib/routes/30secondsofcode/utils.ts +0 -1
- package/lib/routes/7mmtv/index.ts +1 -0
- package/lib/routes/91porn/index.ts +1 -0
- package/lib/routes/95mm/tab.ts +1 -0
- package/lib/routes/aibase/daily.ts +110 -0
- package/lib/routes/aibase/util.ts +3 -0
- package/lib/routes/android/security-bulletin.ts +61 -0
- package/lib/routes/anthropic/research.ts +112 -0
- package/lib/routes/apnews/topics.ts +2 -1
- package/lib/routes/apnews/utils.ts +1 -1
- package/lib/routes/augmentcode/blog.ts +161 -0
- package/lib/routes/augmentcode/namespace.ts +9 -0
- package/lib/routes/augmentcode/templates/description.art +17 -0
- package/lib/routes/azul/namespace.ts +9 -0
- package/lib/routes/azul/packages.ts +105 -0
- package/lib/routes/bandisoft/history.ts +329 -0
- package/lib/routes/bandisoft/namespace.ts +9 -0
- package/lib/routes/banyuetan/index.ts +238 -0
- package/lib/routes/banyuetan/namespace.ts +9 -0
- package/lib/routes/banyuetan/templates/description.art +21 -0
- package/lib/routes/bfl/announcements.ts +127 -0
- package/lib/routes/bfl/namespace.ts +9 -0
- package/lib/routes/bilibili/dynamic.ts +4 -4
- package/lib/routes/bsky/keyword.ts +15 -10
- package/lib/routes/bupt/scss.ts +98 -0
- package/lib/routes/chikubi/index.ts +1 -0
- package/lib/routes/chikubi/tag.ts +1 -0
- package/lib/routes/chiphell/namespace.ts +7 -0
- package/lib/routes/chiphell/portal.ts +82 -0
- package/lib/routes/chocolatey/namespace.ts +9 -0
- package/lib/routes/chocolatey/packages.ts +122 -0
- package/lib/routes/civitai/user.ts +90 -0
- package/lib/routes/cmde/index.ts +1 -1
- package/lib/routes/cna/index.ts +2 -24
- package/lib/routes/cna/utils.ts +23 -0
- package/lib/routes/cna/web/index.ts +2 -22
- package/lib/routes/cockroachlabs/blog.ts +113 -0
- package/lib/routes/cockroachlabs/namespace.ts +7 -0
- package/lib/routes/cool18/index.ts +3 -0
- package/lib/routes/coomer/index.ts +1 -0
- package/lib/routes/copymanga/comic.ts +7 -9
- package/lib/routes/css-tricks/articles.ts +48 -0
- package/lib/routes/css-tricks/collections.ts +62 -0
- package/lib/routes/css-tricks/namespace.ts +8 -0
- package/lib/routes/css-tricks/popular.ts +39 -0
- package/lib/routes/css-tricks/utils.ts +103 -0
- package/lib/routes/daum/potplayer.ts +257 -0
- package/lib/routes/deepl/blog.ts +422 -0
- package/lib/routes/deepl/namespace.ts +9 -0
- package/lib/routes/deepl/templates/description.art +21 -0
- package/lib/routes/dnaindia/common.ts +1 -1
- package/lib/routes/douban/other/list.ts +3 -3
- package/lib/routes/e-hentai/index.ts +3 -0
- package/lib/routes/ehentai/tag.ts +1 -0
- package/lib/routes/everia/article.ts +21 -0
- package/lib/routes/everia/category.ts +54 -0
- package/lib/routes/everia/const.ts +4 -0
- package/lib/routes/everia/latest.ts +49 -0
- package/lib/routes/everia/namespace.ts +6 -0
- package/lib/routes/everia/search.ts +45 -0
- package/lib/routes/everia/tag.ts +54 -0
- package/lib/routes/fanbox/index.ts +1 -0
- package/lib/routes/fanbox/utils.ts +1 -1
- package/lib/routes/fansly/tag.ts +1 -0
- package/lib/routes/fantube/creator.ts +69 -0
- package/lib/routes/fantube/namespace.ts +7 -0
- package/lib/routes/fantube/templates/post.art +17 -0
- package/lib/routes/fantube/types.ts +100 -0
- package/lib/routes/fantube/utils.ts +268 -0
- package/lib/routes/freewechat/profile.ts +7 -1
- package/lib/routes/freexcomic/book.ts +3 -0
- package/lib/routes/geocaching/blogs.ts +2 -2
- package/lib/routes/gmu/namespace.ts +7 -0
- package/lib/routes/gmu/news.ts +136 -0
- package/lib/routes/gmu/yjs.ts +173 -0
- package/lib/routes/go/jihs/idwr.ts +137 -0
- package/lib/routes/google/search.ts +18 -30
- package/lib/routes/gov/chongqing/sydwgkzp.ts +22 -6
- package/lib/routes/gov/customs/list.ts +8 -3
- package/lib/routes/gov/hangzhou/zwfw.ts +1 -1
- package/lib/routes/gov/pbc/goutongjiaoliu.ts +1 -1
- package/lib/routes/gov/sichuan/deyang/govpublicinfo.ts +9 -10
- package/lib/routes/hellogithub/index.ts +1 -1
- package/lib/routes/huawei/developer/harmonyos/samplecode.ts +69 -0
- package/lib/routes/huawei/namespace.ts +7 -0
- package/lib/routes/hyperdash/namespace.ts +7 -0
- package/lib/routes/hyperdash/templates/description.art +34 -0
- package/lib/routes/hyperdash/top-traders.ts +84 -0
- package/lib/routes/hyperdash/utils.ts +49 -0
- package/lib/routes/ielts/index.ts +1 -1
- package/lib/routes/infoq/topic.ts +16 -13
- package/lib/routes/instagram/web-api/index.ts +17 -13
- package/lib/routes/instagram/web-api/utils.ts +46 -63
- package/lib/routes/javbus/index.ts +3 -0
- package/lib/routes/javdb/tags.ts +1 -0
- package/lib/routes/javlibrary/star.ts +1 -0
- package/lib/routes/javtiful/actress.ts +3 -0
- package/lib/routes/javtiful/channel.ts +3 -0
- package/lib/routes/javtrailers/casts.ts +3 -0
- package/lib/routes/jpxgmn/tab.ts +3 -0
- package/lib/routes/kemono/index.ts +1 -0
- package/lib/routes/konachan/post.ts +29 -18
- package/lib/routes/lineageos/changes.ts +79 -0
- package/lib/routes/lineageos/namespace.ts +9 -0
- package/lib/routes/linkedin/cn/renderer.ts +1 -1
- package/lib/routes/liquipedia/cs-matches.ts +42 -14
- package/lib/routes/literotica/new.ts +1 -0
- package/lib/routes/lofter/tag.ts +27 -3
- package/lib/routes/makerworld/contest.ts +51 -0
- package/lib/routes/makerworld/namespace.ts +7 -0
- package/lib/routes/makerworld/trending.ts +45 -0
- package/lib/routes/makerworld/user-upload.ts +54 -0
- package/lib/routes/makerworld/utils.ts +18 -0
- package/lib/routes/mangadex/_access.ts +111 -0
- package/lib/routes/mangadex/_constants.ts +75 -0
- package/lib/routes/mangadex/_feed.ts +184 -0
- package/lib/routes/mangadex/_profile.ts +47 -0
- package/lib/routes/mangadex/_utils.ts +49 -0
- package/lib/routes/mangadex/index.ts +16 -67
- package/lib/routes/mangadex/mdlist/feed.ts +156 -0
- package/lib/routes/mangadex/namespace.ts +2 -0
- package/lib/routes/mangadex/user/feed.ts +126 -0
- package/lib/routes/mangadex/user/follows.ts +149 -0
- package/lib/routes/mastodon/tag.ts +48 -0
- package/lib/routes/mathpix/blog.ts +155 -0
- package/lib/routes/mathpix/namespace.ts +9 -0
- package/lib/routes/mathpix/templates/description.art +21 -0
- package/lib/routes/melonbooks/search.ts +1 -0
- package/lib/routes/meta/ai-blog.ts +121 -0
- package/lib/routes/meta/namespace.ts +6 -0
- package/lib/routes/metacritic/index.ts +2 -2
- package/lib/routes/missav/new.ts +2 -1
- package/lib/routes/mixcloud/config.ts +129 -0
- package/lib/routes/mixcloud/index.ts +163 -107
- package/lib/routes/mixcloud/user-playlist.ts +31 -0
- package/lib/routes/mixi2/community.ts +72 -0
- package/lib/routes/mixi2/discovery.ts +52 -0
- package/lib/routes/mixi2/home.ts +51 -0
- package/lib/routes/mixi2/namespace.ts +8 -0
- package/lib/routes/mixi2/user.ts +77 -0
- package/lib/routes/mixi2/utils.ts +56 -0
- package/lib/routes/musify/index.ts +130 -0
- package/lib/routes/musify/namespace.ts +9 -0
- package/lib/routes/musikguru/namespace.ts +9 -0
- package/lib/routes/musikguru/news.ts +146 -0
- package/lib/routes/musikguru/templates/description.art +21 -0
- package/lib/routes/myfans/post.ts +1 -0
- package/lib/routes/nhentai/index.ts +1 -0
- package/lib/routes/nifd/research.ts +16 -0
- package/lib/routes/njust/cs.ts +58 -0
- package/lib/routes/njust/utils.ts +1 -1
- package/lib/routes/nuaa/utils/pypasswaf.ts +1 -1
- package/lib/routes/paulgraham/article.ts +2 -2
- package/lib/routes/picuki/profile.ts +4 -0
- package/lib/routes/playno1/av.ts +1 -0
- package/lib/routes/pornhub/model.ts +1 -0
- package/lib/routes/python/namespace.ts +9 -0
- package/lib/routes/python/release.ts +120 -0
- package/lib/routes/qipamaijia/index.ts +1 -0
- package/lib/routes/radio/album.ts +40 -49
- package/lib/routes/radio/templates/description.art +2 -2
- package/lib/routes/reuters/common.ts +0 -3
- package/lib/routes/samrdprc/namespace.ts +7 -0
- package/lib/routes/samrdprc/news.ts +79 -0
- package/lib/routes/sankei/namespace.ts +7 -0
- package/lib/routes/sankei/news.ts +68 -0
- package/lib/routes/sankei/topics.ts +71 -0
- package/lib/routes/scoop/apps.ts +188 -0
- package/lib/routes/scoop/namespace.ts +9 -0
- package/lib/routes/scoop/templates/description.art +56 -0
- package/lib/routes/sehuatang/index.ts +29 -31
- package/lib/routes/seu/cyber/index.ts +78 -0
- package/lib/routes/sis001/forum.ts +1 -0
- package/lib/routes/sjtu/seiee/icisee.ts +67 -0
- package/lib/routes/smartlink/index.ts +84 -0
- package/lib/routes/smartlink/namespace.ts +7 -0
- package/lib/routes/spankbang/new-videos.ts +1 -0
- package/lib/routes/stanford/blog.ts +77 -0
- package/lib/routes/stanford/namespace.ts +7 -0
- package/lib/routes/storm/channel.ts +80 -0
- package/lib/routes/t66y/index.ts +1 -0
- package/lib/routes/tju/yzb/index.ts +2 -2
- package/lib/routes/tver/namespace.ts +7 -0
- package/lib/routes/tver/series.ts +98 -0
- package/lib/routes/twitter/api/web-api/login.ts +1 -3
- package/lib/routes/twitter/api/web-api/utils.ts +24 -2
- package/lib/routes/twitter/namespace.ts +1 -0
- package/lib/routes/twitter/utils.ts +24 -16
- package/lib/routes/udn/breaking-news.ts +2 -2
- package/lib/routes/uestc/auto.ts +1 -1
- package/lib/routes/uestc/cqe.ts +1 -1
- package/lib/routes/uestc/scse.ts +1 -1
- package/lib/routes/uestc/sice.ts +1 -1
- package/lib/routes/uestc/sise.ts +1 -1
- package/lib/routes/visionias/daily-news-summary.ts +65 -0
- package/lib/routes/visionias/monthly-magazine.ts +68 -0
- package/lib/routes/visionias/news-today.ts +3 -13
- package/lib/routes/visionias/utils.ts +2 -2
- package/lib/routes/visionias/weekly-focus.ts +2 -2
- package/lib/routes/warhammer-community/namespace.ts +7 -0
- package/lib/routes/warhammer-community/news.ts +73 -0
- package/lib/routes/wdfxw/bookfree.ts +528 -0
- package/lib/routes/wdfxw/namespace.ts +8 -0
- package/lib/routes/wdfxw/templates/description.art +13 -0
- package/lib/routes/windsurf/blog.ts +118 -0
- package/lib/routes/windsurf/changelog.ts +100 -0
- package/lib/routes/windsurf/namespace.ts +9 -0
- package/lib/routes/windsurf/templates/description.art +21 -0
- package/lib/routes/xbookcn/blog.ts +1 -0
- package/lib/routes/xiaohongshu/user.ts +1 -1
- package/lib/routes/xiaohongshu/util.ts +3 -4
- package/lib/routes/xmanhua/index.ts +1 -0
- package/lib/routes/xueqiu/cookies.ts +1 -1
- package/lib/routes/xueqiu/user.ts +24 -1
- package/lib/routes/yande/post.ts +3 -0
- package/lib/routes/ymgal/game.ts +1 -0
- package/lib/routes/youtube/api/google.ts +27 -0
- package/lib/routes/youtube/community.ts +3 -1
- package/lib/routes/youtube/utils.ts +15 -13
- package/lib/routes/zhihu/execlib/x-zse-96-v3.ts +5 -5
- package/lib/types.ts +3 -0
- package/lib/utils/cache/index.ts +2 -2
- package/lib/utils/proxy/index.ts +102 -18
- package/lib/utils/proxy/multi-proxy.ts +139 -0
- package/lib/utils/proxy/unify-proxy.ts +3 -1
- package/lib/utils/puppeteer-utils.test.ts +1 -1
- package/lib/utils/puppeteer.test.ts +14 -27
- package/lib/utils/puppeteer.ts +51 -37
- package/lib/utils/readable-social.test.ts +65 -0
- package/lib/utils/readable-social.ts +15 -1
- package/lib/utils/request-rewriter/fetch.ts +42 -4
- package/package.json +45 -48
- package/lib/routes/go/niid/idwr-dl.ts +0 -104
- package/lib/routes/google/templates/description.art +0 -6
- package/lib/routes/mixcloud/queries.ts +0 -2274
- package/lib/routes-deprecated/chiphell/forum.js +0 -67
package/lib/config.ts
CHANGED
|
@@ -37,6 +37,7 @@ export type Config = {
|
|
|
37
37
|
};
|
|
38
38
|
// proxy
|
|
39
39
|
proxyUri?: string;
|
|
40
|
+
proxyUris?: string[];
|
|
40
41
|
proxy: {
|
|
41
42
|
protocol?: string;
|
|
42
43
|
host?: string;
|
|
@@ -44,6 +45,8 @@ export type Config = {
|
|
|
44
45
|
auth?: string;
|
|
45
46
|
url_regex: string;
|
|
46
47
|
strategy: 'on_retry' | 'all';
|
|
48
|
+
failoverTimeout?: number;
|
|
49
|
+
healthCheckInterval?: number;
|
|
47
50
|
};
|
|
48
51
|
pacUri?: string;
|
|
49
52
|
pacScript?: string;
|
|
@@ -73,6 +76,7 @@ export type Config = {
|
|
|
73
76
|
allow_user_hotlink_template: boolean;
|
|
74
77
|
filter_regex_engine: string;
|
|
75
78
|
allow_user_supply_unsafe_domain: boolean;
|
|
79
|
+
disable_nsfw: boolean;
|
|
76
80
|
};
|
|
77
81
|
suffix?: string;
|
|
78
82
|
titleLengthLimit: number;
|
|
@@ -216,6 +220,9 @@ export type Config = {
|
|
|
216
220
|
lightnovel: {
|
|
217
221
|
cookie?: string;
|
|
218
222
|
};
|
|
223
|
+
lofter: {
|
|
224
|
+
cookies?: string;
|
|
225
|
+
};
|
|
219
226
|
lorientlejour: {
|
|
220
227
|
token?: string;
|
|
221
228
|
username?: string;
|
|
@@ -226,6 +233,13 @@ export type Config = {
|
|
|
226
233
|
password?: string;
|
|
227
234
|
refreshToken?: string;
|
|
228
235
|
};
|
|
236
|
+
mangadex: {
|
|
237
|
+
username?: string;
|
|
238
|
+
password?: string;
|
|
239
|
+
clientId?: string;
|
|
240
|
+
clientSecret?: string;
|
|
241
|
+
refreshToken?: string;
|
|
242
|
+
};
|
|
229
243
|
manhuagui: {
|
|
230
244
|
cookie?: string;
|
|
231
245
|
};
|
|
@@ -248,6 +262,10 @@ export type Config = {
|
|
|
248
262
|
misskey: {
|
|
249
263
|
accessToken?: string;
|
|
250
264
|
};
|
|
265
|
+
mixi2: {
|
|
266
|
+
authToken?: string;
|
|
267
|
+
authKey?: string;
|
|
268
|
+
};
|
|
251
269
|
mox: {
|
|
252
270
|
cookie: string;
|
|
253
271
|
};
|
|
@@ -449,7 +467,7 @@ const calculateValue = () => {
|
|
|
449
467
|
const _value = {
|
|
450
468
|
// app config
|
|
451
469
|
disallowRobot: toBoolean(envs.DISALLOW_ROBOT, false),
|
|
452
|
-
enableCluster: envs.ENABLE_CLUSTER,
|
|
470
|
+
enableCluster: toBoolean(envs.ENABLE_CLUSTER, false),
|
|
453
471
|
isPackage: !!envs.IS_PACKAGE,
|
|
454
472
|
nodeName: envs.NODE_NAME,
|
|
455
473
|
puppeteerWSEndpoint: envs.PUPPETEER_WS_ENDPOINT,
|
|
@@ -480,6 +498,11 @@ const calculateValue = () => {
|
|
|
480
498
|
},
|
|
481
499
|
// proxy
|
|
482
500
|
proxyUri: envs.PROXY_URI,
|
|
501
|
+
proxyUris: envs.PROXY_URIS
|
|
502
|
+
? envs.PROXY_URIS.split(',')
|
|
503
|
+
.map((uri) => uri.trim())
|
|
504
|
+
.filter(Boolean)
|
|
505
|
+
: undefined,
|
|
483
506
|
proxy: {
|
|
484
507
|
protocol: envs.PROXY_PROTOCOL,
|
|
485
508
|
host: envs.PROXY_HOST,
|
|
@@ -487,6 +510,8 @@ const calculateValue = () => {
|
|
|
487
510
|
auth: envs.PROXY_AUTH,
|
|
488
511
|
url_regex: envs.PROXY_URL_REGEX || '.*',
|
|
489
512
|
strategy: envs.PROXY_STRATEGY || 'all', // all / on_retry
|
|
513
|
+
failoverTimeout: toInt(envs.PROXY_FAILOVER_TIMEOUT, 5000),
|
|
514
|
+
healthCheckInterval: toInt(envs.PROXY_HEALTH_CHECK_INTERVAL, 60000),
|
|
490
515
|
},
|
|
491
516
|
pacUri: envs.PAC_URI,
|
|
492
517
|
pacScript: envs.PAC_SCRIPT,
|
|
@@ -517,6 +542,7 @@ const calculateValue = () => {
|
|
|
517
542
|
allow_user_hotlink_template: toBoolean(envs.ALLOW_USER_HOTLINK_TEMPLATE, false),
|
|
518
543
|
filter_regex_engine: envs.FILTER_REGEX_ENGINE || 're2',
|
|
519
544
|
allow_user_supply_unsafe_domain: toBoolean(envs.ALLOW_USER_SUPPLY_UNSAFE_DOMAIN, false),
|
|
545
|
+
disable_nsfw: toBoolean(envs.DISABLE_NSFW, false),
|
|
520
546
|
},
|
|
521
547
|
suffix: envs.SUFFIX,
|
|
522
548
|
titleLengthLimit: toInt(envs.TITLE_LENGTH_LIMIT, 150),
|
|
@@ -660,6 +686,9 @@ const calculateValue = () => {
|
|
|
660
686
|
lightnovel: {
|
|
661
687
|
cookie: envs.SECURITY_KEY,
|
|
662
688
|
},
|
|
689
|
+
lofter: {
|
|
690
|
+
cookies: envs.LOFTER_COOKIE,
|
|
691
|
+
},
|
|
663
692
|
lorientlejour: {
|
|
664
693
|
token: envs.LORIENTLEJOUR_TOKEN,
|
|
665
694
|
username: envs.LORIENTLEJOUR_USERNAME,
|
|
@@ -670,6 +699,13 @@ const calculateValue = () => {
|
|
|
670
699
|
password: envs.MALAYSIAKINI_PASSWORD,
|
|
671
700
|
refreshToken: envs.MALAYSIAKINI_REFRESHTOKEN,
|
|
672
701
|
},
|
|
702
|
+
mangadex: {
|
|
703
|
+
username: envs.MANGADEX_USERNAME, // required when refresh-token is not set
|
|
704
|
+
password: envs.MANGADEX_PASSWORD, // required when refresh-token is not set
|
|
705
|
+
clientId: envs.MANGADEX_CLIENT_ID,
|
|
706
|
+
clientSecret: envs.MANGADEX_CLIENT_SECRET,
|
|
707
|
+
refreshToken: envs.MANGADEX_REFRESH_TOKEN,
|
|
708
|
+
},
|
|
673
709
|
manhuagui: {
|
|
674
710
|
cookie: envs.MHGUI_COOKIE,
|
|
675
711
|
},
|
|
@@ -692,6 +728,10 @@ const calculateValue = () => {
|
|
|
692
728
|
misskey: {
|
|
693
729
|
accessToken: envs.MISSKEY_ACCESS_TOKEN,
|
|
694
730
|
},
|
|
731
|
+
mixi2: {
|
|
732
|
+
authToken: envs.MIXI2_AUTH_TOKEN,
|
|
733
|
+
authKey: envs.MIXI2_AUTH_KEY,
|
|
734
|
+
},
|
|
695
735
|
mox: {
|
|
696
736
|
cookie: envs.MOX_COOKIE,
|
|
697
737
|
},
|
package/lib/errors/index.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type NotFoundHandler, type ErrorHandler } from 'hono';
|
|
2
|
+
import { routePath } from 'hono/route';
|
|
2
3
|
import { getDebugInfo, setDebugInfo } from '@/utils/debug-info';
|
|
3
4
|
import { config } from '@/config';
|
|
4
5
|
import * as Sentry from '@sentry/node';
|
|
@@ -11,7 +12,7 @@ import { requestMetric } from '@/utils/otel';
|
|
|
11
12
|
|
|
12
13
|
export const errorHandler: ErrorHandler = (error, ctx) => {
|
|
13
14
|
const requestPath = ctx.req.path;
|
|
14
|
-
const matchedRoute = ctx
|
|
15
|
+
const matchedRoute = routePath(ctx);
|
|
15
16
|
const hasMatchedRoute = matchedRoute !== '/*';
|
|
16
17
|
|
|
17
18
|
const debug = getDebugInfo();
|
package/lib/index.ts
CHANGED
|
@@ -3,25 +3,59 @@ import logger from '@/utils/logger';
|
|
|
3
3
|
import { getLocalhostAddress } from '@/utils/common-utils';
|
|
4
4
|
import { config } from '@/config';
|
|
5
5
|
import app from '@/app';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import cluster from 'node:cluster';
|
|
8
|
+
import process from 'node:process';
|
|
6
9
|
|
|
7
10
|
const port = config.connect.port;
|
|
8
11
|
const hostIPList = getLocalhostAddress();
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
logger.info(`🔗
|
|
13
|
+
let server;
|
|
14
|
+
if (config.enableCluster) {
|
|
15
|
+
if (cluster.isPrimary) {
|
|
16
|
+
logger.info(`🎉 RSSHub is running on port ${port}! Cheers!`);
|
|
17
|
+
logger.info(`🔗 Local: 👉 http://localhost:${port}`);
|
|
18
|
+
if (config.listenInaddrAny) {
|
|
19
|
+
for (const ip of hostIPList) {
|
|
20
|
+
logger.info(`🔗 Network: 👉 http://${ip}:${port}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
logger.info(`Primary ${process.pid} is running`);
|
|
25
|
+
|
|
26
|
+
const numCPUs = os.availableParallelism();
|
|
27
|
+
|
|
28
|
+
for (let i = 0; i < numCPUs; i++) {
|
|
29
|
+
cluster.fork();
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
logger.info(`Worker ${process.pid} is running`);
|
|
33
|
+
serve({
|
|
34
|
+
fetch: app.fetch,
|
|
35
|
+
hostname: config.listenInaddrAny ? '::' : '127.0.0.1',
|
|
36
|
+
port,
|
|
37
|
+
serverOptions: {
|
|
38
|
+
maxHeaderSize: 1024 * 32,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
logger.info(`🎉 RSSHub is running on port ${port}! Cheers!`);
|
|
44
|
+
logger.info(`🔗 Local: 👉 http://localhost:${port}`);
|
|
45
|
+
if (config.listenInaddrAny) {
|
|
46
|
+
for (const ip of hostIPList) {
|
|
47
|
+
logger.info(`🔗 Network: 👉 http://${ip}:${port}`);
|
|
48
|
+
}
|
|
15
49
|
}
|
|
16
|
-
}
|
|
17
50
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
51
|
+
server = serve({
|
|
52
|
+
fetch: app.fetch,
|
|
53
|
+
hostname: config.listenInaddrAny ? '::' : '127.0.0.1',
|
|
54
|
+
port,
|
|
55
|
+
serverOptions: {
|
|
56
|
+
maxHeaderSize: 1024 * 32,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
26
60
|
|
|
27
61
|
export default server;
|
package/lib/middleware/debug.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MiddlewareHandler } from 'hono';
|
|
2
|
+
import { routePath } from 'hono/route';
|
|
2
3
|
import { getDebugInfo, setDebugInfo } from '@/utils/debug-info';
|
|
3
4
|
|
|
4
5
|
const middleware: MiddlewareHandler = async (ctx, next) => {
|
|
@@ -17,11 +18,12 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
|
|
|
17
18
|
|
|
18
19
|
{
|
|
19
20
|
const debug = getDebugInfo();
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const rPath = routePath(ctx);
|
|
22
|
+
const hasMatchedRoute = rPath !== '/*';
|
|
23
|
+
if (!debug.routes[rPath] && hasMatchedRoute) {
|
|
24
|
+
debug.routes[rPath] = 0;
|
|
23
25
|
}
|
|
24
|
-
hasMatchedRoute && debug.routes[
|
|
26
|
+
hasMatchedRoute && debug.routes[rPath]++;
|
|
25
27
|
|
|
26
28
|
if (ctx.res.headers.get('RSSHub-Cache-Status')) {
|
|
27
29
|
debug.hitCache++;
|
package/lib/middleware/header.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MiddlewareHandler } from 'hono';
|
|
2
|
+
import { routePath } from 'hono/route';
|
|
2
3
|
import etagCalculate from 'etag';
|
|
3
4
|
import { config } from '@/config';
|
|
4
5
|
import { Data } from '@/types';
|
|
@@ -24,9 +25,10 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
|
|
|
24
25
|
ctx.header('Access-Control-Allow-Origin', config.allowOrigin || new URL(ctx.req.url).host);
|
|
25
26
|
|
|
26
27
|
await next();
|
|
28
|
+
const rPath = routePath(ctx);
|
|
27
29
|
|
|
28
|
-
if (
|
|
29
|
-
ctx.header('X-RSSHub-Route',
|
|
30
|
+
if (rPath !== '/*') {
|
|
31
|
+
ctx.header('X-RSSHub-Route', rPath);
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
const data: Data = ctx.get('data');
|
package/lib/registry.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
2
|
import app from '@/app';
|
|
3
3
|
import { config } from '@/config';
|
|
4
4
|
|
|
@@ -37,4 +37,27 @@ describe('registry', () => {
|
|
|
37
37
|
expect(response.headers.get('cache-control')).toBe('no-cache');
|
|
38
38
|
expect(await response.text()).toBe('ok');
|
|
39
39
|
});
|
|
40
|
+
|
|
41
|
+
it('namespaces respects DISABLE_NSFW=true', async () => {
|
|
42
|
+
vi.resetModules();
|
|
43
|
+
vi.stubEnv('DISABLE_NSFW', 'true');
|
|
44
|
+
|
|
45
|
+
const { namespaces } = await import('./registry');
|
|
46
|
+
|
|
47
|
+
// All routes in all namespaces should not have nsfw features
|
|
48
|
+
for (const ns of Object.values(namespaces)) {
|
|
49
|
+
for (const route of Object.values(ns.routes)) {
|
|
50
|
+
expect(route.features?.nsfw).not.toBe(true);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
expect(namespaces['2048']).toBeUndefined();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('namespaces includes NSFW routes when DISABLE_NSFW=false', async () => {
|
|
57
|
+
vi.resetModules();
|
|
58
|
+
vi.stubEnv('DISABLE_NSFW', 'false');
|
|
59
|
+
|
|
60
|
+
const { namespaces } = await import('./registry');
|
|
61
|
+
expect(namespaces['2048']).toBeDefined();
|
|
62
|
+
});
|
|
40
63
|
});
|
package/lib/registry.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { APIRoute, Namespace, Route } from '@/types';
|
|
2
2
|
import { directoryImport } from 'directory-import';
|
|
3
3
|
import { Hono, type Handler } from 'hono';
|
|
4
|
+
import { routePath } from 'hono/route';
|
|
4
5
|
import path from 'node:path';
|
|
5
6
|
import { serveStatic } from '@hono/node-server/serve-static';
|
|
6
7
|
import { config } from '@/config';
|
|
@@ -9,19 +10,38 @@ import index from '@/routes/index';
|
|
|
9
10
|
import healthz from '@/routes/healthz';
|
|
10
11
|
import robotstxt from '@/routes/robots.txt';
|
|
11
12
|
import metrics from '@/routes/metrics';
|
|
13
|
+
import logger from '@/utils/logger';
|
|
12
14
|
|
|
13
15
|
const __dirname = import.meta.dirname;
|
|
14
16
|
|
|
17
|
+
function isSafeRoutes(routes: RoutesType): boolean {
|
|
18
|
+
return Object.values(routes).every((route: Route) => !route.features?.nsfw);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function safeNamespaces(namespaces: NamespacesType): NamespacesType {
|
|
22
|
+
const safe: NamespacesType = {};
|
|
23
|
+
|
|
24
|
+
for (const [key, value] of Object.entries(namespaces)) {
|
|
25
|
+
if (value.routes === null || value.routes === undefined || isSafeRoutes(value.routes)) {
|
|
26
|
+
safe[key] = value;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return safe;
|
|
30
|
+
}
|
|
31
|
+
|
|
15
32
|
let modules: Record<string, { route: Route } | { namespace: Namespace }> = {};
|
|
16
|
-
|
|
33
|
+
|
|
34
|
+
type RoutesType = Record<
|
|
35
|
+
string,
|
|
36
|
+
Route & {
|
|
37
|
+
location: string;
|
|
38
|
+
}
|
|
39
|
+
>;
|
|
40
|
+
|
|
41
|
+
export type NamespacesType = Record<
|
|
17
42
|
string,
|
|
18
43
|
Namespace & {
|
|
19
|
-
routes:
|
|
20
|
-
string,
|
|
21
|
-
Route & {
|
|
22
|
-
location: string;
|
|
23
|
-
}
|
|
24
|
-
>;
|
|
44
|
+
routes: RoutesType;
|
|
25
45
|
apiRoutes: Record<
|
|
26
46
|
string,
|
|
27
47
|
APIRoute & {
|
|
@@ -29,7 +49,9 @@ let namespaces: Record<
|
|
|
29
49
|
}
|
|
30
50
|
>;
|
|
31
51
|
}
|
|
32
|
-
|
|
52
|
+
>;
|
|
53
|
+
|
|
54
|
+
let namespaces: NamespacesType = {};
|
|
33
55
|
|
|
34
56
|
switch (process.env.NODE_ENV) {
|
|
35
57
|
case 'production':
|
|
@@ -38,6 +60,10 @@ switch (process.env.NODE_ENV) {
|
|
|
38
60
|
case 'test':
|
|
39
61
|
// @ts-expect-error
|
|
40
62
|
namespaces = await import('../assets/build/routes.json');
|
|
63
|
+
if (namespaces.default) {
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
namespaces = namespaces.default;
|
|
66
|
+
}
|
|
41
67
|
break;
|
|
42
68
|
default:
|
|
43
69
|
modules = directoryImport({
|
|
@@ -46,6 +72,10 @@ switch (process.env.NODE_ENV) {
|
|
|
46
72
|
}) as typeof modules;
|
|
47
73
|
}
|
|
48
74
|
|
|
75
|
+
if (config.feature.disable_nsfw) {
|
|
76
|
+
namespaces = safeNamespaces(namespaces);
|
|
77
|
+
}
|
|
78
|
+
|
|
49
79
|
if (Object.keys(modules).length) {
|
|
50
80
|
for (const module in modules) {
|
|
51
81
|
const content = modules[module] as
|
|
@@ -157,6 +187,7 @@ for (const namespace in namespaces) {
|
|
|
157
187
|
|
|
158
188
|
for (const [path, routeData] of sortedRoutes) {
|
|
159
189
|
const wrappedHandler: Handler = async (ctx) => {
|
|
190
|
+
logger.debug(`Matched route: ${routePath(ctx)}`);
|
|
160
191
|
if (!ctx.get('data')) {
|
|
161
192
|
if (typeof routeData.handler !== 'function') {
|
|
162
193
|
if (process.env.NODE_ENV === 'test') {
|
package/lib/router.js
CHANGED
|
@@ -1023,9 +1023,6 @@ router.get('/jnu/yw/:type?', lazyloadRouteHandler('./routes/universities/jnu/yw/
|
|
|
1023
1023
|
// moxingfans
|
|
1024
1024
|
router.get('/moxingfans', lazyloadRouteHandler('./routes/moxingfans'));
|
|
1025
1025
|
|
|
1026
|
-
// Chiphell
|
|
1027
|
-
router.get('/chiphell/forum/:forumId?', lazyloadRouteHandler('./routes/chiphell/forum'));
|
|
1028
|
-
|
|
1029
1026
|
// 考研帮调剂信息
|
|
1030
1027
|
router.get('/kaoyan', lazyloadRouteHandler('./routes/kaoyan/kaoyan'));
|
|
1031
1028
|
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Route } from '@/types';
|
|
2
|
+
import { defaultDomain, getApiUrl, getRootUrl, processApiItems } from './utils';
|
|
3
|
+
import { art } from '@/utils/render';
|
|
4
|
+
import path from 'node:path';
|
|
2
5
|
import cache from '@/utils/cache';
|
|
3
|
-
import got from '@/utils/got';
|
|
4
|
-
import { load } from 'cheerio';
|
|
5
|
-
import { parseDate } from '@/utils/parse-date';
|
|
6
|
-
|
|
7
|
-
import { defaultDomain, getRootUrl } from './utils';
|
|
8
6
|
|
|
9
7
|
export const route: Route = {
|
|
10
8
|
path: '/album/:id',
|
|
@@ -37,71 +35,68 @@ async function handler(ctx) {
|
|
|
37
35
|
const id = ctx.req.param('id');
|
|
38
36
|
const { domain = defaultDomain } = ctx.req.query();
|
|
39
37
|
const rootUrl = getRootUrl(domain);
|
|
40
|
-
|
|
41
38
|
const currentUrl = `${rootUrl}/album/${id}`;
|
|
42
39
|
|
|
43
|
-
const
|
|
44
|
-
method: 'get',
|
|
45
|
-
url: currentUrl,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const $ = load(response.data);
|
|
40
|
+
const apiUrl = `${getApiUrl()}/album?id=${id}`;
|
|
49
41
|
|
|
50
|
-
const
|
|
51
|
-
.first()
|
|
52
|
-
.find('a')
|
|
53
|
-
.toArray()
|
|
54
|
-
.map((c) => $(c).text());
|
|
55
|
-
const author = $('span[data-type="author"]')
|
|
56
|
-
.first()
|
|
57
|
-
.find('a')
|
|
58
|
-
.toArray()
|
|
59
|
-
.map((a) => $(a).text())
|
|
60
|
-
.join(', ');
|
|
42
|
+
const apiResult = await processApiItems(apiUrl);
|
|
61
43
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
44
|
+
const category = apiResult.tags;
|
|
45
|
+
const author = apiResult.author.join(', ');
|
|
46
|
+
const description = apiResult.description;
|
|
47
|
+
const addTime = apiResult.addtime;
|
|
48
|
+
let results: any[] = [];
|
|
49
|
+
if (apiResult.series.length === 0) {
|
|
50
|
+
results.push({
|
|
51
|
+
title: apiResult.name,
|
|
52
|
+
link: `${rootUrl}/photo/${id}`,
|
|
53
|
+
guid: `${rootUrl}/photo/${id}`,
|
|
54
|
+
updated: new Date(addTime * 1000),
|
|
55
|
+
pubDate: new Date(addTime * 1000),
|
|
56
|
+
category,
|
|
57
|
+
author,
|
|
58
|
+
description: art(path.join(__dirname, 'templates/description.art'), {
|
|
59
|
+
introduction: description,
|
|
60
|
+
// 不取图片,因为专辑的图片会被分割排序,所以只取封面图
|
|
61
|
+
images: [`https://cdn-msp3.${domain}/media/albums/${id}_3x4.jpg`],
|
|
62
|
+
cover: `https://cdn-msp3.${domain}/media/albums/${id}_3x4.jpg`,
|
|
63
|
+
category,
|
|
64
|
+
}),
|
|
75
65
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
66
|
+
} else {
|
|
67
|
+
results = await Promise.all(
|
|
68
|
+
apiResult.series.map((item, index) =>
|
|
69
|
+
cache.tryGet(`18comic:album:${item.id}`, async () => {
|
|
70
|
+
const chapterApiUrl = `${getApiUrl()}/chapter?id=${item.id}`;
|
|
71
|
+
const chapterResult = await processApiItems(chapterApiUrl);
|
|
72
|
+
const result = {};
|
|
73
|
+
const chapterNum = index + 1;
|
|
74
|
+
result.title = `第${String(chapterNum)}話 ${item.name === '' ? `${String(chapterNum)}` : item.name}`;
|
|
75
|
+
result.link = `${rootUrl}/photo/${item.id}`;
|
|
76
|
+
result.guid = `${rootUrl}/photo/${item.id}`;
|
|
77
|
+
result.updated = new Date(chapterResult.addtime * 1000);
|
|
78
|
+
result.pubDate = addTime;
|
|
79
|
+
result.category = category;
|
|
80
|
+
result.author = author;
|
|
81
|
+
result.description = art(path.join(__dirname, 'templates/description.art'), {
|
|
82
|
+
introduction: description,
|
|
83
|
+
// 不取图片,因为专辑的图片会被分割排序,所以只取封面图
|
|
84
|
+
images: [`https://cdn-msp3.${domain}/media/albums/${item.id}_3x4.jpg`],
|
|
85
|
+
cover: `https://cdn-msp3.${domain}/media/albums/${item.id}_3x4.jpg`,
|
|
86
|
+
category,
|
|
87
|
+
});
|
|
88
|
+
return result;
|
|
89
|
+
})
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
results = results.reverse();
|
|
93
|
+
}
|
|
100
94
|
|
|
101
95
|
return {
|
|
102
|
-
title:
|
|
103
|
-
link: currentUrl,
|
|
104
|
-
item:
|
|
105
|
-
|
|
96
|
+
title: `${apiResult.name} - 禁漫天堂`,
|
|
97
|
+
link: currentUrl.replace(/\?$/, ''),
|
|
98
|
+
item: results,
|
|
99
|
+
allowEmpty: true,
|
|
100
|
+
description,
|
|
106
101
|
};
|
|
107
102
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Route } from '@/types';
|
|
2
|
-
import { defaultDomain, getRootUrl,
|
|
2
|
+
import { apiMapCategory, defaultDomain, getApiUrl, getRootUrl, processApiItems } from './utils';
|
|
3
|
+
import { parseDate } from '@/utils/parse-date';
|
|
4
|
+
import { art } from '@/utils/render';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import cache from '@/utils/cache';
|
|
3
7
|
|
|
4
8
|
export const route: Route = {
|
|
5
9
|
path: '/search/:option?/:category?/:keyword?/:time?/:order?',
|
|
@@ -40,11 +44,56 @@ async function handler(ctx) {
|
|
|
40
44
|
const category = ctx.req.param('category') ?? 'all';
|
|
41
45
|
const keyword = ctx.req.param('keyword') ?? '';
|
|
42
46
|
const time = ctx.req.param('time') ?? 'a';
|
|
43
|
-
const order = ctx.req.param('order') ?? 'mr';
|
|
44
47
|
const { domain = defaultDomain } = ctx.req.query();
|
|
45
48
|
const rootUrl = getRootUrl(domain);
|
|
46
|
-
|
|
49
|
+
let order = ctx.req.param('order') ?? 'mr';
|
|
47
50
|
const currentUrl = `${rootUrl}/search/${option}${category === 'all' ? '' : `/${category}`}${keyword ? `?search_query=${keyword}` : '?'}${time === 'a' ? '' : `&t=${time}`}${order === 'mr' ? '' : `&o=${order}`}`;
|
|
51
|
+
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 20;
|
|
52
|
+
|
|
53
|
+
let apiUrl = getApiUrl();
|
|
54
|
+
order = time === 'a' ? order : `${order}_${time}`;
|
|
55
|
+
apiUrl = `${apiUrl}/search?search_query=${keyword}&o=${order}`;
|
|
56
|
+
let apiResult = await processApiItems(apiUrl);
|
|
57
|
+
let filteredItemsByCategory = apiResult.content;
|
|
58
|
+
// Filter items by category if not 'all'
|
|
59
|
+
if (category !== 'all') {
|
|
60
|
+
filteredItemsByCategory = apiResult.content.filter((item) => item.category.title === apiMapCategory(category));
|
|
61
|
+
}
|
|
62
|
+
filteredItemsByCategory = filteredItemsByCategory.slice(0, limit);
|
|
63
|
+
const results = await Promise.all(
|
|
64
|
+
filteredItemsByCategory.map((item) =>
|
|
65
|
+
cache.tryGet(`18comic:search:${item.id}`, async () => {
|
|
66
|
+
const result = {};
|
|
67
|
+
result.title = item.name;
|
|
68
|
+
result.link = `${rootUrl}/album/${item.id}`;
|
|
69
|
+
result.guid = `18comic:/album/${item.id}`;
|
|
70
|
+
result.updated = parseDate(item.update_at);
|
|
71
|
+
apiUrl = `${getApiUrl()}/album?id=${item.id}`;
|
|
72
|
+
apiResult = await processApiItems(apiUrl);
|
|
73
|
+
result.pubDate = new Date(apiResult.addtime * 1000);
|
|
74
|
+
result.category = apiResult.tags.map((tag) => tag);
|
|
75
|
+
result.author = apiResult.author.map((a) => a).join(', ');
|
|
76
|
+
result.description = art(path.join(__dirname, 'templates/description.art'), {
|
|
77
|
+
introduction: apiResult.description,
|
|
78
|
+
images: [
|
|
79
|
+
`https://cdn-msp3.${domain}/media/albums/${item.id}_3x4.jpg`,
|
|
80
|
+
// 取得的预览图片会被分割排序,所以先只取封面图
|
|
81
|
+
// `https://cdn-msp3.${domain}/media/photos/${item.id}/00001.webp`,
|
|
82
|
+
// `https://cdn-msp3.${domain}/media/photos/${item.id}/00002.webp`,
|
|
83
|
+
// `https://cdn-msp3.${domain}/media/photos/${item.id}/00003.webp`,
|
|
84
|
+
],
|
|
85
|
+
cover: `https://cdn-msp3.${domain}/media/albums/${item.id}_3x4.jpg`,
|
|
86
|
+
category: result.category,
|
|
87
|
+
});
|
|
88
|
+
return result;
|
|
89
|
+
})
|
|
90
|
+
)
|
|
91
|
+
);
|
|
48
92
|
|
|
49
|
-
return
|
|
93
|
+
return {
|
|
94
|
+
title: `Search Results For '${keyword}' - 禁漫天堂`,
|
|
95
|
+
link: currentUrl.replace(/\?$/, ''),
|
|
96
|
+
item: results,
|
|
97
|
+
allowEmpty: true,
|
|
98
|
+
};
|
|
50
99
|
}
|