koishi-plugin-bilibili-videolink-analysis 1.3.3 → 1.3.4

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 (3) hide show
  1. package/lib/index.js +17 -17
  2. package/package.json +1 -1
  3. package/src/utils.ts +17 -17
package/lib/index.js CHANGED
@@ -153,26 +153,26 @@ var BilibiliParser = class {
153
153
  }
154
154
  // 实际处理单个 session 任务
155
155
  async processSessionTask(session, sessioncontent) {
156
- this.logger.info(`[队列] 开始处理消息: ${sessioncontent.substring(0, 50)}...`);
156
+ this.logInfo(`[队列] 开始处理消息: ${sessioncontent.substring(0, 50)}...`);
157
157
  const links = await this.isProcessLinks(sessioncontent);
158
158
  if (!links) {
159
- this.logger.info(`[队列] 未检测到链接`);
159
+ this.logInfo(`[队列] 未检测到链接`);
160
160
  return;
161
161
  }
162
- this.logger.info(`[队列] 检测到 ${links.length} 个链接`);
162
+ this.logInfo(`[队列] 检测到 ${links.length} 个链接`);
163
163
  for (let i = 0; i < links.length; i++) {
164
164
  const link = links[i];
165
- this.logger.info(`[队列] 处理第 ${i + 1}/${links.length} 个链接`);
165
+ this.logInfo(`[队列] 处理第 ${i + 1}/${links.length} 个链接`);
166
166
  const ret = await this.extractLinks(session, [link]);
167
167
  if (ret && !this.isLinkProcessedRecently(ret, session.channelId)) {
168
- this.logger.info(`[队列] 开始下载视频`);
168
+ this.logInfo(`[队列] 开始下载视频`);
169
169
  await this.processVideoTask(session, ret, { video: true });
170
- this.logger.info(`[队列] 视频处理完成`);
170
+ this.logInfo(`[队列] 视频处理完成`);
171
171
  } else {
172
- this.logger.info(`[队列] 链接已处理过,跳过`);
172
+ this.logInfo(`[队列] 链接已处理过,跳过`);
173
173
  }
174
174
  }
175
- this.logger.info(`[队列] Session 处理完成`);
175
+ this.logInfo(`[队列] Session 处理完成`);
176
176
  }
177
177
  // 添加任务到缓冲区(已废弃,保留兼容性)
178
178
  async processVideoFromLink(session, ret, options = { video: true }) {
@@ -255,7 +255,7 @@ var BilibiliParser = class {
255
255
  }
256
256
  }
257
257
  if (this.config.videoParseComponents.length > 0) {
258
- const fullAPIurl = `http://api.xingzhige.cn/API/b_parse/?url=${encodeURIComponent(lastretUrl)}`;
258
+ const fullAPIurl = `http://api.xingzhige.com/API/b_parse/?url=${encodeURIComponent(lastretUrl)}`;
259
259
  try {
260
260
  const responseData = await this.ctx.http.get(fullAPIurl);
261
261
  if (responseData.code === 0 && responseData.msg === "video" && responseData.data) {
@@ -312,24 +312,24 @@ var BilibiliParser = class {
312
312
  }
313
313
  const contentLength = response.headers.get("content-length");
314
314
  const fileSizeMB = contentLength ? parseInt(contentLength) / 1024 / 1024 : 0;
315
- this.logger.info(`[下载] 视频大小: ${fileSizeMB.toFixed(2)}MB`);
315
+ this.logInfo(`[下载] 视频大小: ${fileSizeMB.toFixed(2)}MB`);
316
316
  const maxSize = this.config.maxFileSizeMB;
317
- this.logger.info(`[下载] 配置的最大大小: ${maxSize}MB`);
317
+ this.logInfo(`[下载] 配置的最大大小: ${maxSize}MB`);
318
318
  if (maxSize > 0 && fileSizeMB > maxSize) {
319
319
  this.logger.warn(`[下载] 文件过大 (${fileSizeMB.toFixed(2)}MB > ${maxSize}MB),使用直链模式`);
320
320
  videoData = video.url;
321
321
  } else {
322
- this.logger.info(`[下载] 开始下载并转换为Base64...`);
322
+ this.logInfo(`[下载] 开始下载并转换为Base64...`);
323
323
  const contentType = response.headers.get("content-type");
324
324
  const mimeType = contentType ? contentType.split(";")[0].trim() : "video/mp4";
325
- this.logger.info(`[下载] 读取响应体...`);
325
+ this.logInfo(`[下载] 读取响应体...`);
326
326
  const arrayBuffer = await response.arrayBuffer();
327
- this.logger.info(`[下载] 创建Buffer...`);
327
+ this.logInfo(`[下载] 创建Buffer...`);
328
328
  const buffer = Buffer.from(arrayBuffer);
329
- this.logger.info(`[下载] 转换为Base64...`);
329
+ this.logInfo(`[下载] 转换为Base64...`);
330
330
  const base64Data = buffer.toString("base64");
331
331
  videoData = `data:${mimeType};base64,${base64Data}`;
332
- this.logger.info(`[下载] 视频下载完成,已转换为Base64`);
332
+ this.logInfo(`[下载] 视频下载完成,已转换为Base64`);
333
333
  }
334
334
  } catch (error) {
335
335
  this.logger.error("下载视频失败:", error);
@@ -342,7 +342,7 @@ var BilibiliParser = class {
342
342
  videoElements.push(import_koishi.h.audio(videoData));
343
343
  } else {
344
344
  if (this.config.videoParseComponents.includes("log")) {
345
- this.logger.info(video.url);
345
+ this.logInfo(video.url);
346
346
  }
347
347
  if (this.config.videoParseComponents.includes("link")) {
348
348
  videoElements.push(import_koishi.h.text(video.url));
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "koishi-plugin-bilibili-videolink-analysis",
3
3
  "description": "[<ruby>Bilibili视频解析<rp>(</rp><rt>点我查看食用方法</rt><rp>)</rp></ruby>](https://www.npmjs.com/package/koishi-plugin-bilibili-videolink-analysis)解析B站链接(支持小程序卡片)支持搜索点播功能!灵感来自完美的 [bili-parser](/market?keyword=bili-parser) !",
4
4
  "license": "MIT",
5
- "version": "1.3.3",
5
+ "version": "1.3.4",
6
6
  "main": "lib/index.js",
7
7
  "typings": "lib/index.d.ts",
8
8
  "files": [
package/src/utils.ts CHANGED
@@ -161,33 +161,33 @@ export class BilibiliParser {
161
161
 
162
162
  // 实际处理单个 session 任务
163
163
  private async processSessionTask(session: Session, sessioncontent: string) {
164
- this.logger.info(`[队列] 开始处理消息: ${sessioncontent.substring(0, 50)}...`);
164
+ this.logInfo(`[队列] 开始处理消息: ${sessioncontent.substring(0, 50)}...`);
165
165
 
166
166
  const links = await this.isProcessLinks(sessioncontent);
167
167
  if (!links) {
168
- this.logger.info(`[队列] 未检测到链接`);
168
+ this.logInfo(`[队列] 未检测到链接`);
169
169
  return;
170
170
  }
171
171
 
172
- this.logger.info(`[队列] 检测到 ${links.length} 个链接`);
172
+ this.logInfo(`[队列] 检测到 ${links.length} 个链接`);
173
173
 
174
174
  // 逐个处理链接
175
175
  for (let i = 0; i < links.length; i++) {
176
176
  const link = links[i];
177
- this.logger.info(`[队列] 处理第 ${i + 1}/${links.length} 个链接`);
177
+ this.logInfo(`[队列] 处理第 ${i + 1}/${links.length} 个链接`);
178
178
 
179
179
  const ret = await this.extractLinks(session, [link]);
180
180
  if (ret && !this.isLinkProcessedRecently(ret, session.channelId)) {
181
- this.logger.info(`[队列] 开始下载视频`);
181
+ this.logInfo(`[队列] 开始下载视频`);
182
182
  // 直接处理,不再使用视频级别的缓冲
183
183
  await this.processVideoTask(session, ret, { video: true });
184
- this.logger.info(`[队列] 视频处理完成`);
184
+ this.logInfo(`[队列] 视频处理完成`);
185
185
  } else {
186
- this.logger.info(`[队列] 链接已处理过,跳过`);
186
+ this.logInfo(`[队列] 链接已处理过,跳过`);
187
187
  }
188
188
  }
189
189
 
190
- this.logger.info(`[队列] Session 处理完成`);
190
+ this.logInfo(`[队列] Session 处理完成`);
191
191
  }
192
192
 
193
193
  // 添加任务到缓冲区(已废弃,保留兼容性)
@@ -304,7 +304,7 @@ export class BilibiliParser {
304
304
 
305
305
  // 视频/链接解析
306
306
  if (this.config.videoParseComponents.length > 0) {
307
- const fullAPIurl = `http://api.xingzhige.cn/API/b_parse/?url=${encodeURIComponent(lastretUrl)}`;
307
+ const fullAPIurl = `http://api.xingzhige.com/API/b_parse/?url=${encodeURIComponent(lastretUrl)}`;
308
308
 
309
309
  try {
310
310
  const responseData: any = await this.ctx.http.get(fullAPIurl);
@@ -390,33 +390,33 @@ export class BilibiliParser {
390
390
  // 检查文件大小
391
391
  const contentLength = response.headers.get('content-length');
392
392
  const fileSizeMB = contentLength ? parseInt(contentLength) / 1024 / 1024 : 0;
393
- this.logger.info(`[下载] 视频大小: ${fileSizeMB.toFixed(2)}MB`);
393
+ this.logInfo(`[下载] 视频大小: ${fileSizeMB.toFixed(2)}MB`);
394
394
 
395
395
  // 检查是否超过配置的最大大小
396
396
  const maxSize = this.config.maxFileSizeMB;
397
- this.logger.info(`[下载] 配置的最大大小: ${maxSize}MB`);
397
+ this.logInfo(`[下载] 配置的最大大小: ${maxSize}MB`);
398
398
 
399
399
  if (maxSize > 0 && fileSizeMB > maxSize) {
400
400
  this.logger.warn(`[下载] 文件过大 (${fileSizeMB.toFixed(2)}MB > ${maxSize}MB),使用直链模式`);
401
401
  // 不下载,使用原始URL
402
402
  videoData = video.url;
403
403
  } else {
404
- this.logger.info(`[下载] 开始下载并转换为Base64...`);
404
+ this.logInfo(`[下载] 开始下载并转换为Base64...`);
405
405
 
406
406
  // 获取 MIME 类型
407
407
  const contentType = response.headers.get('content-type');
408
408
  const mimeType = contentType ? contentType.split(';')[0].trim() : 'video/mp4';
409
409
 
410
- this.logger.info(`[下载] 读取响应体...`);
410
+ this.logInfo(`[下载] 读取响应体...`);
411
411
  // 读取响应体并转换
412
412
  const arrayBuffer = await response.arrayBuffer();
413
- this.logger.info(`[下载] 创建Buffer...`);
413
+ this.logInfo(`[下载] 创建Buffer...`);
414
414
  const buffer = Buffer.from(arrayBuffer);
415
- this.logger.info(`[下载] 转换为Base64...`);
415
+ this.logInfo(`[下载] 转换为Base64...`);
416
416
  const base64Data = buffer.toString('base64');
417
417
  videoData = `data:${mimeType};base64,${base64Data}`;
418
418
 
419
- this.logger.info(`[下载] 视频下载完成,已转换为Base64`);
419
+ this.logInfo(`[下载] 视频下载完成,已转换为Base64`);
420
420
  }
421
421
  } catch (error) {
422
422
  this.logger.error("下载视频失败:", error);
@@ -432,7 +432,7 @@ export class BilibiliParser {
432
432
  videoElements.push(h.audio(videoData));
433
433
  } else {
434
434
  if (this.config.videoParseComponents.includes('log')) {
435
- this.logger.info(video.url);
435
+ this.logInfo(video.url);
436
436
  }
437
437
  if (this.config.videoParseComponents.includes('link')) {
438
438
  videoElements.push(h.text(video.url));