koishi-plugin-bilibili-videolink-analysis 1.1.17 → 1.1.19
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/index.js +11 -8
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -153,7 +153,7 @@ function apply(ctx, config) {
|
|
|
153
153
|
const links = await isProcessLinks(sessioncontent); // 判断是否需要解析
|
|
154
154
|
if (links) {
|
|
155
155
|
const ret = await extractLinks(session, config, ctx, links); // 提取链接
|
|
156
|
-
if (ret && !isLinkProcessedRecently(ret, lastProcessedUrls, config,
|
|
156
|
+
if (ret && !isLinkProcessedRecently(ret, lastProcessedUrls, config, session.channelId)) {
|
|
157
157
|
await processVideoFromLink(session, config, ctx, lastProcessedUrls, logger, ret); // 解析视频并返回
|
|
158
158
|
}
|
|
159
159
|
}
|
|
@@ -386,7 +386,7 @@ display: none !important;
|
|
|
386
386
|
if (config.enable) { // 开启自动解析了
|
|
387
387
|
|
|
388
388
|
const ret = await extractLinks(session, config, ctx, [{ type: 'Video', id: chosenVideo.id }], logger); // 提取链接
|
|
389
|
-
if (ret && !isLinkProcessedRecently(ret, lastProcessedUrls, config,
|
|
389
|
+
if (ret && !isLinkProcessedRecently(ret, lastProcessedUrls, config, session.channelId)) {
|
|
390
390
|
await processVideoFromLink(session, config, ctx, lastProcessedUrls, logger, ret, options); // 解析视频并返回
|
|
391
391
|
}
|
|
392
392
|
}
|
|
@@ -434,18 +434,21 @@ display: none !important;
|
|
|
434
434
|
}
|
|
435
435
|
|
|
436
436
|
//判断链接是否已经处理过
|
|
437
|
-
function isLinkProcessedRecently(ret, lastProcessedUrls, config,
|
|
437
|
+
function isLinkProcessedRecently(ret, lastProcessedUrls, config, channelId) {
|
|
438
438
|
const lastretUrl = extractLastUrl(ret); // 提取 ret 最后一个 http 链接作为解析目标
|
|
439
439
|
const currentTime = Date.now();
|
|
440
440
|
|
|
441
|
-
|
|
442
|
-
|
|
441
|
+
// channelId 作为 key 的一部分,分频道鉴别
|
|
442
|
+
const channelKey = `${channelId}:${lastretUrl}`;
|
|
443
|
+
|
|
444
|
+
if (lastProcessedUrls[channelKey] && (currentTime - lastProcessedUrls[channelKey] < config.MinimumTimeInterval * 1000)) {
|
|
445
|
+
ctx.logger.info(`重复出现,略过处理:\n ${lastretUrl} (频道 ${channelId})`);
|
|
443
446
|
|
|
444
447
|
return true; // 已经处理过
|
|
445
448
|
}
|
|
446
449
|
|
|
447
|
-
//
|
|
448
|
-
lastProcessedUrls[
|
|
450
|
+
// 更新该链接的最后处理时间,使用 channelKey
|
|
451
|
+
lastProcessedUrls[channelKey] = currentTime;
|
|
449
452
|
return false; // 没有处理过
|
|
450
453
|
}
|
|
451
454
|
|
|
@@ -494,7 +497,7 @@ display: none !important;
|
|
|
494
497
|
|
|
495
498
|
// 视频/链接解析
|
|
496
499
|
if (config.VideoParsing_ToLink) {
|
|
497
|
-
const fullAPIurl = `
|
|
500
|
+
const fullAPIurl = `http://api.xingzhige.cn/API/b_parse/?url=${encodeURIComponent(lastretUrl)}`;
|
|
498
501
|
|
|
499
502
|
try {
|
|
500
503
|
const responseData = await ctx.http.get(fullAPIurl);
|
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.1.
|
|
5
|
+
"version": "1.1.19",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
8
8
|
"files": [
|