koishi-plugin-video-parser-all 1.1.4 → 1.1.6
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 +5 -4
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -10,7 +10,8 @@ const promises_1 = __importDefault(require("fs/promises"));
|
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const fs_1 = require("fs");
|
|
12
12
|
const promises_2 = require("stream/promises");
|
|
13
|
-
const
|
|
13
|
+
const LruCacheModule = require('lru-cache');
|
|
14
|
+
const LRUCache = LruCacheModule.LRUCache || LruCacheModule;
|
|
14
15
|
exports.name = 'video-parser-all';
|
|
15
16
|
exports.Config = koishi_1.Schema.intersect([
|
|
16
17
|
koishi_1.Schema.object({
|
|
@@ -119,7 +120,7 @@ function debugLog(level, ...args) {
|
|
|
119
120
|
}).join(' ')}`;
|
|
120
121
|
logger.info(message);
|
|
121
122
|
}
|
|
122
|
-
const urlCache = new
|
|
123
|
+
const urlCache = new LRUCache({
|
|
123
124
|
max: 500,
|
|
124
125
|
ttl: 10 * 60 * 1000,
|
|
125
126
|
updateAgeOnGet: false,
|
|
@@ -437,7 +438,7 @@ function getErrorMessage(error) {
|
|
|
437
438
|
function apply(ctx, config) {
|
|
438
439
|
debugEnabled = config.debug || false;
|
|
439
440
|
debugLog('INFO', '插件初始化开始');
|
|
440
|
-
const dedupCache = new
|
|
441
|
+
const dedupCache = new LRUCache({
|
|
441
442
|
max: 1000,
|
|
442
443
|
ttl: config.deduplicationInterval * 1000,
|
|
443
444
|
});
|
|
@@ -481,7 +482,7 @@ function apply(ctx, config) {
|
|
|
481
482
|
'Referer': 'https://www.baidu.com/',
|
|
482
483
|
},
|
|
483
484
|
validateStatus: (status) => status >= 200 && status < 400,
|
|
484
|
-
});
|
|
485
|
+
});
|
|
485
486
|
const finalUrl = res.request?.res?.responseUrl || url;
|
|
486
487
|
return cleanUrl(finalUrl);
|
|
487
488
|
}
|
package/package.json
CHANGED