rsshub 1.0.0-master.b76ffa1 → 1.0.0-master.b77ea8a

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.
Files changed (71) hide show
  1. package/lib/config.ts +3 -0
  2. package/lib/middleware/access-control.ts +1 -1
  3. package/lib/routes/afdian/dynamic.ts +1 -1
  4. package/lib/routes/afdian/explore.ts +1 -1
  5. package/lib/routes/bilibili/bangumi.ts +45 -43
  6. package/lib/routes/bilibili/bilibili-recommend.ts +4 -4
  7. package/lib/routes/bilibili/coin.ts +4 -4
  8. package/lib/routes/bilibili/dynamic.ts +14 -14
  9. package/lib/routes/bilibili/fav.ts +4 -4
  10. package/lib/routes/bilibili/followings-dynamic.ts +25 -3
  11. package/lib/routes/bilibili/followings-video.ts +4 -4
  12. package/lib/routes/bilibili/like.ts +4 -4
  13. package/lib/routes/bilibili/page.ts +5 -4
  14. package/lib/routes/bilibili/partion-ranking.ts +4 -4
  15. package/lib/routes/bilibili/partion.ts +4 -4
  16. package/lib/routes/bilibili/popular.ts +6 -4
  17. package/lib/routes/bilibili/ranking.ts +4 -6
  18. package/lib/routes/bilibili/templates/description.art +12 -0
  19. package/lib/routes/bilibili/types.ts +52 -0
  20. package/lib/routes/bilibili/user-channel.ts +10 -17
  21. package/lib/routes/bilibili/user-collection.ts +10 -18
  22. package/lib/routes/bilibili/user-fav.ts +4 -4
  23. package/lib/routes/bilibili/utils.ts +111 -7
  24. package/lib/routes/bilibili/video-all.ts +8 -3
  25. package/lib/routes/bilibili/video.ts +5 -4
  26. package/lib/routes/bilibili/vsearch.ts +21 -5
  27. package/lib/routes/bilibili/watchlater.ts +4 -4
  28. package/lib/routes/bilibili/weekly-recommend.ts +4 -9
  29. package/lib/routes/bsky/posts.ts +2 -2
  30. package/lib/routes/bsky/templates/post.art +4 -2
  31. package/lib/routes/chinania/index.ts +240 -0
  32. package/lib/routes/chinania/namespace.ts +8 -0
  33. package/lib/routes/dedao/articles.ts +149 -0
  34. package/lib/routes/eshukan/academic.ts +134 -0
  35. package/lib/routes/eshukan/namespace.ts +8 -0
  36. package/lib/routes/eshukan/templates/description.art +7 -0
  37. package/lib/routes/follow/profile.ts +37 -3
  38. package/lib/routes/lovelive-anime/schedules.ts +4 -5
  39. package/lib/routes/lovelive-anime/topics.ts +88 -37
  40. package/lib/routes/mingpao/index.ts +7 -1
  41. package/lib/routes/nature/cover.ts +5 -3
  42. package/lib/routes/nature/research.ts +1 -1
  43. package/lib/routes/nature/siteindex.ts +25 -11
  44. package/lib/routes/nature/utils.ts +5 -7
  45. package/lib/routes/qq/pd/guild.ts +146 -0
  46. package/lib/routes/qq/pd/types.ts +82 -0
  47. package/lib/routes/qq/pd/utils.ts +119 -0
  48. package/lib/routes/reuters/common.ts +160 -159
  49. package/lib/routes/reuters/investigates.ts +3 -2
  50. package/lib/routes/rsshub/transform/html.ts +2 -2
  51. package/lib/routes/telegram/channel.ts +14 -5
  52. package/lib/routes/telegram/scripts/get-telegram-session.mjs +41 -0
  53. package/lib/routes/telegram/tglib/channel.ts +8 -4
  54. package/lib/routes/theinitium/app.ts +49 -27
  55. package/lib/routes/theinitium/templates/description.art +2 -2
  56. package/lib/routes/threads/index.ts +1 -1
  57. package/lib/routes/threads/utils.ts +19 -1
  58. package/lib/routes/twitter/api/mobile-api/login.ts +125 -127
  59. package/lib/routes/twitter/api/mobile-api/token.ts +2 -0
  60. package/lib/routes/twitter/home-latest.ts +4 -1
  61. package/lib/routes/twitter/home.ts +4 -1
  62. package/lib/routes/twitter/likes.ts +4 -1
  63. package/lib/routes/twitter/list.ts +4 -1
  64. package/lib/routes/twitter/namespace.ts +1 -0
  65. package/lib/routes/twitter/utils.ts +9 -3
  66. package/lib/routes/warthunder/news.ts +8 -8
  67. package/lib/routes/washingtonpost/app.ts +118 -0
  68. package/lib/routes/washingtonpost/namespace.ts +6 -0
  69. package/lib/routes/washingtonpost/templates/description.art +59 -0
  70. package/lib/routes/zhihu/daily.ts +30 -64
  71. package/package.json +12 -12
@@ -0,0 +1,52 @@
1
+ export interface ResultResponse<Result> {
2
+ result: Result;
3
+ }
4
+
5
+ /**
6
+ * 番剧信息
7
+ *
8
+ * @interface MediaResult
9
+ *
10
+ * @property {string} cover - 封面。
11
+ * @property {string} evaluate - 摘要。
12
+ * @property {number} media_id - 媒体 ID。
13
+ * @property {number} season_id - 季度 ID。
14
+ * @property {string} share_url - 分享 URL。此属性是注入的。
15
+ * @property {string} title - 标题。
16
+ */
17
+ export interface MediaResult {
18
+ cover: string;
19
+ evaluate: string;
20
+ media_id: number;
21
+ season_id: number;
22
+ share_url: string; // injected
23
+ title: string;
24
+ }
25
+
26
+ export interface SeasonResult {
27
+ main_section: SectionResult;
28
+ section: SectionResult[];
29
+ }
30
+
31
+ export interface SectionResult {
32
+ episodes: EpisodeResult[];
33
+ }
34
+
35
+ /**
36
+ * 番剧剧集信息
37
+ *
38
+ * @interface EpisodeResult
39
+ *
40
+ * @property {string} cover - 封面。
41
+ * @property {number} id - 剧集 ID。
42
+ * @property {string} long_title - 完整标题。
43
+ * @property {string} share_url - 分享 URL。
44
+ * @property {string} title - 短标题。
45
+ */
46
+ export interface EpisodeResult {
47
+ cover: string;
48
+ id: number;
49
+ long_title: string;
50
+ share_url: string;
51
+ title: string;
52
+ }
@@ -10,10 +10,10 @@ const notFoundData = {
10
10
  };
11
11
 
12
12
  export const route: Route = {
13
- path: '/user/channel/:uid/:sid/:disableEmbed?',
13
+ path: '/user/channel/:uid/:sid/:embed?',
14
14
  categories: ['social-media'],
15
15
  example: '/bilibili/user/channel/2267573/396050',
16
- parameters: { uid: '用户 id, 可在 UP 主主页中找到', sid: '频道 id, 可在频道的 URL 中找到', disableEmbed: '默认为开启内嵌视频, 任意值为关闭' },
16
+ parameters: { uid: '用户 id, 可在 UP 主主页中找到', sid: '频道 id, 可在频道的 URL 中找到', embed: '默认为开启内嵌视频, 任意值为关闭' },
17
17
  features: {
18
18
  requireConfig: false,
19
19
  requirePuppeteer: false,
@@ -30,7 +30,7 @@ export const route: Route = {
30
30
  async function handler(ctx) {
31
31
  const uid = Number.parseInt(ctx.req.param('uid'));
32
32
  const sid = Number.parseInt(ctx.req.param('sid'));
33
- const disableEmbed = ctx.req.param('disableEmbed');
33
+ const embed = !ctx.req.param('embed');
34
34
  const limit = ctx.req.query('limit') ?? 25;
35
35
 
36
36
  const link = `https://space.bilibili.com/${uid}/channel/seriesdetail?sid=${sid}`;
@@ -70,19 +70,12 @@ async function handler(ctx) {
70
70
  description: `${userName} 的 bilibili 频道`,
71
71
  logo: face,
72
72
  icon: face,
73
- item: data.archives.map((item) => {
74
- const descList = [];
75
- if (!disableEmbed) {
76
- descList.push(utils.iframe(item.aid));
77
- }
78
- descList.push(`<img src="${item.pic}">`);
79
- return {
80
- title: item.title,
81
- description: descList.join('<br>'),
82
- pubDate: parseDate(item.pubdate, 'X'),
83
- link: item.pubdate > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
84
- author: userName,
85
- };
86
- }),
73
+ item: data.archives.map((item) => ({
74
+ title: item.title,
75
+ description: utils.renderUGCDescription(embed, item.pic, '', item.aid, undefined, item.bvid),
76
+ pubDate: parseDate(item.pubdate, 'X'),
77
+ link: item.pubdate > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
78
+ author: userName,
79
+ })),
87
80
  };
88
81
  }
@@ -3,20 +3,19 @@ import got from '@/utils/got';
3
3
  import cache from './cache';
4
4
  import utils from './utils';
5
5
  import { parseDate } from '@/utils/parse-date';
6
- import { queryToBoolean } from '@/utils/readable-social';
7
6
 
8
7
  const notFoundData = {
9
8
  title: '此 bilibili 频道不存在',
10
9
  };
11
10
 
12
11
  export const route: Route = {
13
- path: '/user/collection/:uid/:sid/:disableEmbed?/:sortReverse?/:page?',
12
+ path: '/user/collection/:uid/:sid/:embed?/:sortReverse?/:page?',
14
13
  categories: ['social-media'],
15
14
  example: '/bilibili/user/collection/245645656/529166',
16
15
  parameters: {
17
16
  uid: '用户 id, 可在 UP 主主页中找到',
18
17
  sid: '合集 id, 可在合集页面的 URL 中找到',
19
- disableEmbed: '空,0与false为开启内嵌视频, 其他任意值为关闭',
18
+ embed: '默认为开启内嵌视频, 任意值为关闭',
20
19
  sortReverse: '默认:默认排序 1:升序排序',
21
20
  page: '页码, 默认1',
22
21
  },
@@ -36,7 +35,7 @@ export const route: Route = {
36
35
  async function handler(ctx) {
37
36
  const uid = Number.parseInt(ctx.req.param('uid'));
38
37
  const sid = Number.parseInt(ctx.req.param('sid'));
39
- const disableEmbed = queryToBoolean(ctx.req.param('disableEmbed'));
38
+ const embed = !ctx.req.param('embed');
40
39
  const sortReverse = Number.parseInt(ctx.req.param('sortReverse')) === 1;
41
40
  const page = ctx.req.param('page') ? Number.parseInt(ctx.req.param('page')) : 1;
42
41
  const limit = ctx.req.query('limit') ?? 25;
@@ -62,19 +61,12 @@ async function handler(ctx) {
62
61
  description: `${userName} 的 bilibili 合集`,
63
62
  logo: face,
64
63
  icon: face,
65
- item: data.archives.map((item) => {
66
- const descList = [];
67
- if (!disableEmbed) {
68
- descList.push(utils.iframe(item.aid));
69
- }
70
- descList.push(`<img src="${item.pic}">`);
71
- return {
72
- title: item.title,
73
- description: descList.join('<br>'),
74
- pubDate: parseDate(item.pubdate, 'X'),
75
- link: item.pubdate > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
76
- author: userName,
77
- };
78
- }),
64
+ item: data.archives.map((item) => ({
65
+ title: item.title,
66
+ description: utils.renderUGCDescription(embed, item.pic, '', item.aid, undefined, item.bvid),
67
+ pubDate: parseDate(item.pubdate, 'X'),
68
+ link: item.pubdate > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
69
+ author: userName,
70
+ })),
79
71
  };
80
72
  }
@@ -5,10 +5,10 @@ import utils from './utils';
5
5
  import { config } from '@/config';
6
6
 
7
7
  export const route: Route = {
8
- path: '/user/fav/:uid/:disableEmbed?',
8
+ path: '/user/fav/:uid/:embed?',
9
9
  categories: ['social-media'],
10
10
  example: '/bilibili/user/fav/2267573',
11
- parameters: { uid: '用户 id, 可在 UP 主主页中找到', disableEmbed: '默认为开启内嵌视频, 任意值为关闭' },
11
+ parameters: { uid: '用户 id, 可在 UP 主主页中找到', embed: '默认为开启内嵌视频, 任意值为关闭' },
12
12
  features: {
13
13
  requireConfig: false,
14
14
  requirePuppeteer: false,
@@ -30,7 +30,7 @@ export const route: Route = {
30
30
 
31
31
  async function handler(ctx) {
32
32
  const uid = ctx.req.param('uid');
33
- const disableEmbed = ctx.req.param('disableEmbed');
33
+ const embed = !ctx.req.param('embed');
34
34
  const name = await cache.getUsernameFromUID(uid);
35
35
 
36
36
  const response = await got({
@@ -53,7 +53,7 @@ async function handler(ctx) {
53
53
  data.data.archives &&
54
54
  data.data.archives.map((item) => ({
55
55
  title: item.title,
56
- description: `${item.desc}${disableEmbed ? '' : `<br><br>${utils.iframe(item.aid)}`}<br><img src="${item.pic}">`,
56
+ description: utils.renderUGCDescription(embed, item.pic, item.desc, item.aid, undefined, item.bvid),
57
57
  pubDate: new Date(item.fav_at * 1000).toUTCString(),
58
58
  link: item.fav_at > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
59
59
  author: item.owner.name,
@@ -1,12 +1,13 @@
1
+ import { getCurrentPath } from '@/utils/helpers';
2
+ const __dirname = getCurrentPath(import.meta.url);
3
+
1
4
  import { config } from '@/config';
2
5
  import md5 from '@/utils/md5';
6
+ import ofetch from '@/utils/ofetch';
7
+ import { art } from '@/utils/render';
3
8
  import CryptoJS from 'crypto-js';
4
-
5
- function iframe(aid: any, page?: any, bvid?: any) {
6
- return `<iframe src="https://www.bilibili.com/blackboard/html5mobileplayer.html?${bvid ? `bvid=${bvid}` : `aid=${aid}`}${
7
- page ? `&page=${page}` : ''
8
- }&high_quality=1&autoplay=0" width="650" height="477" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"></iframe>`;
9
- }
9
+ import path from 'node:path';
10
+ import { MediaResult, ResultResponse, SeasonResult } from './types';
10
11
 
11
12
  // a
12
13
  function randomHexStr(length) {
@@ -197,8 +198,107 @@ function addDmVerifyInfoWithInter(params: string, dmImgList: string, dmImgInter:
197
198
 
198
199
  const bvidTime = 1_589_990_400;
199
200
 
201
+ /**
202
+ * 获取番剧信息并缓存
203
+ *
204
+ * @param {string} id - 番剧 ID。
205
+ * @param cache - 缓存 module。
206
+ * @returns {Promise<MediaResult>} 番剧信息。
207
+ */
208
+ export const getBangumi = (id: string, cache): Promise<MediaResult> =>
209
+ cache.tryGet(
210
+ `bilibili:getBangumi:${id}`,
211
+ async () => {
212
+ const res = await ofetch<ResultResponse<MediaResult>>('https://api.bilibili.com/pgc/view/web/media', {
213
+ query: {
214
+ media_id: id,
215
+ },
216
+ });
217
+ if (res.result.share_url === undefined) {
218
+ // reference: https://api.bilibili.com/pgc/review/user?media_id=${id}
219
+ res.result.share_url = `https://www.bilibili.com/bangumi/media/md${res.result.media_id}`;
220
+ }
221
+ return res.result;
222
+ },
223
+ config.cache.routeExpire,
224
+ false
225
+ ) as Promise<MediaResult>;
226
+
227
+ /**
228
+ * 获取番剧分集信息并缓存
229
+ *
230
+ * @param {string} id - 番剧 ID。
231
+ * @param cache - 缓存 module。
232
+ * @returns {Promise<SeasonResult>} 番剧分集信息。
233
+ */
234
+ export const getBangumiItems = (id: string, cache): Promise<SeasonResult> =>
235
+ cache.tryGet(
236
+ `bilibili:getBangumiItems:${id}`,
237
+ async () => {
238
+ const res = await ofetch<ResultResponse<SeasonResult>>('https://api.bilibili.com/pgc/web/season/section', {
239
+ query: {
240
+ season_id: id,
241
+ },
242
+ });
243
+ return res.result;
244
+ },
245
+ config.cache.routeExpire,
246
+ false
247
+ ) as Promise<SeasonResult>;
248
+
249
+ /**
250
+ * 使用模板渲染 UGC(用户生成内容)描述。
251
+ *
252
+ * @param {boolean} embed - 是否嵌入视频。
253
+ * @param {string} img - 要包含在描述中的图片 URL。
254
+ * @param {string} description - UGC 的文本描述。
255
+ * @param {string} [aid] - 可选。UGC 的 aid。
256
+ * @param {string} [cid] - 可选。UGC 的 cid。
257
+ * @param {string} [bvid] - 可选。UGC 的 bvid。
258
+ * @returns {string} 渲染的 UGC 描述。
259
+ *
260
+ * @see https://player.bilibili.com/ 获取更多信息。
261
+ */
262
+ export const renderUGCDescription = (embed: boolean, img: string, description: string, aid?: string, cid?: string, bvid?: string): string => {
263
+ // docs: https://player.bilibili.com/
264
+ const rendered = art(path.join(__dirname, 'templates/description.art'), {
265
+ embed,
266
+ ugc: true,
267
+ aid,
268
+ cid,
269
+ bvid,
270
+ img: img.replace('http://', 'https://'),
271
+ description,
272
+ });
273
+ return rendered;
274
+ };
275
+
276
+ /**
277
+ * 使用模板渲染 OGV(原创视频)描述。
278
+ *
279
+ * @param {boolean} embed - 是否嵌入视频。
280
+ * @param {string} img - 要包含在描述中的图片 URL。
281
+ * @param {string} description - OGV 的文本描述。
282
+ * @param {string} [seasonId] - 可选。OGV 的季 ID。
283
+ * @param {string} [episodeId] - 可选。OGV 的集 ID。
284
+ * @returns {string} 渲染的 OGV 描述。
285
+ *
286
+ * @see https://player.bilibili.com/ 获取更多信息。
287
+ */
288
+ export const renderOGVDescription = (embed: boolean, img: string, description: string, seasonId?: string, episodeId?: string): string => {
289
+ // docs: https://player.bilibili.com/
290
+ const rendered = art(path.join(__dirname, 'templates/description.art'), {
291
+ embed,
292
+ ogv: true,
293
+ seasonId,
294
+ episodeId,
295
+ img: img.replace('http://', 'https://'),
296
+ description,
297
+ });
298
+ return rendered;
299
+ };
300
+
200
301
  export default {
201
- iframe,
202
302
  lsid,
203
303
  _uuid,
204
304
  hexsign,
@@ -209,4 +309,8 @@ export default {
209
309
  addDmVerifyInfoWithInter,
210
310
  bvidTime,
211
311
  addRenderData,
312
+ getBangumi,
313
+ getBangumiItems,
314
+ renderUGCDescription,
315
+ renderOGVDescription,
212
316
  };
@@ -5,16 +5,21 @@ import utils from './utils';
5
5
  import { parseDate } from '@/utils/parse-date';
6
6
 
7
7
  export const route: Route = {
8
- path: '/user/video-all/:uid/:disableEmbed?',
8
+ path: '/user/video-all/:uid/:embed?',
9
9
  name: '用户所有视频',
10
10
  maintainers: [],
11
11
  handler,
12
+ example: '/bilibili/user/video-all/2267573',
13
+ parameters: {
14
+ uid: '用户 id, 可在 UP 主主页中找到',
15
+ embed: '默认为开启内嵌视频, 任意值为关闭',
16
+ },
12
17
  categories: ['social-media'],
13
18
  };
14
19
 
15
20
  async function handler(ctx) {
16
21
  const uid = ctx.req.param('uid');
17
- const disableEmbed = ctx.req.param('disableEmbed');
22
+ const embed = !ctx.req.param('embed');
18
23
  const cookie = await cache.getCookie();
19
24
  const wbiVerifyString = await cache.getWbiVerifyString();
20
25
  const dmImgList = utils.getDmImgList();
@@ -74,7 +79,7 @@ async function handler(ctx) {
74
79
  icon: face,
75
80
  item: vlist.map((item) => ({
76
81
  title: item.title,
77
- description: `${item.description}${disableEmbed ? '' : `<br><br>${utils.iframe(item.aid)}`}<br><img src="${item.pic}">`,
82
+ description: utils.renderUGCDescription(embed, item.pic, item.description, item.aid, undefined, item.bvid),
78
83
  pubDate: parseDate(item.created, 'X'),
79
84
  link: item.created > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
80
85
  author: name,
@@ -5,11 +5,11 @@ import utils from './utils';
5
5
  import logger from '@/utils/logger';
6
6
 
7
7
  export const route: Route = {
8
- path: '/user/video/:uid/:disableEmbed?',
8
+ path: '/user/video/:uid/:embed?',
9
9
  categories: ['social-media', 'popular'],
10
10
  view: ViewType.Videos,
11
11
  example: '/bilibili/user/video/2267573',
12
- parameters: { uid: '用户 id, 可在 UP 主主页中找到', disableEmbed: '默认为开启内嵌视频, 任意值为关闭' },
12
+ parameters: { uid: '用户 id, 可在 UP 主主页中找到', embed: '默认为开启内嵌视频, 任意值为关闭' },
13
13
  features: {
14
14
  requireConfig: false,
15
15
  requirePuppeteer: false,
@@ -31,7 +31,7 @@ export const route: Route = {
31
31
 
32
32
  async function handler(ctx) {
33
33
  const uid = ctx.req.param('uid');
34
- const disableEmbed = ctx.req.param('disableEmbed');
34
+ const embed = !ctx.req.param('embed');
35
35
  const cookie = await cache.getCookie();
36
36
  const wbiVerifyString = await cache.getWbiVerifyString();
37
37
  const dmImgList = utils.getDmImgList();
@@ -59,6 +59,7 @@ async function handler(ctx) {
59
59
  title: `${name} 的 bilibili 空间`,
60
60
  link: `https://space.bilibili.com/${uid}`,
61
61
  description: `${name} 的 bilibili 空间`,
62
+ image: face,
62
63
  logo: face,
63
64
  icon: face,
64
65
  item:
@@ -67,7 +68,7 @@ async function handler(ctx) {
67
68
  data.data.list.vlist &&
68
69
  data.data.list.vlist.map((item) => ({
69
70
  title: item.title,
70
- description: `${item.description}${disableEmbed ? '' : `<br><br>${utils.iframe(item.aid)}`}<br><img src="${item.pic}">`,
71
+ description: utils.renderUGCDescription(embed, item.pic, item.description, item.aid, undefined, item.bvid),
71
72
  pubDate: new Date(item.created * 1000).toUTCString(),
72
73
  link: item.created > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
73
74
  author: name,
@@ -2,14 +2,18 @@ import { Route } from '@/types';
2
2
  import got from '@/utils/got';
3
3
  import { parseDate } from '@/utils/parse-date';
4
4
  import utils from './utils';
5
- import { queryToBoolean } from '@/utils/readable-social';
6
5
  import cacheIn from './cache';
7
6
 
8
7
  export const route: Route = {
9
- path: '/vsearch/:kw/:order?/:disableEmbed?/:tid?',
8
+ path: '/vsearch/:kw/:order?/:embed?/:tid?',
10
9
  categories: ['social-media'],
11
10
  example: '/bilibili/vsearch/RSSHub',
12
- parameters: { kw: '检索关键字', order: '排序方式, 综合:totalrank 最多点击:click 最新发布:pubdate(缺省) 最多弹幕:dm 最多收藏:stow', disableEmbed: '默认为开启内嵌视频, 任意值为关闭', tid: '分区 id' },
11
+ parameters: {
12
+ kw: '检索关键字',
13
+ order: '排序方式, 综合:totalrank 最多点击:click 最新发布:pubdate(缺省) 最多弹幕:dm 最多收藏:stow',
14
+ embed: '默认为开启内嵌视频, 任意值为关闭',
15
+ tid: '分区 id',
16
+ },
13
17
  features: {
14
18
  requireConfig: [
15
19
  {
@@ -38,10 +42,22 @@ export const route: Route = {
38
42
  | 0 | 1 | 13 | 167 | 3 | 129 | 4 | 36 | 188 | 234 | 223 | 160 | 211 | 217 | 119 | 155 | 202 | 5 | 181 | 177 | 23 | 11 |`,
39
43
  };
40
44
 
45
+ const getIframe = (data, embed: boolean = true) => {
46
+ if (!embed) {
47
+ return '';
48
+ }
49
+ const aid = data?.aid;
50
+ const bvid = data?.bvid;
51
+ if (aid === undefined && bvid === undefined) {
52
+ return '';
53
+ }
54
+ return utils.renderUGCDescription(embed, '', '', aid, undefined, bvid);
55
+ };
56
+
41
57
  async function handler(ctx) {
42
58
  const kw = ctx.req.param('kw');
43
59
  const order = ctx.req.param('order') || 'pubdate';
44
- const disableEmbed = queryToBoolean(ctx.req.param('disableEmbed'));
60
+ const embed = !ctx.req.param('embed');
45
61
  const kw_url = encodeURIComponent(kw);
46
62
  const tids = ctx.req.param('tid') ?? 0;
47
63
  const cookie = await cacheIn.getCookie();
@@ -84,7 +100,7 @@ async function handler(ctx) {
84
100
  `<br/>${des}<br/>` +
85
101
  `<img src="${img}"><br/>` +
86
102
  `Match By: ${item.hit_columns?.join(',') || ''}` +
87
- (disableEmbed ? '' : `<br><br>${utils.iframe(item.aid)}`),
103
+ getIframe(item, embed),
88
104
  pubDate: parseDate(item.pubdate, 'X'),
89
105
  guid: item.arcurl,
90
106
  link: item.arcurl,
@@ -7,10 +7,10 @@ import { parseDate } from '@/utils/parse-date';
7
7
  import ConfigNotFoundError from '@/errors/types/config-not-found';
8
8
 
9
9
  export const route: Route = {
10
- path: '/watchlater/:uid/:disableEmbed?',
10
+ path: '/watchlater/:uid/:embed?',
11
11
  categories: ['social-media'],
12
12
  example: '/bilibili/watchlater/2267573',
13
- parameters: { uid: '用户 id', disableEmbed: '默认为开启内嵌视频, 任意值为关闭' },
13
+ parameters: { uid: '用户 id', embed: '默认为开启内嵌视频, 任意值为关闭' },
14
14
  features: {
15
15
  requireConfig: [
16
16
  {
@@ -38,7 +38,7 @@ export const route: Route = {
38
38
 
39
39
  async function handler(ctx) {
40
40
  const uid = ctx.req.param('uid');
41
- const disableEmbed = ctx.req.param('disableEmbed');
41
+ const embed = !ctx.req.param('embed');
42
42
  const name = await cache.getUsernameFromUID(uid);
43
43
 
44
44
  const cookie = config.bilibili.cookies[uid];
@@ -62,7 +62,7 @@ async function handler(ctx) {
62
62
 
63
63
  const out = list.map((item) => ({
64
64
  title: item.title,
65
- description: `${item.desc}<br><br><a href="https://www.bilibili.com/list/watchlater?bvid=${item.bvid}">在稍后再看列表中查看</a>${disableEmbed ? '' : `<br><br>${utils.iframe(item.aid)}`}<br><img src="${item.pic}">`,
65
+ description: utils.renderUGCDescription(embed, item.pic, `${item.desc}<br><a href="https://www.bilibili.com/list/watchlater?bvid=${item.bvid}">在稍后再看列表中查看</a>`, item.aid, undefined, item.bvid),
66
66
  pubDate: parseDate(item.add_at * 1000),
67
67
  link: item.pubdate > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
68
68
  author: item.owner.name,
@@ -3,10 +3,10 @@ import got from '@/utils/got';
3
3
  import utils from './utils';
4
4
 
5
5
  export const route: Route = {
6
- path: '/weekly/:disableEmbed?',
6
+ path: '/weekly/:embed?',
7
7
  categories: ['social-media'],
8
8
  example: '/bilibili/weekly',
9
- parameters: { disableEmbed: '默认为开启内嵌视频, 任意值为关闭' },
9
+ parameters: { embed: '默认为开启内嵌视频, 任意值为关闭' },
10
10
  features: {
11
11
  requireConfig: false,
12
12
  requirePuppeteer: false,
@@ -21,7 +21,7 @@ export const route: Route = {
21
21
  };
22
22
 
23
23
  async function handler(ctx) {
24
- const disableEmbed = ctx.req.param('disableEmbed');
24
+ const embed = !ctx.req.param('embed');
25
25
 
26
26
  const status_response = await got({
27
27
  method: 'get',
@@ -48,12 +48,7 @@ async function handler(ctx) {
48
48
  description: 'B站每周必看',
49
49
  item: data.map((item) => ({
50
50
  title: item.title,
51
- // description: `${weekly_name} ${item.title}<br>${item.rcmd_reason}<br>${!disableEmbed ? `${utils.iframe(item.param)}` : ''}<img src="${item.cover}">`,
52
- description: `
53
- ${weekly_name} ${item.title}<br>
54
- ${item.rcmd_reason}<br>
55
- ${disableEmbed ? '' : utils.iframe(item.param)}<img src="${item.cover}">
56
- `,
51
+ description: utils.renderUGCDescription(embed, item.cover, `${weekly_name} ${item.title} - ${item.rcmd_reason}`, item.param, undefined, item.bvid),
57
52
  link: weekly_number > 60 && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.param}`,
58
53
  })),
59
54
  };
@@ -62,8 +62,8 @@ async function handler(ctx) {
62
62
  description: art(path.join(__dirname, 'templates/post.art'), {
63
63
  text: post.record.text.replaceAll('\n', '<br>'),
64
64
  embed: post.embed,
65
- // embed.$type "app.bsky.embed.record#view" and "app.bsky.embed.recordWithMedia#view"
66
- // are not handled
65
+ // embed.$type "app.bsky.embed.record#view" and "app.bsky.embed.recordWithMedia#view" are not handled
66
+ // "app.bsky.embed.video#view" is rendered as image
67
67
  }),
68
68
  author: post.author.displayName,
69
69
  pubDate: parseDate(post.record.createdAt),
@@ -3,11 +3,13 @@
3
3
  {{ /if }}
4
4
 
5
5
  {{ if embed }}
6
- {{ if embed.$type == 'app.bsky.embed.images#view'}}
6
+ {{ if embed.$type === 'app.bsky.embed.images#view' }}
7
7
  {{ each embed.images i }}
8
8
  <img src="{{ i.fullsize }}" alt="{{ i.alt }}"><br>
9
9
  {{ /each }}
10
- {{ else if embed.$type == 'app.bsky.embed.external#view' }}
10
+ {{ else if embed.$type === 'app.bsky.embed.video#view' }}
11
+ <img src="{{ embed.thumbnail }}"><br>
12
+ {{ else if embed.$type === 'app.bsky.embed.external#view' }}
11
13
  <a href="{{ embed.external.uri }}"><b>{{ embed.external.title }}</b><br>
12
14
  {{ embed.external.description }}
13
15
  </a>