rsshub 1.0.0-master.b7b64b2 → 1.0.0-master.b7ec210
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/api/radar/rules/all.ts +3 -6
- package/lib/api/radar/rules/one.ts +3 -6
- package/lib/config.ts +12 -22
- package/lib/errors/index.tsx +1 -1
- package/lib/middleware/parameter.test.ts +22 -5
- package/lib/middleware/parameter.ts +47 -17
- package/lib/registry.test.ts +8 -0
- package/lib/registry.ts +2 -0
- package/lib/router.js +0 -3
- package/lib/routes/141jav/index.ts +25 -21
- package/lib/routes/141ppv/index.ts +24 -20
- package/lib/routes/51read/article.ts +82 -0
- package/lib/routes/51read/namespace.ts +6 -0
- package/lib/routes/aljazeera/index.ts +2 -2
- package/lib/routes/apnews/sitemap.ts +98 -0
- package/lib/routes/apnews/utils.ts +7 -5
- package/lib/routes/bilibili/api-interface.d.ts +1 -0
- package/lib/routes/bilibili/cache.ts +3 -1
- package/lib/routes/bilibili/dynamic.ts +5 -1
- package/lib/routes/bing/daily-wallpaper.ts +1 -1
- package/lib/routes/bjnews/cat.ts +43 -0
- package/lib/routes/bjnews/column.ts +43 -0
- package/lib/routes/bjnews/namespace.ts +6 -0
- package/lib/routes/bjnews/utils.ts +19 -0
- package/lib/routes/bjx/fd.ts +35 -26
- package/lib/routes/buaa/jiaowu.ts +1 -1
- package/lib/routes/buaa/lib/space/newbook.ts +171 -0
- package/lib/routes/buaa/lib/space/templates/newbook.art +44 -0
- package/lib/routes/cccfna/index.ts +2 -2
- package/lib/routes/cctv/category.ts +16 -12
- package/lib/routes/cctv/xwlb.ts +32 -10
- package/lib/routes/cffex/announcement.ts +73 -0
- package/lib/routes/cffex/namespace.ts +6 -0
- package/lib/routes/copymanga/comic.ts +3 -1
- package/lib/routes/devolverdigital/blog.ts +59 -42
- package/lib/routes/digitalcameraworld/news.ts +1 -1
- package/lib/routes/discord/channel.ts +10 -10
- package/lib/routes/discord/discord-api.ts +27 -32
- package/lib/routes/discord/templates/message.art +15 -0
- package/lib/routes/discourse/notifications.ts +2 -1
- package/lib/routes/fediverse/timeline.ts +35 -18
- package/lib/routes/flashcat/blog.ts +61 -0
- package/lib/routes/flashcat/namespace.ts +6 -0
- package/lib/routes/ftm/index.ts +60 -0
- package/lib/routes/ftm/namespace.ts +6 -0
- package/lib/routes/gdut/oa-news.ts +12 -17
- package/lib/routes/gisreportsonline/index.ts +60 -0
- package/lib/routes/gisreportsonline/namespace.ts +6 -0
- package/lib/routes/github/search.ts +20 -18
- package/lib/routes/google/research.ts +45 -0
- package/lib/routes/gov/chongqing/sydwgkzp.ts +4 -4
- package/lib/routes/gov/lswz/index.ts +289 -0
- package/lib/routes/gov/zj/ningbogzw-notice.ts +50 -0
- package/lib/routes/gov/zj/ningborsjnotice.ts +50 -0
- package/lib/routes/gq/news.ts +1 -1
- package/lib/routes/healthz.ts +8 -0
- package/lib/routes/hket/index.ts +80 -76
- package/lib/routes/hottoys/index.ts +63 -0
- package/lib/routes/hottoys/namespace.ts +6 -0
- package/lib/routes/imop/namespace.ts +10 -0
- package/lib/routes/imop/tianshu.ts +53 -0
- package/lib/routes/infzm/hot.ts +39 -0
- package/lib/routes/infzm/index.ts +3 -30
- package/lib/routes/infzm/utils.ts +34 -0
- package/lib/routes/inspirehep/author.ts +46 -0
- package/lib/routes/inspirehep/literature.ts +42 -0
- package/lib/routes/inspirehep/namespace.ts +7 -0
- package/lib/routes/inspirehep/types.ts +210 -0
- package/lib/routes/inspirehep/utils.ts +15 -0
- package/lib/routes/iwara/subscriptions.ts +1 -1
- package/lib/routes/javdb/actors.ts +6 -2
- package/lib/routes/joins/chinese.ts +218 -0
- package/lib/routes/joins/namespace.ts +8 -0
- package/lib/routes/joins/templates/description.art +17 -0
- package/lib/routes/juejin/dynamic.ts +114 -0
- package/lib/routes/kaopu/news.ts +3 -3
- package/lib/routes/keylol/index.ts +56 -11
- package/lib/routes/kurogames/namespace.ts +7 -0
- package/lib/routes/kurogames/wutheringwaves/news.ts +59 -0
- package/lib/routes/lmu/jobs.ts +96 -0
- package/lib/routes/lmu/namespace.ts +17 -0
- package/lib/routes/lmu/templates/jobPosting.art +11 -0
- package/lib/routes/mcmod/index.ts +105 -0
- package/lib/routes/mcmod/namespace.ts +6 -0
- package/lib/routes/mcmod/templates/mod.art +13 -0
- package/lib/routes/misskey/user-timeline.ts +42 -0
- package/lib/routes/misskey/utils.ts +41 -1
- package/lib/routes/nationalgeographic/latest-stories.ts +1 -1
- package/lib/routes/nationalgeographic/templates/stories.art +1 -1
- package/lib/routes/newyorker/news.ts +24 -17
- package/lib/routes/oschina/news.ts +2 -0
- package/lib/routes/people/index.ts +4 -2
- package/lib/routes/pixiv/search.ts +20 -1
- package/lib/routes/pixiv/utils.ts +3 -3
- package/lib/routes/psyche/topic.ts +1 -1
- package/lib/routes/psyche/type.ts +1 -1
- package/lib/routes/psyche/utils.ts +1 -1
- package/lib/routes/rebase/geekdaily.ts +35 -0
- package/lib/routes/rebase/namespace.ts +6 -0
- package/lib/routes/rss3/index.ts +447 -13
- package/lib/routes/rss3/interfaces/metadata.ts +67 -0
- package/lib/routes/rsshub/routes.ts +18 -12
- package/lib/routes/samd/news.ts +1 -1
- package/lib/routes/sara/index.ts +1 -1
- package/lib/routes/shiep/config.ts +4 -10
- package/lib/routes/shiep/index.ts +9 -9
- package/lib/routes/showstart/artist.ts +5 -4
- package/lib/routes/showstart/brand.ts +5 -4
- package/lib/routes/showstart/event.ts +8 -7
- package/lib/routes/showstart/search.ts +43 -9
- package/lib/routes/showstart/service.ts +81 -53
- package/lib/routes/showstart/site.ts +41 -0
- package/lib/routes/showstart/utils.ts +9 -8
- package/lib/routes/sjtu/jwc.ts +4 -1
- package/lib/routes/spotify/show.ts +1 -1
- package/lib/routes/springer/journal.ts +10 -12
- package/lib/routes/sspai/author.ts +1 -1
- package/lib/routes/sspai/column.ts +1 -1
- package/lib/routes/sspai/index.ts +1 -1
- package/lib/routes/sspai/matrix.ts +1 -1
- package/lib/routes/sspai/series-update.ts +1 -1
- package/lib/routes/sspai/tag.ts +1 -1
- package/lib/routes/sspai/topic.ts +1 -1
- package/lib/routes/sustainabilitymag/articles.ts +2 -0
- package/lib/routes/t66y/index.ts +29 -7
- package/lib/routes/techcrunch/news.ts +20 -29
- package/lib/routes/techcrunch/templates/description.art +7 -0
- package/lib/routes/telegram/channel.ts +3 -1
- package/lib/routes/test/index.ts +6 -36
- package/lib/routes/the/index.ts +210 -0
- package/lib/routes/the/namespace.ts +8 -0
- package/lib/routes/the/templates/description.art +27 -0
- package/lib/routes/the/util.ts +307 -0
- package/lib/routes/towardsdatascience/latest.ts +67 -0
- package/lib/routes/towardsdatascience/namespace.ts +6 -0
- package/lib/routes/tvb/news.ts +1 -0
- package/lib/routes/twitter/api/web-api/login.ts +66 -0
- package/lib/routes/twitter/api/web-api/utils.ts +49 -11
- package/lib/routes/twitter/home.ts +1 -1
- package/lib/routes/twitter/user.ts +1 -1
- package/lib/routes/twitter/utils.ts +4 -1
- package/lib/routes/uber/blog.ts +1 -1
- package/lib/routes/xiaohongshu/notes.ts +10 -2
- package/lib/routes/xiaohongshu/user.ts +23 -2
- package/lib/routes/yahoo/news/index.ts +1 -0
- package/lib/routes/yahoo/news/listid.ts +67 -0
- package/lib/routes/yahoo/news/utils.ts +8 -2
- package/lib/routes/yicai/carousel.ts +48 -0
- package/lib/routes/yicai/utils.ts +23 -17
- package/lib/routes/youtube/subscriptions.ts +1 -0
- package/lib/routes/zhihu/answers.ts +5 -1
- package/lib/routes/zhihu/execlib/x-zse-96-v3.ts +2 -0
- package/lib/routes/zhihu/namespace.ts +3 -0
- package/lib/routes/zhihu/utils.ts +12 -1
- package/lib/setup.test.ts +1 -1
- package/lib/types.ts +6 -0
- package/lib/utils/camelcase-keys.spec.ts +127 -0
- package/lib/utils/camelcase-keys.ts +27 -0
- package/lib/views/error.tsx +3 -3
- package/lib/views/index.tsx +4 -3
- package/lib/views/layout.tsx +1 -1
- package/package.json +34 -32
- package/lib/routes-deprecated/bjnews/news.js +0 -44
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { namespaces } from '@/registry';
|
|
2
2
|
import { parse } from 'tldts';
|
|
3
|
-
import {
|
|
3
|
+
import { RadarDomain } from '@/types';
|
|
4
4
|
import { createRoute, RouteHandler } from '@hono/zod-openapi';
|
|
5
5
|
|
|
6
6
|
const radar: {
|
|
7
|
-
[domain: string]:
|
|
8
|
-
_name: string;
|
|
9
|
-
[subdomain: string]: RadarItem[] | string;
|
|
10
|
-
};
|
|
7
|
+
[domain: string]: RadarDomain;
|
|
11
8
|
} = {};
|
|
12
9
|
|
|
13
10
|
for (const namespace in namespaces) {
|
|
@@ -23,7 +20,7 @@ for (const namespace in namespaces) {
|
|
|
23
20
|
if (!radar[domain]) {
|
|
24
21
|
radar[domain] = {
|
|
25
22
|
_name: namespaces[namespace].name,
|
|
26
|
-
};
|
|
23
|
+
} as RadarDomain;
|
|
27
24
|
}
|
|
28
25
|
if (!radar[domain][subdomain]) {
|
|
29
26
|
radar[domain][subdomain] = [];
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { namespaces } from '@/registry';
|
|
2
2
|
import { parse } from 'tldts';
|
|
3
|
-
import {
|
|
3
|
+
import { RadarDomain } from '@/types';
|
|
4
4
|
import { z, createRoute, RouteHandler } from '@hono/zod-openapi';
|
|
5
5
|
|
|
6
6
|
const radar: {
|
|
7
|
-
[domain: string]:
|
|
8
|
-
_name: string;
|
|
9
|
-
[subdomain: string]: RadarItem[] | string;
|
|
10
|
-
};
|
|
7
|
+
[domain: string]: RadarDomain;
|
|
11
8
|
} = {};
|
|
12
9
|
|
|
13
10
|
for (const namespace in namespaces) {
|
|
@@ -23,7 +20,7 @@ for (const namespace in namespaces) {
|
|
|
23
20
|
if (!radar[domain]) {
|
|
24
21
|
radar[domain] = {
|
|
25
22
|
_name: namespaces[namespace].name,
|
|
26
|
-
};
|
|
23
|
+
} as RadarDomain;
|
|
27
24
|
}
|
|
28
25
|
if (!radar[domain][subdomain]) {
|
|
29
26
|
radar[domain][subdomain] = [];
|
package/lib/config.ts
CHANGED
|
@@ -70,7 +70,9 @@ export type Config = {
|
|
|
70
70
|
temperature?: number;
|
|
71
71
|
maxTokens?: number;
|
|
72
72
|
endpoint: string;
|
|
73
|
-
|
|
73
|
+
inputOption: string;
|
|
74
|
+
promptTitle: string;
|
|
75
|
+
promptDescription: string;
|
|
74
76
|
};
|
|
75
77
|
bilibili: {
|
|
76
78
|
cookies: Record<string, string | undefined>;
|
|
@@ -168,6 +170,9 @@ export type Config = {
|
|
|
168
170
|
javdb: {
|
|
169
171
|
session?: string;
|
|
170
172
|
};
|
|
173
|
+
keylol: {
|
|
174
|
+
cookie?: string;
|
|
175
|
+
};
|
|
171
176
|
lastfm: {
|
|
172
177
|
api_key?: string;
|
|
173
178
|
};
|
|
@@ -433,7 +438,9 @@ const calculateValue = () => {
|
|
|
433
438
|
temperature: toInt(envs.OPENAI_TEMPERATURE, 0.2),
|
|
434
439
|
maxTokens: toInt(envs.OPENAI_MAX_TOKENS, 0) || undefined,
|
|
435
440
|
endpoint: envs.OPENAI_API_ENDPOINT || 'https://api.openai.com/v1',
|
|
436
|
-
|
|
441
|
+
inputOption: envs.OPENAI_INPUT_OPTION || 'description',
|
|
442
|
+
promptDescription: envs.OPENAI_PROMPT || 'Please summarize the following article and reply with markdown format.',
|
|
443
|
+
promptTitle: envs.OPENAI_PROMPT_TITLE || 'Please translate the following title into Simplified Chinese and reply only translated text.',
|
|
437
444
|
},
|
|
438
445
|
|
|
439
446
|
// Route-specific Configurations
|
|
@@ -534,6 +541,9 @@ const calculateValue = () => {
|
|
|
534
541
|
javdb: {
|
|
535
542
|
session: envs.JAVDB_SESSION,
|
|
536
543
|
},
|
|
544
|
+
keylol: {
|
|
545
|
+
cookie: envs.KEYLOL_COOKIE,
|
|
546
|
+
},
|
|
537
547
|
lastfm: {
|
|
538
548
|
api_key: envs.LASTFM_API_KEY,
|
|
539
549
|
},
|
|
@@ -713,26 +723,6 @@ calculateValue();
|
|
|
713
723
|
logger.error('Remote config load failed.', error);
|
|
714
724
|
}
|
|
715
725
|
}
|
|
716
|
-
|
|
717
|
-
if (!envs.DISABLE_UMAMI && envs.NODE_ENV === 'production') {
|
|
718
|
-
ofetch(`https://umami.rss3.io/api/send`, {
|
|
719
|
-
method: 'POST',
|
|
720
|
-
headers: {
|
|
721
|
-
'content-type': 'application/json',
|
|
722
|
-
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
|
|
723
|
-
},
|
|
724
|
-
body: JSON.stringify({
|
|
725
|
-
payload: {
|
|
726
|
-
hostname: 'rsshub.app',
|
|
727
|
-
language: 'en-US',
|
|
728
|
-
referrer: 'rsshub.app',
|
|
729
|
-
url: 'rsshub.app',
|
|
730
|
-
website: '239067cd-231f-4a3f-a478-cced11a84876',
|
|
731
|
-
},
|
|
732
|
-
type: 'event',
|
|
733
|
-
}),
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
726
|
})();
|
|
737
727
|
|
|
738
728
|
// @ts-expect-error value is set
|
package/lib/errors/index.tsx
CHANGED
|
@@ -69,7 +69,7 @@ export const errorHandler: ErrorHandler = (error, ctx) => {
|
|
|
69
69
|
logger.error(`Error in ${requestPath}: ${message}`);
|
|
70
70
|
requestMetric.error({ path: requestPath, method: ctx.req.method, status: ctx.res.status });
|
|
71
71
|
|
|
72
|
-
return config.isPackage
|
|
72
|
+
return config.isPackage || ctx.req.query('format') === 'json'
|
|
73
73
|
? ctx.json({
|
|
74
74
|
error: {
|
|
75
75
|
message: error.message ?? error,
|
|
@@ -427,7 +427,8 @@ describe('multi parameter', () => {
|
|
|
427
427
|
});
|
|
428
428
|
|
|
429
429
|
describe('openai', () => {
|
|
430
|
-
it(
|
|
430
|
+
it('processes both title and description', async () => {
|
|
431
|
+
config.openai.inputOption = 'both';
|
|
431
432
|
const responseWithGpt = await app.request('/test/gpt?chatgpt=true');
|
|
432
433
|
const responseNormal = await app.request('/test/gpt');
|
|
433
434
|
|
|
@@ -437,9 +438,25 @@ describe('openai', () => {
|
|
|
437
438
|
const parsedGpt = await parser.parseString(await responseWithGpt.text());
|
|
438
439
|
const parsedNormal = await parser.parseString(await responseNormal.text());
|
|
439
440
|
|
|
440
|
-
expect(parsedGpt.items[0].
|
|
441
|
-
expect(parsedGpt.items[0].
|
|
442
|
-
expect(parsedGpt.items[
|
|
443
|
-
expect(parsedGpt.items[
|
|
441
|
+
expect(parsedGpt.items[0].title).not.toBe(parsedNormal.items[0].title);
|
|
442
|
+
expect(parsedGpt.items[0].title).toContain('AI processed content.');
|
|
443
|
+
expect(parsedGpt.items[0].content).not.toBe(parsedNormal.items[0].content);
|
|
444
|
+
expect(parsedGpt.items[0].content).toContain('AI processed content.');
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
it('processes title or description', async () => {
|
|
448
|
+
// test title
|
|
449
|
+
config.openai.inputOption = 'title';
|
|
450
|
+
const responseTitleOnly = await app.request('/test/gpt?chatgpt=true');
|
|
451
|
+
const parsedTitleOnly = await parser.parseString(await responseTitleOnly.text());
|
|
452
|
+
expect(parsedTitleOnly.items[0].title).toContain('AI processed content.');
|
|
453
|
+
expect(parsedTitleOnly.items[0].content).not.toContain('AI processed content.');
|
|
454
|
+
|
|
455
|
+
// test description
|
|
456
|
+
config.openai.inputOption = 'description';
|
|
457
|
+
const responseDescriptionOnly = await app.request('/test/gpt?chatgpt=true');
|
|
458
|
+
const parsedDescriptionOnly = await parser.parseString(await responseDescriptionOnly.text());
|
|
459
|
+
expect(parsedDescriptionOnly.items[0].title).not.toContain('AI processed content.');
|
|
460
|
+
expect(parsedDescriptionOnly.items[0].content).toContain('AI processed content.');
|
|
444
461
|
});
|
|
445
462
|
});
|
|
@@ -32,7 +32,7 @@ const resolveRelativeLink = ($: CheerioAPI, elem: Element, attr: string, baseUrl
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
const
|
|
35
|
+
const getAiCompletion = async (prompt: string, text: string) => {
|
|
36
36
|
const apiUrl = `${config.openai.endpoint}/chat/completions`;
|
|
37
37
|
const response = await ofetch(apiUrl, {
|
|
38
38
|
method: 'POST',
|
|
@@ -40,8 +40,8 @@ const summarizeArticle = async (articleText: string) => {
|
|
|
40
40
|
model: config.openai.model,
|
|
41
41
|
max_tokens: config.openai.maxTokens,
|
|
42
42
|
messages: [
|
|
43
|
-
{ role: 'system', content:
|
|
44
|
-
{ role: 'user', content:
|
|
43
|
+
{ role: 'system', content: prompt },
|
|
44
|
+
{ role: 'user', content: text },
|
|
45
45
|
],
|
|
46
46
|
temperature: config.openai.temperature,
|
|
47
47
|
},
|
|
@@ -327,23 +327,53 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
|
|
|
327
327
|
if (ctx.req.query('chatgpt') && config.openai.apiKey) {
|
|
328
328
|
data.item = await Promise.all(
|
|
329
329
|
data.item.map(async (item) => {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
const summary_md = await summarizeArticle(text);
|
|
338
|
-
return md.render(summary_md);
|
|
330
|
+
try {
|
|
331
|
+
// handle description
|
|
332
|
+
if (config.openai.inputOption === 'description' && item.description) {
|
|
333
|
+
const description = await cache.tryGet(`openai:description:${item.link}`, async () => {
|
|
334
|
+
const description = convert(item.description!);
|
|
335
|
+
const descriptionMd = await getAiCompletion(config.openai.promptDescription, description);
|
|
336
|
+
return md.render(descriptionMd);
|
|
339
337
|
});
|
|
340
|
-
//
|
|
341
|
-
if (
|
|
342
|
-
item.description =
|
|
338
|
+
// add it to the description
|
|
339
|
+
if (description !== '') {
|
|
340
|
+
item.description = description + '<hr/><br/>' + item.description;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
// handle title
|
|
344
|
+
else if (config.openai.inputOption === 'title' && item.title) {
|
|
345
|
+
const title = await cache.tryGet(`openai:title:${item.link}`, async () => {
|
|
346
|
+
const title = convert(item.title!);
|
|
347
|
+
return await getAiCompletion(config.openai.promptTitle, title);
|
|
348
|
+
});
|
|
349
|
+
// replace the title
|
|
350
|
+
if (title !== '') {
|
|
351
|
+
item.title = title + '';
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
// handle both
|
|
355
|
+
else if (config.openai.inputOption === 'both' && item.title && item.description) {
|
|
356
|
+
const title = await cache.tryGet(`openai:title:${item.link}`, async () => {
|
|
357
|
+
const title = convert(item.title!);
|
|
358
|
+
return await getAiCompletion(config.openai.promptTitle, title);
|
|
359
|
+
});
|
|
360
|
+
// replace the title
|
|
361
|
+
if (title !== '') {
|
|
362
|
+
item.title = title + '';
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const description = await cache.tryGet(`openai:description:${item.link}`, async () => {
|
|
366
|
+
const description = convert(item.description!);
|
|
367
|
+
const descriptionMd = await getAiCompletion(config.openai.promptDescription, description);
|
|
368
|
+
return md.render(descriptionMd);
|
|
369
|
+
});
|
|
370
|
+
// add it to the description
|
|
371
|
+
if (description !== '') {
|
|
372
|
+
item.description = description + '<hr/><br/>' + item.description;
|
|
343
373
|
}
|
|
344
|
-
} catch {
|
|
345
|
-
// when openai failed, return default description and not write cache
|
|
346
374
|
}
|
|
375
|
+
} catch {
|
|
376
|
+
// when openai failed, return default content and not write cache
|
|
347
377
|
}
|
|
348
378
|
return item;
|
|
349
379
|
})
|
package/lib/registry.test.ts
CHANGED
|
@@ -29,4 +29,12 @@ describe('registry', () => {
|
|
|
29
29
|
const response = await app.request('/favicon.ico');
|
|
30
30
|
expect(response.status).toBe(200);
|
|
31
31
|
});
|
|
32
|
+
|
|
33
|
+
// healthz
|
|
34
|
+
it('/healthz', async () => {
|
|
35
|
+
const response = await app.request('/healthz');
|
|
36
|
+
expect(response.status).toBe(200);
|
|
37
|
+
expect(response.headers.get('cache-control')).toBe('no-cache');
|
|
38
|
+
expect(await response.text()).toBe('ok');
|
|
39
|
+
});
|
|
32
40
|
});
|
package/lib/registry.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { serveStatic } from '@hono/node-server/serve-static';
|
|
|
7
7
|
import { config } from '@/config';
|
|
8
8
|
|
|
9
9
|
import index from '@/routes/index';
|
|
10
|
+
import healthz from '@/routes/healthz';
|
|
10
11
|
import robotstxt from '@/routes/robots.txt';
|
|
11
12
|
import metrics from '@/routes/metrics';
|
|
12
13
|
|
|
@@ -100,6 +101,7 @@ for (const namespace in namespaces) {
|
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
app.get('/', index);
|
|
104
|
+
app.get('/healthz', healthz);
|
|
103
105
|
app.get('/robots.txt', robotstxt);
|
|
104
106
|
if (config.debugInfo) {
|
|
105
107
|
// Only enable tracing in debug mode
|
package/lib/router.js
CHANGED
|
@@ -66,9 +66,6 @@ router.get('/konachan.net/post/popular_recent/:period', lazyloadRouteHandler('./
|
|
|
66
66
|
// EZTV
|
|
67
67
|
router.get('/eztv/torrents/:imdb_id', lazyloadRouteHandler('./routes/eztv/imdb'));
|
|
68
68
|
|
|
69
|
-
// 新京报
|
|
70
|
-
router.get('/bjnews/:cat', lazyloadRouteHandler('./routes/bjnews/news'));
|
|
71
|
-
|
|
72
69
|
// 米哈游
|
|
73
70
|
router.get('/mihoyo/bh3/:type', lazyloadRouteHandler('./routes/mihoyo/bh3'));
|
|
74
71
|
router.get('/mihoyo/bh2/:type', lazyloadRouteHandler('./routes/mihoyo/bh2'));
|
|
@@ -10,49 +10,53 @@ import { art } from '@/utils/render';
|
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
|
|
12
12
|
export const route: Route = {
|
|
13
|
-
path: '
|
|
13
|
+
path: '/:type/:keyword{.*}?',
|
|
14
14
|
categories: ['multimedia'],
|
|
15
15
|
name: '通用',
|
|
16
16
|
maintainers: ['cgkings', 'nczitzk'],
|
|
17
|
+
parameters: { type: '类型,可查看下表的类型说明', keyword: '关键词,可查看下表的关键词说明' },
|
|
18
|
+
handler,
|
|
17
19
|
description: `**类型**
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
| 最新 | 热门 | 随机 | 指定演员 | 指定标签 | 日期 |
|
|
22
|
+
| ---- | ------- | ------ | -------- | -------- | ---- |
|
|
23
|
+
| new | popular | random | actress | tag | date |
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
**关键词**
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
| 空 | 日期范围 | 演员名 | 标签名 | 年月日 |
|
|
28
|
+
| -- | ----------- | ------------ | -------------- | ---------- |
|
|
29
|
+
| | 7 / 30 / 60 | Yua%20Mikami | Adult%20Awards | 2020/07/30 |
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
**示例说明**
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
- \`/141jav/new\`
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
仅当类型为 \`new\` \`popular\` 或 \`random\` 时关键词为 **空**
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
- \`/141jav/popular/30\`
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
\`popular\` \`random\` 类型的关键词可填写 \`7\` \`30\` 或 \`60\` 三个 **日期范围** 之一,分别对应 **7 天**、**30 天** 或 **60 天内**
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
- \`/141jav/actress/Yua%20Mikami\`
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
\`actress\` 类型的关键词必须填写 **演员名** ,可在 [此处](https://141jav.com/actress/) 演员单页链接中获取
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
- \`/141jav/tag/Adult%20Awards\`
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
\`tag\` 类型的关键词必须填写 **标签名** 且标签中的 \`/\` 必须替换为 \`%2F\` ,可在 [此处](https://141jav.com/tag/) 标签单页链接中获取
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
- \`/141jav/date/2020/07/30\`
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
handler,
|
|
51
|
+
\`date\` 类型的关键词必须填写 **日期(年/月/日)**`,
|
|
51
52
|
};
|
|
52
53
|
|
|
53
54
|
async function handler(ctx) {
|
|
54
55
|
const rootUrl = 'https://www.141jav.com';
|
|
55
|
-
const
|
|
56
|
+
const type = ctx.req.param('type');
|
|
57
|
+
const keyword = ctx.req.param('keyword') ?? '';
|
|
58
|
+
|
|
59
|
+
const currentUrl = `${rootUrl}/${type}${keyword ? `/${keyword}` : ''}`;
|
|
56
60
|
|
|
57
61
|
const response = await got({
|
|
58
62
|
method: 'get',
|
|
@@ -10,49 +10,53 @@ import { art } from '@/utils/render';
|
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
|
|
12
12
|
export const route: Route = {
|
|
13
|
-
path: '
|
|
13
|
+
path: '/:type/:keyword{.*}?',
|
|
14
14
|
categories: ['multimedia'],
|
|
15
15
|
name: '通用',
|
|
16
16
|
maintainers: ['cgkings', 'nczitzk'],
|
|
17
|
+
parameters: { type: '类型,可查看下表的类型说明', keyword: '关键词,可查看下表的关键词说明' },
|
|
17
18
|
handler,
|
|
18
19
|
description: `**类型**
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
| 最新 | 热门 | 随机 | 指定演员 | 指定标签 | 日期 |
|
|
22
|
+
| ---- | ------- | ------ | -------- | -------- | ---- |
|
|
23
|
+
| new | popular | random | actress | tag | date |
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
**关键词**
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
| 空 | 日期范围 | 演员名 | 标签名 | 年月日 |
|
|
28
|
+
| -- | ----------- | ------------ | -------------- | ---------- |
|
|
29
|
+
| | 7 / 30 / 60 | Yua%20Mikami | Adult%20Awards | 2020/07/30 |
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
**示例说明**
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
- \`/141ppv/new\`
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
仅当类型为 \`new\` \`popular\` 或 \`random\` 时关键词为 **空**
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
- \`/141ppv/popular/30\`
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
\`popular\` \`random\` 类型的关键词可填写 \`7\` \`30\` 或 \`60\` 三个 **日期范围** 之一,分别对应 **7 天**、**30 天** 或 **60 天内**
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
- \`/141ppv/actress/Yua%20Mikami\`
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
\`actress\` 类型的关键词必须填写 **演员名** ,可在 [此处](https://141ppv.com/actress/) 演员单页链接中获取
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
- \`/141ppv/tag/Adult%20Awards\`
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
\`tag\` 类型的关键词必须填写 **标签名** 且标签中的 \`/\` 必须替换为 \`%2F\` ,可在 [此处](https://141ppv.com/tag/) 标签单页链接中获取
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
- \`/141ppv/date/2020/07/30\`
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
\`date\` 类型的关键词必须填写 **日期(年/月/日)**`,
|
|
51
52
|
};
|
|
52
53
|
|
|
53
54
|
async function handler(ctx) {
|
|
54
55
|
const rootUrl = 'https://www.141ppv.com';
|
|
55
|
-
const
|
|
56
|
+
const type = ctx.req.param('type');
|
|
57
|
+
const keyword = ctx.req.param('keyword') ?? '';
|
|
58
|
+
|
|
59
|
+
const currentUrl = `${rootUrl}/${type}${keyword ? `/${keyword}` : ''}`;
|
|
56
60
|
|
|
57
61
|
const response = await got({
|
|
58
62
|
method: 'get',
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { load } from 'cheerio';
|
|
2
|
+
import cache from '@/utils/cache';
|
|
3
|
+
import ofetch from '@/utils/ofetch';
|
|
4
|
+
import type { Route, DataItem } from '@/types';
|
|
5
|
+
|
|
6
|
+
export const route: Route = {
|
|
7
|
+
path: '/article/:id',
|
|
8
|
+
name: '章节',
|
|
9
|
+
url: 'm.51read.org',
|
|
10
|
+
maintainers: ['lazwa34'],
|
|
11
|
+
example: '/51read/article/152685',
|
|
12
|
+
parameters: { id: '小说 id, 可在对应小说页 URL 中找到' },
|
|
13
|
+
categories: ['reading'],
|
|
14
|
+
features: {
|
|
15
|
+
requireConfig: false,
|
|
16
|
+
requirePuppeteer: false,
|
|
17
|
+
antiCrawler: false,
|
|
18
|
+
supportBT: false,
|
|
19
|
+
supportPodcast: false,
|
|
20
|
+
supportScihub: false,
|
|
21
|
+
},
|
|
22
|
+
radar: [
|
|
23
|
+
{
|
|
24
|
+
source: ['m.51read.org/xiaoshuo/:id'],
|
|
25
|
+
target: '/article/:id',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
source: ['51read.org/xiaoshuo/:id'],
|
|
29
|
+
target: '/article/:id',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
handler,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
async function handler(ctx) {
|
|
36
|
+
const { id } = ctx.req.param();
|
|
37
|
+
const link = `https://m.51read.org/xiaoshuo/${id}`;
|
|
38
|
+
const $book = load(await ofetch(link));
|
|
39
|
+
|
|
40
|
+
const chapter = `https://m.51read.org/zhangjiemulu/${id}`;
|
|
41
|
+
const $chapter = load(await ofetch(chapter));
|
|
42
|
+
|
|
43
|
+
const pageLength = $chapter('.ml-page select')
|
|
44
|
+
.find('option')
|
|
45
|
+
.map((_, option) => option.attribs.value)
|
|
46
|
+
.toArray().length;
|
|
47
|
+
|
|
48
|
+
const item = await createItem(chapter, pageLength);
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
title: $book('h1').text(),
|
|
52
|
+
description: $book('.bi-cot p').text(),
|
|
53
|
+
link,
|
|
54
|
+
item,
|
|
55
|
+
image: $book('.bi-img img').attr('src'),
|
|
56
|
+
author: $book('.bi-wt a').text(),
|
|
57
|
+
language: 'zh-cn',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const createItem = async (baseUrl: string, page: number) => {
|
|
62
|
+
const url = `${baseUrl}/${page}`;
|
|
63
|
+
const $latest = load(await ofetch(url));
|
|
64
|
+
const item = await Promise.all(
|
|
65
|
+
$latest('.kb-jp li>a')
|
|
66
|
+
.map((_, chapter) => buildItem(chapter.attribs.href))
|
|
67
|
+
.toArray()
|
|
68
|
+
.toReversed()
|
|
69
|
+
);
|
|
70
|
+
return item;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const buildItem = (url: string) =>
|
|
74
|
+
cache.tryGet(url, async () => {
|
|
75
|
+
const $ = load(await ofetch(url));
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
title: $('h1').text(),
|
|
79
|
+
description: $('.kb-cot').html() || '',
|
|
80
|
+
link: url,
|
|
81
|
+
};
|
|
82
|
+
}) as Promise<DataItem>;
|
|
@@ -7,7 +7,7 @@ import cache from '@/utils/cache';
|
|
|
7
7
|
import { load } from 'cheerio';
|
|
8
8
|
import { art } from '@/utils/render';
|
|
9
9
|
import path from 'node:path';
|
|
10
|
-
import
|
|
10
|
+
import ofetch from '@/utils/ofetch';
|
|
11
11
|
|
|
12
12
|
const languages = {
|
|
13
13
|
arabic: {
|
|
@@ -27,7 +27,7 @@ const languages = {
|
|
|
27
27
|
export const route: Route = {
|
|
28
28
|
path: '*',
|
|
29
29
|
name: 'Unknown',
|
|
30
|
-
maintainers: [],
|
|
30
|
+
maintainers: ['nczitzk'],
|
|
31
31
|
handler,
|
|
32
32
|
};
|
|
33
33
|
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Route, ViewType } from '@/types';
|
|
2
|
+
import { fetchArticle } from './utils';
|
|
3
|
+
import ofetch from '@/utils/ofetch';
|
|
4
|
+
import { load } from 'cheerio';
|
|
5
|
+
import { parseDate } from '@/utils/parse-date';
|
|
6
|
+
import asyncPool from 'tiny-async-pool';
|
|
7
|
+
import timezone from '@/utils/timezone';
|
|
8
|
+
const HOME_PAGE = 'https://apnews.com';
|
|
9
|
+
|
|
10
|
+
export const route: Route = {
|
|
11
|
+
path: '/sitemap/:route',
|
|
12
|
+
categories: ['traditional-media'],
|
|
13
|
+
example: '/apnews/sitemap/ap-sitemap-latest',
|
|
14
|
+
view: ViewType.Articles,
|
|
15
|
+
parameters: {
|
|
16
|
+
route: {
|
|
17
|
+
description: 'Route for sitemap, excluding the `.xml` extension',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
features: {
|
|
21
|
+
requireConfig: false,
|
|
22
|
+
requirePuppeteer: false,
|
|
23
|
+
antiCrawler: false,
|
|
24
|
+
supportBT: false,
|
|
25
|
+
supportPodcast: false,
|
|
26
|
+
supportScihub: false,
|
|
27
|
+
},
|
|
28
|
+
radar: [
|
|
29
|
+
{
|
|
30
|
+
source: ['apnews.com/'],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
name: 'Sitemap',
|
|
34
|
+
maintainers: ['zoenglinghou', 'mjysci', 'TonyRL', 'dzx-dzx'],
|
|
35
|
+
handler,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
async function handler(ctx) {
|
|
39
|
+
const route = ctx.req.param('route');
|
|
40
|
+
const url = `${HOME_PAGE}/${route}.xml`;
|
|
41
|
+
const response = await ofetch(url);
|
|
42
|
+
const $ = load(response);
|
|
43
|
+
|
|
44
|
+
const list = $('urlset url')
|
|
45
|
+
.toArray()
|
|
46
|
+
.map((e) => {
|
|
47
|
+
const LANGUAGE_MAP = new Map([
|
|
48
|
+
['eng', 'en'],
|
|
49
|
+
['spa', 'es'],
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
const title = $(e)
|
|
53
|
+
.find(String.raw`news\:title`)
|
|
54
|
+
.text();
|
|
55
|
+
const pubDate = parseDate(
|
|
56
|
+
$(e)
|
|
57
|
+
.find(String.raw`news\:publication_date`)
|
|
58
|
+
.text()
|
|
59
|
+
);
|
|
60
|
+
const lastmod = timezone(parseDate($(e).find(`lastmod`).text()), -4);
|
|
61
|
+
const language = LANGUAGE_MAP.get(
|
|
62
|
+
$(e)
|
|
63
|
+
.find(String.raw`news\:language`)
|
|
64
|
+
.text()
|
|
65
|
+
);
|
|
66
|
+
let res = { link: $(e).find('loc').text() };
|
|
67
|
+
if (title) {
|
|
68
|
+
res = Object.assign(res, { title });
|
|
69
|
+
}
|
|
70
|
+
if (pubDate.toString() !== 'Invalid Date') {
|
|
71
|
+
res = Object.assign(res, { pubDate });
|
|
72
|
+
}
|
|
73
|
+
if (language) {
|
|
74
|
+
res = Object.assign(res, { language });
|
|
75
|
+
}
|
|
76
|
+
if (lastmod.toString() !== 'Invalid Date') {
|
|
77
|
+
res = Object.assign(res, { lastmod });
|
|
78
|
+
}
|
|
79
|
+
return res;
|
|
80
|
+
})
|
|
81
|
+
.filter((e) => Boolean(e.link) && !new URL(e.link).pathname.split('/').includes('hub'))
|
|
82
|
+
.sort((a, b) => (a.pubDate && b.pubDate ? b.pubDate - a.pubDate : b.lastmod - a.lastmod))
|
|
83
|
+
.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 20);
|
|
84
|
+
|
|
85
|
+
const items = await asyncPoolAll(20, list, (item) => fetchArticle(item));
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
title: `AP News sitemap:${route}`,
|
|
89
|
+
item: items,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
async function asyncPoolAll<IN, OUT>(poolLimit: number, array: readonly IN[], iteratorFn: (generator: IN) => Promise<OUT>) {
|
|
93
|
+
const results: Awaited<OUT[]> = [];
|
|
94
|
+
for await (const result of asyncPool(poolLimit, array, iteratorFn)) {
|
|
95
|
+
results.push(result);
|
|
96
|
+
}
|
|
97
|
+
return results;
|
|
98
|
+
}
|