rsshub 1.0.0-master.c183692 → 1.0.0-master.c1913c8
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/README.md +6 -9
- package/lib/config.ts +18 -0
- package/lib/errors/index.tsx +1 -1
- package/lib/middleware/logger.ts +2 -2
- package/lib/routes/abc/index.ts +2 -2
- package/lib/routes/apnews/api.ts +6 -1
- package/lib/routes/apnews/rss.ts +1 -1
- package/lib/routes/apnews/sitemap.ts +2 -1
- package/lib/routes/apnews/topics.ts +2 -2
- package/lib/routes/asus/bios.ts +39 -6
- package/lib/routes/bilibili/bilibili-recommend.ts +42 -0
- package/lib/routes/bilibili/cache.ts +22 -0
- package/lib/routes/bilibili/dynamic.ts +101 -97
- package/lib/routes/bilibili/followings-video.ts +9 -3
- package/lib/routes/bilibili/utils.ts +5 -0
- package/lib/routes/bilibili/video.ts +2 -1
- package/lib/routes/bitget/announcement.ts +200 -0
- package/lib/routes/bitget/namespace.ts +6 -0
- package/lib/routes/bitget/type.ts +26 -0
- package/lib/routes/bjp/apod.ts +4 -2
- package/lib/routes/bupt/jwc.ts +130 -0
- package/lib/routes/ccfa/index.ts +216 -0
- package/lib/routes/ccfa/namespace.ts +8 -0
- package/lib/routes/ccfa/templates/description.art +7 -0
- package/lib/routes/devtrium/namespace.ts +6 -0
- package/lib/routes/devtrium/posts.ts +55 -0
- package/lib/routes/discourse/official.ts +55 -0
- package/lib/routes/dockerhub/utils.ts +4 -3
- package/lib/routes/douban/movie/coming.ts +68 -0
- package/lib/routes/douban/templates/movie_coming.art +27 -0
- package/lib/routes/follow/profile.ts +35 -5
- package/lib/routes/github/comments.ts +32 -30
- package/lib/routes/gov/cn/namespace.ts +8 -0
- package/lib/routes/gov/{news → cn/news}/index.ts +11 -7
- package/lib/routes/gov/ndrc/fggz.ts +637 -2
- package/lib/routes/gov/ndrc/namespace.ts +8 -0
- package/lib/routes/gov/ndrc/xwdt.ts +28 -8
- package/lib/routes/gov/ndrc/zfxxgk/articles.ts +73 -0
- package/lib/routes/hpoi/all.ts +3 -2
- package/lib/routes/hpoi/character.ts +3 -2
- package/lib/routes/hpoi/work.ts +3 -2
- package/lib/routes/jjwxc/book.ts +18 -14
- package/lib/routes/lofter/collection.ts +87 -0
- package/lib/routes/malaysiakini/index.ts +179 -0
- package/lib/routes/malaysiakini/namespace.ts +11 -0
- package/lib/routes/mastodon/acct.ts +4 -3
- package/lib/routes/mastodon/timeline-local.ts +3 -2
- package/lib/routes/mastodon/timeline-remote.ts +3 -2
- package/lib/routes/meishichina/index.ts +1997 -0
- package/lib/routes/meishichina/namespace.ts +8 -0
- package/lib/routes/oct0pu5/namespace.ts +10 -0
- package/lib/routes/oct0pu5/rss.ts +48 -0
- package/lib/routes/pconline/focus.ts +143 -0
- package/lib/routes/pconline/namespace.ts +10 -0
- package/lib/routes/people/index.ts +6 -2
- package/lib/routes/pixivision/index.ts +84 -0
- package/lib/routes/pixivision/namespace.ts +6 -0
- package/lib/routes/pixivision/utils.ts +86 -0
- package/lib/routes/pku/bbs/hot.ts +1 -1
- package/lib/routes/pornhub/category.ts +3 -2
- package/lib/routes/pornhub/model.ts +4 -3
- package/lib/routes/pornhub/pornstar.ts +4 -3
- package/lib/routes/pornhub/search.ts +3 -2
- package/lib/routes/qiche365/namespace.ts +5 -0
- package/lib/routes/qiche365/recall.ts +53 -0
- package/lib/routes/sdu/{cs.ts → cs/index.ts} +46 -12
- package/lib/routes/sdu/namespace.ts +2 -2
- package/lib/routes/soundon/namespace.ts +6 -0
- package/lib/routes/soundon/podcast.ts +80 -0
- package/lib/routes/soundon/types.ts +67 -0
- package/lib/routes/swjtu/scai/bks.ts +80 -0
- package/lib/routes/telegram/blog.ts +3 -2
- package/lib/routes/telegram/stickerpack.ts +3 -2
- package/lib/routes/tencent/news/author.ts +2 -1
- package/lib/routes/the/index.ts +3 -2
- package/lib/routes/theinitium/app.ts +137 -0
- package/lib/routes/theinitium/templates/description.art +17 -0
- package/lib/routes/threads/index.ts +26 -20
- package/lib/routes/tju/cic/index.ts +2 -2
- package/lib/routes/tju/news/index.ts +2 -2
- package/lib/routes/tju/oaa/index.ts +2 -2
- package/lib/routes/twitch/live.ts +3 -2
- package/lib/routes/twitch/video.ts +3 -2
- package/lib/routes/twitter/api/mobile-api/login.ts +1 -1
- package/lib/routes/twitter/api/web-api/constants.ts +15 -14
- package/lib/routes/twitter/api/web-api/login.ts +7 -5
- package/lib/routes/twitter/api/web-api/utils.ts +1 -2
- package/lib/routes/twitter/list.ts +5 -2
- package/lib/routes/twitter/tweet.ts +1 -0
- package/lib/routes/weibo/namespace.ts +1 -0
- package/lib/routes/weibo/oasis/user.ts +1 -1
- package/lib/routes/weibo/super-index.ts +23 -11
- package/lib/routes/weibo/user.ts +12 -1
- package/lib/routes/whu/cs.ts +11 -3
- package/lib/routes/whu/gs/index.ts +2 -1
- package/lib/routes/whu/news.ts +27 -2
- package/lib/routes/withgoogle/explorables.ts +54 -0
- package/lib/routes/withgoogle/namespace.ts +6 -0
- package/lib/routes/zaobao/util.ts +1 -1
- package/lib/routes/zhihu/zhuanlan.ts +8 -7
- package/lib/utils/otel/metric.ts +3 -2
- package/lib/views/rss.tsx +7 -0
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
[](https://app.codecov.io/gh/DIYgod/RSSHub/branch/master)
|
|
13
13
|
[](https://github.com/DIYgod/RSSHub)
|
|
14
14
|
|
|
15
|
-
[](https://t.me/rsshub) [](https://t.me/awesomeRSSHub) [](https://t.me/rsshub) [](https://t.me/awesomeRSSHub) [](https://x.com/intent/follow?screen_name=_RSSHub)
|
|
16
16
|
|
|
17
17
|
## Introduction
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ RSSHub is the world's largest RSS network, consisting of over 5,000 global insta
|
|
|
20
20
|
|
|
21
21
|
RSSHub delivers millions of contents aggregated from all kinds of sources, our vibrant open source community is ensuring the deliver of RSSHub's new routes, new features and bug fixes.
|
|
22
22
|
|
|
23
|
-
[Documentation](https://docs.rsshub.app) | [Telegram Group](https://t.me/rsshub) | [Telegram Channel](https://t.me/awesomeRSSHub) | [Twitter](https://x.com/intent/follow?screen_name=_RSSHub)
|
|
23
|
+
[Documentation](https://docs.rsshub.app) | [Telegram Group](https://t.me/rsshub) | [Telegram Channel](https://t.me/awesomeRSSHub) | [X (Twitter)](https://x.com/intent/follow?screen_name=_RSSHub)
|
|
24
24
|
|
|
25
25
|
## Related Projects
|
|
26
26
|
|
|
@@ -41,23 +41,20 @@ Refer to [Deployment](https://docs.rsshub.app/deploy/)
|
|
|
41
41
|
|
|
42
42
|
## Special Thanks
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
<div align="center">
|
|
45
45
|
|
|
46
46
|
[](https://github.com/DIYgod/RSSHub/graphs/contributors)
|
|
47
47
|
|
|
48
48
|
Logo designer [sheldonrrr](https://dribbble.com/sheldonrrr)
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
<a href="https://github.com/DIYgod/sponsors">
|
|
52
|
-
<img src="https://raw.githubusercontent.com/DIYgod/sponsors/main/sponsors.wide.svg" />
|
|
53
|
-
</a>
|
|
54
|
-
</p>
|
|
50
|
+
[](https://github.com/DIYgod/sponsors)
|
|
55
51
|
|
|
56
52
|
<a href="https://www.cloudflare.com" target="_blank"><img height="50px" src="https://i.imgur.com/7Ph27Fq.png"></a> <a href="https://www.netlify.com" target="_blank"><img height="40px" src="https://i.imgur.com/cU01915.png"></a> <a href="https://1password.com" target="_blank"><img height="40px" src="https://i.imgur.com/a2XjflO.png"></a>
|
|
53
|
+
</div>
|
|
57
54
|
|
|
58
55
|
## Author
|
|
59
56
|
|
|
60
57
|
**RSSHub** © [DIYgod](https://github.com/DIYgod), Released under the [MIT](./LICENSE) License.<br>
|
|
61
58
|
Authored and maintained by DIYgod with help from contributors ([list](https://github.com/DIYgod/RSSHub/contributors)).
|
|
62
59
|
|
|
63
|
-
> Blog [@DIYgod](https://diygod.cc) · GitHub [@DIYgod](https://github.com/DIYgod) · Twitter [@DIYgod](https://x.com/DIYgod) · Telegram Channel [@awesomeDIYgod](https://t.me/awesomeDIYgod)
|
|
60
|
+
> Blog [@DIYgod](https://diygod.cc) · GitHub [@DIYgod](https://github.com/DIYgod) · X (Twitter) [@DIYgod](https://x.com/DIYgod) · Telegram Channel [@awesomeDIYgod](https://t.me/awesomeDIYgod)
|
package/lib/config.ts
CHANGED
|
@@ -47,6 +47,10 @@ export type Config = {
|
|
|
47
47
|
debugInfo: string;
|
|
48
48
|
loggerLevel: string;
|
|
49
49
|
noLogfiles?: boolean;
|
|
50
|
+
otel: {
|
|
51
|
+
seconds_bucket?: string;
|
|
52
|
+
milliseconds_bucket?: string;
|
|
53
|
+
};
|
|
50
54
|
showLoggerTimestamp?: boolean;
|
|
51
55
|
sentry: {
|
|
52
56
|
dsn?: string;
|
|
@@ -179,6 +183,11 @@ export type Config = {
|
|
|
179
183
|
lightnovel: {
|
|
180
184
|
cookie?: string;
|
|
181
185
|
};
|
|
186
|
+
malaysiakini: {
|
|
187
|
+
email?: string;
|
|
188
|
+
password?: string;
|
|
189
|
+
refreshToken?: string;
|
|
190
|
+
};
|
|
182
191
|
manhuagui: {
|
|
183
192
|
cookie?: string;
|
|
184
193
|
};
|
|
@@ -414,6 +423,10 @@ const calculateValue = () => {
|
|
|
414
423
|
debugInfo: envs.DEBUG_INFO || 'true',
|
|
415
424
|
loggerLevel: envs.LOGGER_LEVEL || 'info',
|
|
416
425
|
noLogfiles: toBoolean(envs.NO_LOGFILES, false),
|
|
426
|
+
otel: {
|
|
427
|
+
seconds_bucket: envs.OTEL_SECONDS_BUCKET || '0.01,0.1,1,2,5,15,30,60',
|
|
428
|
+
milliseconds_bucket: envs.OTEL_MILLISECONDS_BUCKET || '10,20,50,100,250,500,1000,5000,15000',
|
|
429
|
+
},
|
|
417
430
|
showLoggerTimestamp: toBoolean(envs.SHOW_LOGGER_TIMESTAMP, false),
|
|
418
431
|
sentry: {
|
|
419
432
|
dsn: envs.SENTRY,
|
|
@@ -550,6 +563,11 @@ const calculateValue = () => {
|
|
|
550
563
|
lightnovel: {
|
|
551
564
|
cookie: envs.SECURITY_KEY,
|
|
552
565
|
},
|
|
566
|
+
malaysiakini: {
|
|
567
|
+
email: envs.MALAYSIAKINI_EMAIL,
|
|
568
|
+
password: envs.MALAYSIAKINI_PASSWORD,
|
|
569
|
+
refreshToken: envs.MALAYSIAKINI_REFRESHTOKEN,
|
|
570
|
+
},
|
|
553
571
|
manhuagui: {
|
|
554
572
|
cookie: envs.MHGUI_COOKIE,
|
|
555
573
|
},
|
package/lib/errors/index.tsx
CHANGED
|
@@ -67,7 +67,7 @@ export const errorHandler: ErrorHandler = (error, ctx) => {
|
|
|
67
67
|
const message = `${error.name}: ${errorMessage}`;
|
|
68
68
|
|
|
69
69
|
logger.error(`Error in ${requestPath}: ${message}`);
|
|
70
|
-
requestMetric.error({ path:
|
|
70
|
+
requestMetric.error({ path: matchedRoute, method: ctx.req.method, status: ctx.res.status });
|
|
71
71
|
|
|
72
72
|
return config.isPackage || ctx.req.query('format') === 'json'
|
|
73
73
|
? ctx.json({
|
package/lib/middleware/logger.ts
CHANGED
|
@@ -26,7 +26,7 @@ const colorStatus = (status: number) => {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
const middleware: MiddlewareHandler = async (ctx, next) => {
|
|
29
|
-
const { method, raw } = ctx.req;
|
|
29
|
+
const { method, raw, routePath } = ctx.req;
|
|
30
30
|
const path = getPath(raw);
|
|
31
31
|
|
|
32
32
|
logger.info(`${LogPrefix.Incoming} ${method} ${path}`);
|
|
@@ -38,7 +38,7 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
|
|
|
38
38
|
const status = ctx.res.status;
|
|
39
39
|
|
|
40
40
|
logger.info(`${LogPrefix.Outgoing} ${method} ${path} ${colorStatus(status)} ${time(start)}`);
|
|
41
|
-
requestMetric.success(Date.now() - start, { path, method, status });
|
|
41
|
+
requestMetric.success(Date.now() - start, { path: routePath, method, status });
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
export default middleware;
|
package/lib/routes/abc/index.ts
CHANGED
|
@@ -82,8 +82,8 @@ async function handler(ctx) {
|
|
|
82
82
|
}),
|
|
83
83
|
author: i.newsBylineProps?.authors?.map((a) => a.name).join('/') ?? undefined,
|
|
84
84
|
guid: `abc-${i.id}`,
|
|
85
|
-
pubDate: parseDate(i.
|
|
86
|
-
updated: i.
|
|
85
|
+
pubDate: parseDate(i.dates.firstPublished),
|
|
86
|
+
updated: i.dates.lastUpdated ? parseDate(i.dates.lastUpdated) : undefined,
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
if (i.mediaIndicator) {
|
package/lib/routes/apnews/api.ts
CHANGED
|
@@ -44,14 +44,19 @@ async function handler(ctx) {
|
|
|
44
44
|
title: e.contents[0]?.headline,
|
|
45
45
|
link: e.contents[0]?.localLinkUrl,
|
|
46
46
|
pubDate: timezone(parseDate(e.publishedDate), 0),
|
|
47
|
+
category: e.tagObjs.map((tag) => tag.name),
|
|
48
|
+
updated: timezone(parseDate(e.contents[0]?.updated), 0),
|
|
49
|
+
description: e.contents[0]?.storyHTML,
|
|
50
|
+
author: e.contents[0]?.reporters.map((author) => ({ name: author.displayName })),
|
|
47
51
|
}))
|
|
48
52
|
.sort((a, b) => b.pubDate - a.pubDate)
|
|
49
53
|
.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 20);
|
|
50
54
|
|
|
51
|
-
const items = await Promise.all(list.map((item) => fetchArticle(item)));
|
|
55
|
+
const items = ctx.req.query('mode') === 'fulltext' ? await Promise.all(list.map((item) => fetchArticle(item))) : list;
|
|
52
56
|
|
|
53
57
|
return {
|
|
54
58
|
title: `${res.tagObjs[0].name} - AP News`,
|
|
55
59
|
item: items,
|
|
60
|
+
link: 'https://apnews.com',
|
|
56
61
|
};
|
|
57
62
|
}
|
package/lib/routes/apnews/rss.ts
CHANGED
|
@@ -38,7 +38,7 @@ async function handler(ctx) {
|
|
|
38
38
|
const url = `${HOME_PAGE}/${rss}.rss`;
|
|
39
39
|
const res = await parser.parseURL(url);
|
|
40
40
|
|
|
41
|
-
const items = await Promise.all(res.items.map((item) => fetchArticle(item)));
|
|
41
|
+
const items = ctx.req.query('mode') === 'fulltext' ? await Promise.all(res.items.map((item) => fetchArticle(item))) : res;
|
|
42
42
|
|
|
43
43
|
return {
|
|
44
44
|
...res,
|
|
@@ -82,11 +82,12 @@ async function handler(ctx) {
|
|
|
82
82
|
.sort((a, b) => (a.pubDate && b.pubDate ? b.pubDate - a.pubDate : b.lastmod - a.lastmod))
|
|
83
83
|
.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 20);
|
|
84
84
|
|
|
85
|
-
const items = await asyncPoolAll(20, list, (item) => fetchArticle(item));
|
|
85
|
+
const items = ctx.req.query('mode') === 'fulltext' ? await asyncPoolAll(20, list, (item) => fetchArticle(item)) : list;
|
|
86
86
|
|
|
87
87
|
return {
|
|
88
88
|
title: `AP News sitemap:${route}`,
|
|
89
89
|
item: items,
|
|
90
|
+
link: 'https://apnews.com',
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
93
|
async function asyncPoolAll<IN, OUT>(poolLimit: number, array: readonly IN[], iteratorFn: (generator: IN) => Promise<OUT>) {
|
|
@@ -42,14 +42,14 @@ async function handler(ctx) {
|
|
|
42
42
|
|
|
43
43
|
const items = await Promise.all(
|
|
44
44
|
$(':is(.PagePromo-content, .PageListStandardE-leadPromo-info) bsp-custom-headline')
|
|
45
|
-
.
|
|
45
|
+
.toArray()
|
|
46
46
|
.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : Infinity)
|
|
47
47
|
.map((e) => ({
|
|
48
48
|
title: $(e).find('span.PagePromoContentIcons-text').text(),
|
|
49
49
|
link: $(e).find('a').attr('href'),
|
|
50
50
|
}))
|
|
51
51
|
.filter((e) => typeof e.link === 'string')
|
|
52
|
-
.map((item) => fetchArticle(item))
|
|
52
|
+
.map((item) => (ctx.req.query('mode') === 'fulltext' ? fetchArticle(item) : item))
|
|
53
53
|
);
|
|
54
54
|
|
|
55
55
|
return {
|
package/lib/routes/asus/bios.ts
CHANGED
|
@@ -7,8 +7,24 @@ import { parseDate } from '@/utils/parse-date';
|
|
|
7
7
|
import { art } from '@/utils/render';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const endPoints = {
|
|
11
|
+
zh: {
|
|
12
|
+
url: 'https://odinapi.asus.com.cn/',
|
|
13
|
+
lang: 'cn',
|
|
14
|
+
website_code: 'cn',
|
|
15
|
+
},
|
|
16
|
+
en: {
|
|
17
|
+
url: 'https://odinapi.asus.com/',
|
|
18
|
+
lang: 'en',
|
|
19
|
+
website_code: 'us',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const getProductID = async (model, language) => {
|
|
24
|
+
const currentEndpoint = endPoints[language] ?? endPoints.zh;
|
|
25
|
+
const { url, lang, website_code } = currentEndpoint;
|
|
26
|
+
|
|
27
|
+
const searchAPI = `${url}recent-data/apiv2/SearchSuggestion?SystemCode=asus&WebsiteCode=${website_code}&SearchKey=${model}&SearchType=ProductsAll&RowLimit=4&sitelang=${lang}`;
|
|
12
28
|
const response = await got(searchAPI);
|
|
13
29
|
|
|
14
30
|
return {
|
|
@@ -18,10 +34,26 @@ const getProductID = async (model) => {
|
|
|
18
34
|
};
|
|
19
35
|
|
|
20
36
|
export const route: Route = {
|
|
21
|
-
path: '/bios/:model',
|
|
37
|
+
path: '/bios/:model/:lang?',
|
|
22
38
|
categories: ['program-update'],
|
|
23
|
-
example: '/asus/bios/RT-AX88U',
|
|
24
|
-
parameters: {
|
|
39
|
+
example: '/asus/bios/RT-AX88U/zh',
|
|
40
|
+
parameters: {
|
|
41
|
+
model: 'Model, can be found in product page',
|
|
42
|
+
lang: {
|
|
43
|
+
description: 'Language, provide access routes for other parts of the world',
|
|
44
|
+
options: [
|
|
45
|
+
{
|
|
46
|
+
label: 'Chinese',
|
|
47
|
+
value: 'zh',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: 'English',
|
|
51
|
+
value: 'en',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
default: 'zh',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
25
57
|
features: {
|
|
26
58
|
requireConfig: false,
|
|
27
59
|
requirePuppeteer: false,
|
|
@@ -43,7 +75,8 @@ export const route: Route = {
|
|
|
43
75
|
|
|
44
76
|
async function handler(ctx) {
|
|
45
77
|
const model = ctx.req.param('model');
|
|
46
|
-
const
|
|
78
|
+
const language = ctx.req.param('lang') ?? 'zh';
|
|
79
|
+
const { productID, url } = await getProductID(model, language);
|
|
47
80
|
const biosAPI = `https://www.asus.com.cn/support/api/product.asmx/GetPDBIOS?website=cn&model=${model}&pdid=${productID}&sitelang=cn`;
|
|
48
81
|
|
|
49
82
|
const response = await got(biosAPI);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Route } from '@/types';
|
|
2
|
+
import got from '@/utils/got';
|
|
3
|
+
import utils from './utils';
|
|
4
|
+
|
|
5
|
+
export const route: Route = {
|
|
6
|
+
path: '/precious/:disableEmbed?',
|
|
7
|
+
categories: ['social-media'],
|
|
8
|
+
example: '/bilibili/precious',
|
|
9
|
+
parameters: { disableEmbed: '默认为开启内嵌视频, 任意值为关闭' },
|
|
10
|
+
features: {
|
|
11
|
+
requireConfig: false,
|
|
12
|
+
requirePuppeteer: false,
|
|
13
|
+
antiCrawler: false,
|
|
14
|
+
supportBT: false,
|
|
15
|
+
supportPodcast: false,
|
|
16
|
+
supportScihub: false,
|
|
17
|
+
},
|
|
18
|
+
name: '入站必刷',
|
|
19
|
+
maintainers: ['liuyuhe666'],
|
|
20
|
+
handler,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
async function handler(ctx) {
|
|
24
|
+
const disableEmbed = ctx.req.param('disableEmbed');
|
|
25
|
+
const response = await got({
|
|
26
|
+
method: 'get',
|
|
27
|
+
url: 'https://api.bilibili.com/x/web-interface/popular/precious',
|
|
28
|
+
headers: {
|
|
29
|
+
Referer: 'https://www.bilibili.com/v/popular/history',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const data = response.data.data.list;
|
|
33
|
+
return {
|
|
34
|
+
title: '哔哩哔哩入站必刷',
|
|
35
|
+
link: 'https://www.bilibili.com/v/popular/history',
|
|
36
|
+
item: data.map((item) => ({
|
|
37
|
+
title: item.title,
|
|
38
|
+
description: `${item.desc || item.title}${disableEmbed ? '' : `<br><br>${utils.iframe(item.aid, null, item.bvid)}`}<br><img src="${item.pic}">`,
|
|
39
|
+
link: item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
|
|
40
|
+
})),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -5,6 +5,7 @@ import { load } from 'cheerio';
|
|
|
5
5
|
import { config } from '@/config';
|
|
6
6
|
import logger from '@/utils/logger';
|
|
7
7
|
import puppeteer from '@/utils/puppeteer';
|
|
8
|
+
import { JSDOM } from 'jsdom';
|
|
8
9
|
|
|
9
10
|
let disableConfigCookie = false;
|
|
10
11
|
const getCookie = () => {
|
|
@@ -39,6 +40,26 @@ const clearCookie = () => {
|
|
|
39
40
|
disableConfigCookie = true;
|
|
40
41
|
};
|
|
41
42
|
|
|
43
|
+
const getRenderData = (uid) => {
|
|
44
|
+
const key = 'bili-web-render-data';
|
|
45
|
+
return cache.tryGet(key, async () => {
|
|
46
|
+
const cookie = await getCookie();
|
|
47
|
+
const { data: response } = await got(`https://space.bilibili.com/${uid}`, {
|
|
48
|
+
headers: {
|
|
49
|
+
Referer: 'https://www.bilibili.com/',
|
|
50
|
+
Cookie: cookie,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
const dom = new JSDOM(response);
|
|
54
|
+
const document = dom.window.document;
|
|
55
|
+
const scriptElement = document.querySelector('#__RENDER_DATA__');
|
|
56
|
+
const innerText = scriptElement ? scriptElement.textContent || '{}' : '{}';
|
|
57
|
+
const renderData = JSON.parse(decodeURIComponent(innerText));
|
|
58
|
+
const accessId = renderData.access_id;
|
|
59
|
+
return accessId;
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
42
63
|
const getWbiVerifyString = () => {
|
|
43
64
|
const key = 'bili-wbi-verify-string';
|
|
44
65
|
return cache.tryGet(key, async () => {
|
|
@@ -262,4 +283,5 @@ export default {
|
|
|
262
283
|
getCidFromId,
|
|
263
284
|
getAidFromBvid,
|
|
264
285
|
getArticleDataFromCvid,
|
|
286
|
+
getRenderData,
|
|
265
287
|
};
|
|
@@ -22,6 +22,7 @@ export const route: Route = {
|
|
|
22
22
|
| disableEmbed | 关闭内嵌视频 | 0/1/true/false | false |
|
|
23
23
|
| useAvid | 视频链接使用 AV 号 (默认为 BV 号) | 0/1/true/false | false |
|
|
24
24
|
| directLink | 使用内容直链 | 0/1/true/false | false |
|
|
25
|
+
| hideGoods | 隐藏带货动态 | 0/1/true/false | false |
|
|
25
26
|
|
|
26
27
|
用例:\`/bilibili/user/dynamic/2267573/showEmoji=1&disableEmbed=1&useAvid=1\``,
|
|
27
28
|
},
|
|
@@ -229,6 +230,7 @@ async function handler(ctx) {
|
|
|
229
230
|
const displayArticle = ctx.req.query('mode') === 'fulltext';
|
|
230
231
|
const useAvid = fallback(undefined, queryToBoolean(routeParams.useAvid), false);
|
|
231
232
|
const directLink = fallback(undefined, queryToBoolean(routeParams.directLink), false);
|
|
233
|
+
const hideGoods = fallback(undefined, queryToBoolean(routeParams.hideGoods), false);
|
|
232
234
|
|
|
233
235
|
const cookie = await cacheIn.getCookie();
|
|
234
236
|
|
|
@@ -253,119 +255,121 @@ async function handler(ctx) {
|
|
|
253
255
|
cache.set(`bili-userface-from-uid-${uid}`, face);
|
|
254
256
|
|
|
255
257
|
const rssItems = await Promise.all(
|
|
256
|
-
items
|
|
257
|
-
|
|
258
|
+
items
|
|
259
|
+
.filter((item) => !hideGoods || item.modules.module_dynamic?.additional?.type !== 'ADDITIONAL_TYPE_GOODS')
|
|
260
|
+
.map(async (item) => {
|
|
261
|
+
// const parsed = JSONbig.parse(item.card);
|
|
258
262
|
|
|
259
|
-
|
|
260
|
-
|
|
263
|
+
const data = item.modules;
|
|
264
|
+
const origin = item?.orig?.modules;
|
|
261
265
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
266
|
+
// link
|
|
267
|
+
let link = '';
|
|
268
|
+
if (item.id_str) {
|
|
269
|
+
link = `https://t.bilibili.com/${item.id_str}`;
|
|
270
|
+
}
|
|
267
271
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
272
|
+
let description = getDes(data) || '';
|
|
273
|
+
const title = getTitle(data) || description; // 没有 title 的时候使用 desc 填充
|
|
274
|
+
const category: string[] = [];
|
|
275
|
+
// emoji
|
|
276
|
+
if (data.module_dynamic?.desc?.rich_text_nodes?.length) {
|
|
277
|
+
const nodes = data.module_dynamic.desc.rich_text_nodes;
|
|
278
|
+
for (const node of nodes) {
|
|
279
|
+
// 处理 emoji 的情况
|
|
280
|
+
if (showEmoji && node?.emoji) {
|
|
281
|
+
const emoji = node.emoji;
|
|
282
|
+
description = description.replaceAll(
|
|
283
|
+
emoji.text,
|
|
284
|
+
`<img alt="${emoji.text}" src="${emoji.icon_url}" style="margin: -1px 1px 0px; display: inline-block; width: 20px; height: 20px; vertical-align: text-bottom;" title="" referrerpolicy="no-referrer">`
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
// 处理转发带图评论的情况
|
|
288
|
+
if (node?.pics?.length) {
|
|
289
|
+
const { pics, text } = node;
|
|
290
|
+
description = description.replaceAll(
|
|
291
|
+
text,
|
|
292
|
+
pics
|
|
293
|
+
.map(
|
|
294
|
+
(pic) =>
|
|
295
|
+
`<img alt="${text}" src="${pic.src}" style="margin: 0px 0px 0px; display: inline-block; width: ${pic.width}px; height: ${pic.height}px; vertical-align: text-bottom;" title="" referrerpolicy="no-referrer">`
|
|
296
|
+
)
|
|
297
|
+
.join('<br>')
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
if (node?.type === 'RICH_TEXT_NODE_TYPE_TOPIC') {
|
|
301
|
+
// 将话题作为 category
|
|
302
|
+
category.push(node.text.match(/#(\S+)#/)?.[1] || '');
|
|
303
|
+
}
|
|
299
304
|
}
|
|
300
305
|
}
|
|
301
|
-
}
|
|
302
306
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
307
|
+
if (data.module_dynamic?.major?.opus?.summary?.rich_text_nodes?.length) {
|
|
308
|
+
const nodes = data.module_dynamic.major.opus.summary.rich_text_nodes;
|
|
309
|
+
for (const node of nodes) {
|
|
310
|
+
if (node?.type === 'RICH_TEXT_NODE_TYPE_TOPIC') {
|
|
311
|
+
// 将话题作为 category
|
|
312
|
+
category.push(node.text.match(/#(\S+)#/)?.[1] || '');
|
|
313
|
+
}
|
|
309
314
|
}
|
|
310
315
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
+
if (data.module_dynamic?.topic?.name) {
|
|
317
|
+
// 将话题作为 category
|
|
318
|
+
category.push(data.module_dynamic.topic.name);
|
|
319
|
+
}
|
|
316
320
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
321
|
+
if (item.type === 'DYNAMIC_TYPE_ARTICLE' && displayArticle) {
|
|
322
|
+
// 抓取专栏全文
|
|
323
|
+
const cvid = data.module_dynamic?.major?.opus?.jump_url?.match?.(/cv(\d+)/)?.[0];
|
|
324
|
+
if (cvid) {
|
|
325
|
+
description = (await cacheIn.getArticleDataFromCvid(cvid, uid)).description || '';
|
|
326
|
+
}
|
|
322
327
|
}
|
|
323
|
-
}
|
|
324
328
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
329
|
+
const urlResult = getUrl(item, useAvid);
|
|
330
|
+
const urlText = urlResult?.text;
|
|
331
|
+
if (urlResult && directLink) {
|
|
332
|
+
link = urlResult.url;
|
|
333
|
+
}
|
|
330
334
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
335
|
+
const originUrlResult = getUrl(item?.orig, useAvid);
|
|
336
|
+
const originUrlText = originUrlResult?.text;
|
|
337
|
+
if (originUrlResult && directLink) {
|
|
338
|
+
link = originUrlResult.url;
|
|
339
|
+
}
|
|
336
340
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
341
|
+
let originDescription = '';
|
|
342
|
+
const originName = getOriginName(origin);
|
|
343
|
+
const originTitle = getOriginTitle(origin);
|
|
344
|
+
const originDes = getOriginDes(origin);
|
|
345
|
+
if (originName) {
|
|
346
|
+
originDescription += `//转发自: @${getOriginName(origin)}: `;
|
|
347
|
+
}
|
|
348
|
+
if (originTitle) {
|
|
349
|
+
originDescription += originTitle;
|
|
350
|
+
}
|
|
351
|
+
if (originDes) {
|
|
352
|
+
originDescription += `<br>${originDes}`;
|
|
353
|
+
}
|
|
350
354
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
355
|
+
// 换行处理
|
|
356
|
+
description = description.replaceAll('\r\n', '<br>').replaceAll('\n', '<br>');
|
|
357
|
+
originDescription = originDescription.replaceAll('\r\n', '<br>').replaceAll('\n', '<br>');
|
|
354
358
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
+
const descriptions = [description, originDescription, urlText, originUrlText, getIframe(data, disableEmbed), getIframe(origin, disableEmbed), getImgs(data), getImgs(origin)]
|
|
360
|
+
.filter(Boolean)
|
|
361
|
+
.map((e) => e?.trim())
|
|
362
|
+
.join('<br>');
|
|
359
363
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
364
|
+
return {
|
|
365
|
+
title,
|
|
366
|
+
description: descriptions,
|
|
367
|
+
pubDate: data.module_author?.pub_ts ? parseDate(data.module_author.pub_ts, 'X') : undefined,
|
|
368
|
+
link,
|
|
369
|
+
author,
|
|
370
|
+
category: category.length ? [...new Set(category)] : undefined,
|
|
371
|
+
};
|
|
372
|
+
})
|
|
369
373
|
);
|
|
370
374
|
|
|
371
375
|
return {
|
|
@@ -4,6 +4,7 @@ import cache from './cache';
|
|
|
4
4
|
import { config } from '@/config';
|
|
5
5
|
import utils from './utils';
|
|
6
6
|
import ConfigNotFoundError from '@/errors/types/config-not-found';
|
|
7
|
+
import logger from '@/utils/logger';
|
|
7
8
|
|
|
8
9
|
export const route: Route = {
|
|
9
10
|
path: '/followings/video/:uid/:disableEmbed?',
|
|
@@ -53,10 +54,15 @@ async function handler(ctx) {
|
|
|
53
54
|
Cookie: cookie,
|
|
54
55
|
},
|
|
55
56
|
});
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
const data = response.data;
|
|
58
|
+
if (data.code) {
|
|
59
|
+
logger.error(JSON.stringify(data));
|
|
60
|
+
if (data.code === -6 || data.code === 4_100_000) {
|
|
61
|
+
throw new ConfigNotFoundError('对应 uid 的 Bilibili 用户的 Cookie 已过期');
|
|
62
|
+
}
|
|
63
|
+
throw new Error(`Got error code ${data.code} while fetching: ${data.message}`);
|
|
58
64
|
}
|
|
59
|
-
const cards =
|
|
65
|
+
const cards = data.data.cards;
|
|
60
66
|
|
|
61
67
|
const out = cards.map((card) => {
|
|
62
68
|
const card_data = JSON.parse(card.card);
|
|
@@ -66,6 +66,10 @@ function hexsign(e) {
|
|
|
66
66
|
return o;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
function addRenderData(params, renderData) {
|
|
70
|
+
return `${params}&w_webid=${encodeURIComponent(renderData)}`;
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
function addWbiVerifyInfo(params, wbiVerifyString) {
|
|
70
74
|
const searchParams = new URLSearchParams(params);
|
|
71
75
|
searchParams.sort();
|
|
@@ -122,4 +126,5 @@ export default {
|
|
|
122
126
|
getDmImgList,
|
|
123
127
|
addDmVerifyInfo,
|
|
124
128
|
bvidTime,
|
|
129
|
+
addRenderData,
|
|
125
130
|
};
|