yz-yuki-plugin 2.0.8-0 → 2.0.8-2

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/CHANGELOG.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # 2.0.8
2
+ * 更新B站动态标题获取
2
3
  * 合并分支dev与dev3,减少维护成本
3
4
 
4
5
  # 2.0.7
@@ -83,6 +83,9 @@ noSplitHeight: 7500
83
83
  # 动态卡片分页截图高度,默认8000px(仅填数字,无需填入单位),请勿设置过大或过小。启用分片截图时生效。
84
84
  splitHeight: 8000
85
85
 
86
+ # 渲染动态内容是否暂停 GIF 动图,默认 0 否,1 是。
87
+ isPauseGif: 0
88
+
86
89
  # 直播动态是否@全体成员,默认 0 关闭,1 开启。
87
90
  # 开启前请检查 <机器人> 是否有 [管理员权限] 或 [聊天平台是否支持],某些聊天平台或类型不支持@全体成员,如qq官方机器人等。
88
91
  liveAtAll: 0
@@ -77,3 +77,6 @@ noSplitHeight: 7500
77
77
 
78
78
  # 动态卡片分页截图高度,默认8000px(仅填数字,无需填入单位),请勿设置过大或过小。启用分片截图时生效。
79
79
  splitHeight: 8000
80
+
81
+ # 渲染动态内容是否暂停 GIF 动图,默认 0 否,1 是。
82
+ isPauseGif: 0
@@ -42,15 +42,16 @@ class BiliQuery {
42
42
  return { url: item?.url, width: item?.width, height: item?.height };
43
43
  }) || [];
44
44
  additional = data?.modules?.module_dynamic?.additional;
45
+ formatData.data.title = desc?.title || '';
45
46
  formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text, additional) || '';
46
47
  }
47
48
  else {
48
49
  desc = data?.modules?.module_dynamic?.desc || {};
49
50
  pics = data?.modules?.module_dynamic?.major?.draw?.items;
50
51
  pics = [];
52
+ formatData.data.title = desc?.title || '';
51
53
  formatData.data.content = this.parseRichTextNodes(desc?.text);
52
54
  }
53
- formatData.data.title = '';
54
55
  formatData.data.url = `${BiliDrawDynamicLinkUrl}${data.id_str}`;
55
56
  formatData.data.pubTime = author.pub_time;
56
57
  formatData.data.pubTs = moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss');
@@ -65,6 +66,7 @@ class BiliQuery {
65
66
  return { url: item?.url, width: item?.width, height: item?.height };
66
67
  });
67
68
  additional = data?.modules?.module_dynamic?.additional;
69
+ formatData.data.title = desc?.title || '';
68
70
  formatData.data.content = this.parseRichTextNodes(desc?.summary?.rich_text_nodes || desc?.summary?.text, additional) || '';
69
71
  }
70
72
  else if (majorType === 'MAJOR_TYPE_DRAW') {
@@ -73,6 +75,7 @@ class BiliQuery {
73
75
  pics = pics.map((item) => {
74
76
  return { url: item?.url, width: item?.width, height: item?.height };
75
77
  });
78
+ formatData.data.title = desc?.title || '';
76
79
  formatData.data.content = this.parseRichTextNodes(desc?.rich_text_nodes || desc?.text) || '';
77
80
  }
78
81
  else {
@@ -81,9 +84,9 @@ class BiliQuery {
81
84
  pics = pics.map((item) => {
82
85
  return { url: item?.src };
83
86
  });
87
+ formatData.data.title = desc?.title || '';
84
88
  formatData.data.content = this.parseRichTextNodes(desc?.text);
85
89
  }
86
- formatData.data.title = '';
87
90
  formatData.data.url = `${BiliDrawDynamicLinkUrl}${data.id_str}`;
88
91
  formatData.data.pubTime = author.pub_time;
89
92
  formatData.data.pubTs = moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss');
@@ -453,6 +456,7 @@ class BiliQuery {
453
456
  msg_meta = `B站【${upName}】图文动态推送:`;
454
457
  msg = [
455
458
  msg_meta,
459
+ ...(desc?.title ? [`\n--------------------`, `\n${desc.title}`] : []),
456
460
  `\n--------------------`,
457
461
  `\n正文:`,
458
462
  `\n${this.dynamicContentLimit(content, setData)}`,
@@ -508,6 +512,7 @@ class BiliQuery {
508
512
  msg_meta = `B站【${upName}】图文动态推送:`;
509
513
  msg = [
510
514
  msg_meta,
515
+ ...(desc?.title ? [`\n--------------------`, `\n${desc.title}`] : []),
511
516
  `\n--------------------`,
512
517
  `\n正文:`,
513
518
  `\n${this.dynamicContentLimit(content, setData)}`,
@@ -212,6 +212,7 @@ class BiliTask {
212
212
  let isSplit = !!biliConfigData.isSplit === false ? false : true; // 是否启用分片截图,默认为 true
213
213
  let style = isSplit ? '' : `.unfold { max-height: ${biliConfigData?.noSplitHeight ?? 7500}px; }`; // 不启用分片截图模式的样式
214
214
  let splitHeight = biliConfigData?.splitHeight || 8000; // 分片截图高度,默认 8000, 单位 px,启用分片截图时生效
215
+ let isPauseGif = !!biliConfigData?.isPauseGif === true ? true : false; // 是否暂停 GIF 动图,默认为 false
215
216
  const urlQrcodeData = await QRCode.toDataURL(extentData?.url);
216
217
  let renderData = this.buildRenderData(extentData, urlQrcodeData, boxGrid);
217
218
  const ScreenshotOptionsData = {
@@ -224,7 +225,8 @@ class BiliTask {
224
225
  quality: 98
225
226
  },
226
227
  saveHtmlfile: false,
227
- pageSplitHeight: splitHeight
228
+ pageSplitHeight: splitHeight,
229
+ isPauseGif: isPauseGif
228
230
  };
229
231
  let imgs = await this.renderDynamicCard(uid, renderData, ScreenshotOptionsData);
230
232
  if (!imgs)
@@ -279,22 +281,25 @@ class BiliTask {
279
281
  * @returns 渲染数据
280
282
  */
281
283
  buildRenderData(extentData, urlQrcodeData, boxGrid) {
284
+ const baseData = {
285
+ appName: 'bilibili',
286
+ boxGrid: boxGrid,
287
+ type: extentData?.type,
288
+ face: extentData?.face,
289
+ pendant: extentData?.pendant,
290
+ name: extentData?.name,
291
+ pubTs: extentData?.pubTs,
292
+ title: extentData?.title,
293
+ content: extentData?.content,
294
+ urlImgData: urlQrcodeData,
295
+ created: extentData?.created,
296
+ pics: extentData?.pics,
297
+ category: extentData?.category
298
+ };
282
299
  if (extentData.orig && extentData.orig.length !== 0) {
283
300
  return {
284
301
  data: {
285
- appName: 'bilibili',
286
- boxGrid: boxGrid,
287
- type: extentData?.type,
288
- face: extentData?.face,
289
- pendant: extentData?.pendant,
290
- name: extentData?.name,
291
- pubTs: extentData?.pubTs,
292
- title: extentData?.title,
293
- content: extentData?.content,
294
- urlImgData: urlQrcodeData,
295
- created: extentData?.created,
296
- pics: extentData?.pics,
297
- category: extentData?.category,
302
+ ...baseData,
298
303
  orig: {
299
304
  data: {
300
305
  type: extentData?.orig?.data?.type,
@@ -312,23 +317,7 @@ class BiliTask {
312
317
  };
313
318
  }
314
319
  else {
315
- return {
316
- data: {
317
- appName: 'bilibili',
318
- boxGrid: boxGrid,
319
- type: extentData?.type,
320
- face: extentData?.face,
321
- pendant: extentData?.pendant,
322
- name: extentData?.name,
323
- pubTs: extentData?.pubTs,
324
- title: extentData?.title,
325
- content: extentData?.content,
326
- urlImgData: urlQrcodeData,
327
- created: extentData?.created,
328
- pics: extentData?.pics,
329
- category: extentData?.category
330
- }
331
- };
320
+ return { data: baseData };
332
321
  }
333
322
  }
334
323
  /**
@@ -177,6 +177,7 @@ class WeiboTask {
177
177
  let isSplit = !!weiboConfigData.isSplit === false ? false : true; // 是否启用分片截图,默认为 true
178
178
  let style = isSplit ? '' : `.unfold { max-height: ${weiboConfigData?.noSplitHeight ?? 7500}px; }`; // 不启用分片截图模式的样式
179
179
  let splitHeight = weiboConfigData?.splitHeight ?? 8000; // 分片截图高度,默认 8000, 单位 px,启用分片截图时生效
180
+ let isPauseGif = !!weiboConfigData?.isPauseGif === true ? true : false; // 是否暂停 GIF 动图,默认为 false
180
181
  const extentData = { ...data };
181
182
  const urlQrcodeData = await QRCode.toDataURL(extentData?.url);
182
183
  let renderData = this.buildRenderData(extentData, urlQrcodeData, boxGrid);
@@ -190,7 +191,8 @@ class WeiboTask {
190
191
  quality: 98
191
192
  },
192
193
  saveHtmlfile: false,
193
- pageSplitHeight: splitHeight
194
+ pageSplitHeight: splitHeight,
195
+ isPauseGif: isPauseGif
194
196
  };
195
197
  let imgs = await this.renderDynamicCard(uid, renderData, ScreenshotOptionsData);
196
198
  if (!imgs)
@@ -245,22 +247,25 @@ class WeiboTask {
245
247
  * @returns 渲染数据
246
248
  */
247
249
  buildRenderData(extentData, urlQrcodeData, boxGrid) {
250
+ const baseData = {
251
+ appName: 'weibo',
252
+ boxGrid: boxGrid,
253
+ type: extentData?.type,
254
+ face: extentData?.face,
255
+ pendant: extentData?.pendant,
256
+ name: extentData?.name,
257
+ pubTs: extentData?.pubTs,
258
+ title: extentData?.title,
259
+ content: extentData?.content,
260
+ urlImgData: urlQrcodeData,
261
+ created: extentData?.created,
262
+ pics: extentData?.pics,
263
+ category: extentData?.category
264
+ };
248
265
  if (extentData.orig && extentData.orig.length !== 0) {
249
266
  return {
250
267
  data: {
251
- appName: 'weibo',
252
- boxGrid: boxGrid,
253
- type: extentData?.type,
254
- face: extentData?.face,
255
- pendant: extentData?.pendant,
256
- name: extentData?.name,
257
- pubTs: extentData?.pubTs,
258
- title: extentData?.title,
259
- content: extentData?.content,
260
- urlImgData: urlQrcodeData,
261
- created: extentData?.created,
262
- pics: extentData?.pics,
263
- category: extentData?.category,
268
+ ...baseData,
264
269
  orig: {
265
270
  data: {
266
271
  type: extentData?.orig?.data?.type,
@@ -278,23 +283,7 @@ class WeiboTask {
278
283
  };
279
284
  }
280
285
  else {
281
- return {
282
- data: {
283
- appName: 'weibo',
284
- boxGrid: boxGrid,
285
- type: extentData?.type,
286
- face: extentData?.face,
287
- pendant: extentData?.pendant,
288
- name: extentData?.name,
289
- pubTs: extentData?.pubTs,
290
- title: extentData?.title,
291
- content: extentData?.content,
292
- urlImgData: urlQrcodeData,
293
- created: extentData?.created,
294
- pics: extentData?.pics,
295
- category: extentData?.category
296
- }
297
- };
286
+ return { data: baseData };
298
287
  }
299
288
  }
300
289
  /**
@@ -53,7 +53,9 @@ class YukiPuppeteerRender {
53
53
  pageHeight = Math.round(boundingBox.height / num); //动态调整分片高度,防止过短影响观感。
54
54
  await page.setViewport({ width: boundingBox.width + 50, height: pageHeight + 100 });
55
55
  // 禁止 GIF 动图播放
56
- await page.addStyleTag({ content: `img[src$=".gif"] {animation-play-state: paused !important;}` });
56
+ if (Options?.isPauseGif === true) {
57
+ await page.addStyleTag({ content: `img[src$=".gif"] {animation-play-state: paused !important;}` });
58
+ }
57
59
  // 是否保存 html 文件
58
60
  if (Options?.saveHtmlfile === true) {
59
61
  const htmlContent = await page.content();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yz-yuki-plugin",
3
- "version": "2.0.8-0",
3
+ "version": "2.0.8-2",
4
4
  "description": "优纪插件,yunzaijs 关于 微博推送、B站推送 等功能的拓展插件",
5
5
  "author": "snowtafir",
6
6
  "type": "module",