rsshub 1.0.0-master.d6c1b77 → 1.0.0-master.d6ea759
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 +23 -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.ts +3 -0
- package/lib/router.js +0 -3
- 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/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/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/bsky/keyword.ts +15 -10
- package/lib/routes/bupt/scss.ts +98 -0
- package/lib/routes/chiphell/namespace.ts +7 -0
- package/lib/routes/chiphell/portal.ts +82 -0
- package/lib/routes/civitai/user.ts +90 -0
- 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/copymanga/comic.ts +7 -9
- package/lib/routes/daum/potplayer.ts +257 -0
- package/lib/routes/douban/other/list.ts +3 -3
- 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/search.ts +45 -0
- package/lib/routes/everia/tag.ts +20 -40
- package/lib/routes/freewechat/profile.ts +7 -1
- 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/customs/list.ts +7 -2
- 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/konachan/post.ts +26 -18
- 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/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/njust/cs.ts +58 -0
- package/lib/routes/python/namespace.ts +9 -0
- package/lib/routes/python/release.ts +120 -0
- package/lib/routes/radio/album.ts +40 -49
- package/lib/routes/radio/templates/description.art +2 -2
- 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/sjtu/seiee/icisee.ts +67 -0
- package/lib/routes/smartlink/index.ts +74 -0
- package/lib/routes/smartlink/namespace.ts +7 -0
- package/lib/routes/storm/channel.ts +80 -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/utils.ts +24 -2
- package/lib/routes/twitter/namespace.ts +1 -0
- package/lib/routes/twitter/utils.ts +24 -16
- package/lib/routes/warhammer-community/namespace.ts +7 -0
- package/lib/routes/warhammer-community/news.ts +73 -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/xiaohongshu/user.ts +1 -1
- package/lib/routes/xiaohongshu/util.ts +2 -1
- package/lib/routes/xueqiu/user.ts +23 -0
- package/lib/routes/youtube/api/google.ts +27 -0
- package/lib/routes/youtube/utils.ts +15 -13
- package/lib/utils/readable-social.test.ts +65 -0
- package/lib/utils/readable-social.ts +15 -1
- package/package.json +30 -29
- package/lib/routes/go/niid/idwr-dl.ts +0 -104
- package/lib/routes/google/templates/description.art +0 -6
- package/lib/routes-deprecated/chiphell/forum.js +0 -67
package/lib/config.ts
CHANGED
|
@@ -226,6 +226,13 @@ export type Config = {
|
|
|
226
226
|
password?: string;
|
|
227
227
|
refreshToken?: string;
|
|
228
228
|
};
|
|
229
|
+
mangadex: {
|
|
230
|
+
username?: string;
|
|
231
|
+
password?: string;
|
|
232
|
+
clientId?: string;
|
|
233
|
+
clientSecret?: string;
|
|
234
|
+
refreshToken?: string;
|
|
235
|
+
};
|
|
229
236
|
manhuagui: {
|
|
230
237
|
cookie?: string;
|
|
231
238
|
};
|
|
@@ -248,6 +255,10 @@ export type Config = {
|
|
|
248
255
|
misskey: {
|
|
249
256
|
accessToken?: string;
|
|
250
257
|
};
|
|
258
|
+
mixi2: {
|
|
259
|
+
authToken?: string;
|
|
260
|
+
authKey?: string;
|
|
261
|
+
};
|
|
251
262
|
mox: {
|
|
252
263
|
cookie: string;
|
|
253
264
|
};
|
|
@@ -449,7 +460,7 @@ const calculateValue = () => {
|
|
|
449
460
|
const _value = {
|
|
450
461
|
// app config
|
|
451
462
|
disallowRobot: toBoolean(envs.DISALLOW_ROBOT, false),
|
|
452
|
-
enableCluster: envs.ENABLE_CLUSTER,
|
|
463
|
+
enableCluster: toBoolean(envs.ENABLE_CLUSTER, false),
|
|
453
464
|
isPackage: !!envs.IS_PACKAGE,
|
|
454
465
|
nodeName: envs.NODE_NAME,
|
|
455
466
|
puppeteerWSEndpoint: envs.PUPPETEER_WS_ENDPOINT,
|
|
@@ -670,6 +681,13 @@ const calculateValue = () => {
|
|
|
670
681
|
password: envs.MALAYSIAKINI_PASSWORD,
|
|
671
682
|
refreshToken: envs.MALAYSIAKINI_REFRESHTOKEN,
|
|
672
683
|
},
|
|
684
|
+
mangadex: {
|
|
685
|
+
username: envs.MANGADEX_USERNAME, // required when refresh-token is not set
|
|
686
|
+
password: envs.MANGADEX_PASSWORD, // required when refresh-token is not set
|
|
687
|
+
clientId: envs.MANGADEX_CLIENT_ID,
|
|
688
|
+
clientSecret: envs.MANGADEX_CLIENT_SECRET,
|
|
689
|
+
refreshToken: envs.MANGADEX_REFRESH_TOKEN,
|
|
690
|
+
},
|
|
673
691
|
manhuagui: {
|
|
674
692
|
cookie: envs.MHGUI_COOKIE,
|
|
675
693
|
},
|
|
@@ -692,6 +710,10 @@ const calculateValue = () => {
|
|
|
692
710
|
misskey: {
|
|
693
711
|
accessToken: envs.MISSKEY_ACCESS_TOKEN,
|
|
694
712
|
},
|
|
713
|
+
mixi2: {
|
|
714
|
+
authToken: envs.MIXI2_AUTH_TOKEN,
|
|
715
|
+
authKey: envs.MIXI2_AUTH_KEY,
|
|
716
|
+
},
|
|
695
717
|
mox: {
|
|
696
718
|
cookie: envs.MOX_COOKIE,
|
|
697
719
|
},
|
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.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,6 +10,7 @@ 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
|
|
|
@@ -157,6 +159,7 @@ for (const namespace in namespaces) {
|
|
|
157
159
|
|
|
158
160
|
for (const [path, routeData] of sortedRoutes) {
|
|
159
161
|
const wrappedHandler: Handler = async (ctx) => {
|
|
162
|
+
logger.debug(`Matched route: ${routePath(ctx)}`);
|
|
160
163
|
if (!ctx.get('data')) {
|
|
161
164
|
if (typeof routeData.handler !== 'function') {
|
|
162
165
|
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
|
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Route } from '@/types';
|
|
2
|
+
import ofetch from '@/utils/ofetch';
|
|
3
|
+
import { parseDate } from '@/utils/parse-date';
|
|
4
|
+
import { load } from 'cheerio';
|
|
5
|
+
import { rootUrl, buildApiUrl } from './util';
|
|
6
|
+
import cache from '@/utils/cache';
|
|
7
|
+
|
|
8
|
+
export const route: Route = {
|
|
9
|
+
path: '/daily',
|
|
10
|
+
name: 'AI日报',
|
|
11
|
+
url: 'www.aibase.com',
|
|
12
|
+
maintainers: ['3tuuu'],
|
|
13
|
+
handler: async (ctx) => {
|
|
14
|
+
// 每页数量限制
|
|
15
|
+
const limit = Number.parseInt(ctx.req.query('limit') ?? '30', 10);
|
|
16
|
+
// 用项目中已有的获取页面方法,获取页面以及 Token
|
|
17
|
+
const currentUrl = new URL('discover', rootUrl).href;
|
|
18
|
+
const currentHtml = await ofetch(currentUrl);
|
|
19
|
+
const $ = load(currentHtml);
|
|
20
|
+
const logoSrc = $('img.logo').prop('src');
|
|
21
|
+
const image = logoSrc ? new URL(logoSrc, rootUrl).href : '';
|
|
22
|
+
const author = 'AI Base';
|
|
23
|
+
const { aILogListUrl } = await buildApiUrl($);
|
|
24
|
+
const response: DailyData = await ofetch(aILogListUrl, {
|
|
25
|
+
headers: {
|
|
26
|
+
accept: 'application/json;charset=utf-8',
|
|
27
|
+
},
|
|
28
|
+
query: {
|
|
29
|
+
pagesize: limit,
|
|
30
|
+
page: 1,
|
|
31
|
+
type: 2,
|
|
32
|
+
isen: 0,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
if (!response || !response.data) {
|
|
36
|
+
throw new Error('日报数据不存在或为空');
|
|
37
|
+
}
|
|
38
|
+
const items = await Promise.all(
|
|
39
|
+
response.data.slice(0, limit).map(async (item) => {
|
|
40
|
+
const articleUrl = `https://www.aibase.com/zh/news/${item.Id}`;
|
|
41
|
+
return await cache.tryGet(articleUrl, async () => {
|
|
42
|
+
const articleHtml = await ofetch(articleUrl);
|
|
43
|
+
const $ = load(articleHtml);
|
|
44
|
+
const description = $('.post-content').html();
|
|
45
|
+
if (!description) {
|
|
46
|
+
throw new Error(`Empty content: ${articleUrl}`);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
title: item.title,
|
|
50
|
+
link: articleUrl,
|
|
51
|
+
description,
|
|
52
|
+
pubDate: parseDate(item.addtime),
|
|
53
|
+
author: 'AI Base',
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
title: 'AI日报',
|
|
61
|
+
description: '每天三分钟关注AI行业趋势',
|
|
62
|
+
language: 'zh-cn',
|
|
63
|
+
link: 'https://www.aibase.com/zh/daily',
|
|
64
|
+
item: items,
|
|
65
|
+
allowEmpty: true,
|
|
66
|
+
image,
|
|
67
|
+
author,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
example: '/aibase/daily',
|
|
71
|
+
description: '获取 AI 日报',
|
|
72
|
+
categories: ['new-media'],
|
|
73
|
+
features: {
|
|
74
|
+
requireConfig: false,
|
|
75
|
+
requirePuppeteer: false,
|
|
76
|
+
antiCrawler: false,
|
|
77
|
+
supportRadar: true,
|
|
78
|
+
supportBT: false,
|
|
79
|
+
supportPodcast: false,
|
|
80
|
+
supportScihub: false,
|
|
81
|
+
},
|
|
82
|
+
radar: [
|
|
83
|
+
{
|
|
84
|
+
source: ['www.aibase.com/zh/daily'],
|
|
85
|
+
target: '/daily',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
interface DailyData {
|
|
91
|
+
has_more: boolean;
|
|
92
|
+
message: string;
|
|
93
|
+
data: DailyItem[];
|
|
94
|
+
}
|
|
95
|
+
interface DailyItem {
|
|
96
|
+
/** 文章 ID */
|
|
97
|
+
Id: number;
|
|
98
|
+
/** 添加时间 */
|
|
99
|
+
addtime: string;
|
|
100
|
+
/** 文章标题 */
|
|
101
|
+
title: string;
|
|
102
|
+
/** 文章副标题 */
|
|
103
|
+
subtitle: string;
|
|
104
|
+
/** 文章简要描述 */
|
|
105
|
+
desc: string;
|
|
106
|
+
/** 文章主图 */
|
|
107
|
+
orgthumb: string;
|
|
108
|
+
playtime: number;
|
|
109
|
+
pv: string;
|
|
110
|
+
}
|
|
@@ -56,12 +56,15 @@ const buildApiUrl = async ($: CheerioAPI) => {
|
|
|
56
56
|
const apiTagProcUrl = new URL(`${token}/ai/GetAiProductOfTag.aspx`, apiRootUrl).href;
|
|
57
57
|
// AI 资讯列表
|
|
58
58
|
const apiInfoListUrl = new URL(`${token}/ai/GetAiInfoList.aspx`, apiRootUrl).href;
|
|
59
|
+
// AI 日报
|
|
60
|
+
const aILogListUrl = new URL(`${token}/ai/v2/GetAILogList.aspx`, apiRootUrl).href;
|
|
59
61
|
|
|
60
62
|
return {
|
|
61
63
|
apiRecommListUrl,
|
|
62
64
|
apiRecommProcUrl,
|
|
63
65
|
apiTagProcUrl,
|
|
64
66
|
apiInfoListUrl,
|
|
67
|
+
aILogListUrl,
|
|
65
68
|
};
|
|
66
69
|
};
|
|
67
70
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Route } from '@/types';
|
|
2
|
+
import ofetch from '@/utils/ofetch';
|
|
3
|
+
import { load } from 'cheerio';
|
|
4
|
+
import { parseDate } from '@/utils/parse-date';
|
|
5
|
+
export const route: Route = {
|
|
6
|
+
path: '/security-bulletin',
|
|
7
|
+
categories: ['program-update'],
|
|
8
|
+
example: '/android/security-bulletin',
|
|
9
|
+
parameters: {},
|
|
10
|
+
features: {
|
|
11
|
+
requireConfig: false,
|
|
12
|
+
requirePuppeteer: false,
|
|
13
|
+
antiCrawler: false,
|
|
14
|
+
supportBT: false,
|
|
15
|
+
supportPodcast: false,
|
|
16
|
+
supportScihub: false,
|
|
17
|
+
},
|
|
18
|
+
radar: [
|
|
19
|
+
{
|
|
20
|
+
source: ['source.android.com/docs/security/bulletin', 'source.android.com/docs/security/bulletin/asb-overview', 'source.android.com/'],
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
name: 'Security Bulletins',
|
|
24
|
+
maintainers: ['TonyRL'],
|
|
25
|
+
handler,
|
|
26
|
+
url: 'source.android.com/docs/security/bulletin/asb-overview',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
async function handler() {
|
|
30
|
+
const baseUrl = 'https://source.android.com';
|
|
31
|
+
const link = `${baseUrl}/docs/security/bulletin/asb-overview`;
|
|
32
|
+
|
|
33
|
+
const response = await ofetch(link, {
|
|
34
|
+
headers: {
|
|
35
|
+
Cookie: 'signin=autosignin; cookies_accepted=true; django_language=en;',
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const $ = load(response);
|
|
40
|
+
|
|
41
|
+
const items = $('table tr')
|
|
42
|
+
.slice(1)
|
|
43
|
+
.toArray()
|
|
44
|
+
.map((item) => {
|
|
45
|
+
const $item = $(item);
|
|
46
|
+
const a = $item.find('td:nth-child(1) a');
|
|
47
|
+
return {
|
|
48
|
+
title: `Bulletin ${a.text()}`,
|
|
49
|
+
description: $item.find('td:nth-child(2)').html(),
|
|
50
|
+
link: `${baseUrl}${a.attr('href')}`,
|
|
51
|
+
pubDate: parseDate($item.find('td:nth-child(3)').text()),
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
title: $('title').text(),
|
|
57
|
+
link,
|
|
58
|
+
image: $('link[rel="apple-touch-icon"]').attr('href'),
|
|
59
|
+
item: items,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { routePath } from 'hono/route';
|
|
1
2
|
import { Route, ViewType } from '@/types';
|
|
2
3
|
import got from '@/utils/got';
|
|
3
4
|
import { load } from 'cheerio';
|
|
@@ -37,7 +38,7 @@ export const route: Route = {
|
|
|
37
38
|
|
|
38
39
|
async function handler(ctx) {
|
|
39
40
|
const { topic = 'trending-news', nav = '' } = ctx.req.param();
|
|
40
|
-
const useNav = ctx
|
|
41
|
+
const useNav = routePath(ctx) === '/apnews/nav/:nav{.*}?';
|
|
41
42
|
const url = useNav ? `${HOME_PAGE}/${nav}` : `${HOME_PAGE}/hub/${topic}`;
|
|
42
43
|
const response = await got(url);
|
|
43
44
|
const $ = load(response.data);
|
|
@@ -44,7 +44,7 @@ export function fetchArticle(item) {
|
|
|
44
44
|
description: $('div.RichTextStoryBody').html() || $(':is(.VideoLead, .VideoPage-pageSubHeading)').html(),
|
|
45
45
|
category: [...(section ? [section] : []), ...(ldjson.keywords ?? [])],
|
|
46
46
|
guid: $("meta[name='brightspot.contentId']").attr('content'),
|
|
47
|
-
author: ldjson.author,
|
|
47
|
+
author: ldjson.author?.map((e) => e.mainEntity),
|
|
48
48
|
};
|
|
49
49
|
} else {
|
|
50
50
|
// Live
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { type Data, type DataItem, type Route, ViewType } from '@/types';
|
|
2
|
+
|
|
3
|
+
import { art } from '@/utils/render';
|
|
4
|
+
import cache from '@/utils/cache';
|
|
5
|
+
import ofetch from '@/utils/ofetch';
|
|
6
|
+
import { parseDate } from '@/utils/parse-date';
|
|
7
|
+
|
|
8
|
+
import { type CheerioAPI, type Cheerio, load } from 'cheerio';
|
|
9
|
+
import type { Element } from 'domhandler';
|
|
10
|
+
import { type Context } from 'hono';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
|
|
13
|
+
export const handler = async (ctx: Context): Promise<Data> => {
|
|
14
|
+
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '50', 10);
|
|
15
|
+
|
|
16
|
+
const baseUrl: string = 'https://augmentcode.com';
|
|
17
|
+
const targetUrl: string = new URL('blog', baseUrl).href;
|
|
18
|
+
|
|
19
|
+
const response = await ofetch(targetUrl);
|
|
20
|
+
const $: CheerioAPI = load(response);
|
|
21
|
+
const language = $('html').attr('lang') ?? 'en';
|
|
22
|
+
|
|
23
|
+
let items: DataItem[] = [];
|
|
24
|
+
|
|
25
|
+
items = $('div[data-slot="card"]')
|
|
26
|
+
.slice(0, limit)
|
|
27
|
+
.toArray()
|
|
28
|
+
.map((el): Element => {
|
|
29
|
+
const $el: Cheerio<Element> = $(el);
|
|
30
|
+
|
|
31
|
+
const title: string = $el.find('div[data-slot="card-content"]').text();
|
|
32
|
+
const pubDateStr: string | undefined = $el.find('div[data-slot="card-footer"] p').last().text();
|
|
33
|
+
const linkUrl: string | undefined = $el.parent().attr('href');
|
|
34
|
+
const authorEls: Element[] = $el.find('div[data-slot="card-footer"] p').first().find('span').toArray();
|
|
35
|
+
const authors: DataItem['author'] = authorEls.map((authorEl) => {
|
|
36
|
+
const $authorEl: Cheerio<Element> = $(authorEl);
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
name: $authorEl.contents().first().text(),
|
|
40
|
+
url: undefined,
|
|
41
|
+
avatar: undefined,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
const image: string | undefined = $el.find('div[data-slot="card-header"] img').attr('src');
|
|
45
|
+
const upDatedStr: string | undefined = pubDateStr;
|
|
46
|
+
|
|
47
|
+
const processedItem: DataItem = {
|
|
48
|
+
title,
|
|
49
|
+
pubDate: pubDateStr ? parseDate(pubDateStr) : undefined,
|
|
50
|
+
link: linkUrl ? new URL(linkUrl, baseUrl).href : undefined,
|
|
51
|
+
author: authors,
|
|
52
|
+
image,
|
|
53
|
+
banner: image,
|
|
54
|
+
updated: upDatedStr ? parseDate(upDatedStr) : undefined,
|
|
55
|
+
language,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return processedItem;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
items = await Promise.all(
|
|
62
|
+
items.map((item) => {
|
|
63
|
+
if (!item.link) {
|
|
64
|
+
return item;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return cache.tryGet(item.link, async (): Promise<DataItem> => {
|
|
68
|
+
const detailResponse = await ofetch(item.link);
|
|
69
|
+
const $$: CheerioAPI = load(detailResponse);
|
|
70
|
+
|
|
71
|
+
const title: string = $$('article h1').text();
|
|
72
|
+
const image: string | undefined = $$('meta[property="og:image"]').attr('content') ?? item.image;
|
|
73
|
+
const description: string | undefined = art(path.join(__dirname, 'templates/description.art'), {
|
|
74
|
+
images: image
|
|
75
|
+
? [
|
|
76
|
+
{
|
|
77
|
+
src: image,
|
|
78
|
+
alt: title,
|
|
79
|
+
},
|
|
80
|
+
]
|
|
81
|
+
: undefined,
|
|
82
|
+
description: $$('div.prose').html(),
|
|
83
|
+
});
|
|
84
|
+
const pubDateStr: string | undefined = $$('meta[property="article:published_time"]').attr('content');
|
|
85
|
+
const authorEls: Element[] = $$('meta[property="article:author"]').toArray();
|
|
86
|
+
const authors: DataItem['author'] = authorEls.map((authorEl) => {
|
|
87
|
+
const $$authorEl: Cheerio<Element> = $$(authorEl);
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
name: $$authorEl.attr('content'),
|
|
91
|
+
url: undefined,
|
|
92
|
+
avatar: undefined,
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
const upDatedStr: string | undefined = pubDateStr;
|
|
96
|
+
|
|
97
|
+
const processedItem: DataItem = {
|
|
98
|
+
title,
|
|
99
|
+
description,
|
|
100
|
+
pubDate: pubDateStr ? parseDate(pubDateStr) : item.pubDate,
|
|
101
|
+
author: authors,
|
|
102
|
+
content: {
|
|
103
|
+
html: description,
|
|
104
|
+
text: description,
|
|
105
|
+
},
|
|
106
|
+
image,
|
|
107
|
+
banner: image,
|
|
108
|
+
updated: upDatedStr ? parseDate(upDatedStr) : item.updated,
|
|
109
|
+
language,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
...item,
|
|
114
|
+
...processedItem,
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const title: string = $('title').text();
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
title,
|
|
124
|
+
description: $('meta[name="description"]').attr('content'),
|
|
125
|
+
link: targetUrl,
|
|
126
|
+
item: items,
|
|
127
|
+
allowEmpty: true,
|
|
128
|
+
image: $('meta[property="og:image"]').attr('content'),
|
|
129
|
+
author: title.split(/-/).pop()?.trim(),
|
|
130
|
+
language,
|
|
131
|
+
id: targetUrl,
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const route: Route = {
|
|
136
|
+
path: '/blog',
|
|
137
|
+
name: 'Blog',
|
|
138
|
+
url: 'augmentcode.com',
|
|
139
|
+
maintainers: ['nczitzk'],
|
|
140
|
+
handler,
|
|
141
|
+
example: '/augmentcode/blog',
|
|
142
|
+
parameters: undefined,
|
|
143
|
+
description: undefined,
|
|
144
|
+
categories: ['programming'],
|
|
145
|
+
features: {
|
|
146
|
+
requireConfig: false,
|
|
147
|
+
requirePuppeteer: false,
|
|
148
|
+
antiCrawler: false,
|
|
149
|
+
supportRadar: true,
|
|
150
|
+
supportBT: false,
|
|
151
|
+
supportPodcast: false,
|
|
152
|
+
supportScihub: false,
|
|
153
|
+
},
|
|
154
|
+
radar: [
|
|
155
|
+
{
|
|
156
|
+
source: ['augmentcode.com/blog'],
|
|
157
|
+
target: '/blog',
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
view: ViewType.Articles,
|
|
161
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{{ if images }}
|
|
2
|
+
{{ each images image }}
|
|
3
|
+
{{ if image?.src }}
|
|
4
|
+
<figure>
|
|
5
|
+
<img
|
|
6
|
+
{{ if image.alt }}
|
|
7
|
+
alt="{{ image.alt }}"
|
|
8
|
+
{{ /if }}
|
|
9
|
+
src="{{ image.src }}">
|
|
10
|
+
</figure>
|
|
11
|
+
{{ /if }}
|
|
12
|
+
{{ /each }}
|
|
13
|
+
{{ /if }}
|
|
14
|
+
|
|
15
|
+
{{ if description }}
|
|
16
|
+
{{@ description }}
|
|
17
|
+
{{ /if }}
|