koishi-plugin-video-parser-all 1.3.6 → 1.3.7

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.d.ts CHANGED
@@ -93,11 +93,6 @@ export declare const Config: Schema<{
93
93
  } & {
94
94
  primaryApiUrl?: string | null | undefined;
95
95
  backupApiUrl?: string | null | undefined;
96
- apiKeys?: ({
97
- key?: string | null | undefined;
98
- weight?: number | null | undefined;
99
- } & import("cosmokit").Dict)[] | null | undefined;
100
- rotationMode?: "sequential" | "load_balance" | null | undefined;
101
96
  platformDedicatedFirst?: ({
102
97
  bilibili?: boolean | null | undefined;
103
98
  douyin?: boolean | null | undefined;
@@ -248,11 +243,6 @@ export declare const Config: Schema<{
248
243
  } & {
249
244
  primaryApiUrl: string;
250
245
  backupApiUrl: string;
251
- apiKeys: Schemastery.ObjectT<{
252
- key: Schema<string, string>;
253
- weight: Schema<number, number>;
254
- }>[];
255
- rotationMode: "sequential" | "load_balance";
256
246
  platformDedicatedFirst: Schemastery.ObjectT<{
257
247
  bilibili: Schema<boolean, boolean>;
258
248
  douyin: Schema<boolean, boolean>;
package/lib/index.js CHANGED
@@ -169,14 +169,6 @@ exports.Config = koishi_1.Schema.intersect([
169
169
  koishi_1.Schema.object({
170
170
  primaryApiUrl: koishi_1.Schema.string().default('https://api.bugpk.com/api/short_videos').hidden(),
171
171
  backupApiUrl: koishi_1.Schema.string().default('https://api.bugpk.com/api/svparse').hidden(),
172
- apiKeys: koishi_1.Schema.array(koishi_1.Schema.object({
173
- key: koishi_1.Schema.string().required().description('API Key'),
174
- weight: koishi_1.Schema.number().min(1).default(1).description('权重(负载均衡模式)'),
175
- })).default([]).description('多 API 密钥(轮换使用)'),
176
- rotationMode: koishi_1.Schema.union([
177
- koishi_1.Schema.const('sequential').description('顺序模式(无效时切换)'),
178
- koishi_1.Schema.const('load_balance').description('负载均衡模式(轮询)'),
179
- ]).default('sequential').description('密钥轮换模式'),
180
172
  platformDedicatedFirst: koishi_1.Schema.object({
181
173
  bilibili: koishi_1.Schema.boolean().default(false).description('哔哩哔哩'),
182
174
  douyin: koishi_1.Schema.boolean().default(false).description('抖音'),
@@ -693,8 +685,6 @@ function parseFieldMapping(mappingStr) {
693
685
  }
694
686
  }
695
687
  function apply(ctx, config) {
696
- // @ts-expect-error koishi runtime supports optional service dependencies
697
- ctx.using(['downloads', 'silk', 'ffmpeg'], { optional: true });
698
688
  debugEnabled = config.debug || false;
699
689
  debugLog('INFO', 'plugin start');
700
690
  const dedupCache = new SimpleLRUCache(1000, config.deduplicationInterval * 1000);
@@ -740,38 +730,6 @@ function apply(ctx, config) {
740
730
  logger.warn('aria2 连接失败,回退到内置下载');
741
731
  }
742
732
  }
743
- const apiKeyList = (config.apiKeys || []).map((k) => ({
744
- key: k.key,
745
- weight: k.weight || 1,
746
- lastUsed: 0
747
- }));
748
- let keyIndex = 0;
749
- function getNextApiKey() {
750
- if (apiKeyList.length === 0)
751
- return '';
752
- if (config.rotationMode === 'load_balance') {
753
- const totalWeight = apiKeyList.reduce((sum, k) => sum + k.weight, 0);
754
- let rand = Math.random() * totalWeight;
755
- for (const k of apiKeyList) {
756
- rand -= k.weight;
757
- if (rand <= 0)
758
- return k.key;
759
- }
760
- return apiKeyList[0].key;
761
- }
762
- else {
763
- const current = apiKeyList[keyIndex % apiKeyList.length];
764
- keyIndex++;
765
- return current.key;
766
- }
767
- }
768
- function markApiKeyInvalid(key) {
769
- if (config.rotationMode === 'sequential') {
770
- const idx = apiKeyList.findIndex(k => k.key === key);
771
- if (idx !== -1)
772
- apiKeyList.splice(idx, 1);
773
- }
774
- }
775
733
  function getPlatformConfig(type) {
776
734
  if (type.startsWith('custom_')) {
777
735
  const name = type.slice(7);
@@ -780,7 +738,7 @@ function apply(ctx, config) {
780
738
  return {
781
739
  apiUrl: custom.apiUrl,
782
740
  dedicatedFirst: true,
783
- apiKey: custom.apiKey || getNextApiKey(),
741
+ apiKey: custom.apiKey || '',
784
742
  authHeaderType: custom.authHeaderType,
785
743
  customHeaderName: custom.customHeaderName,
786
744
  fieldMapping: custom.fieldMapping,
@@ -812,13 +770,13 @@ function apply(ctx, config) {
812
770
  let fieldMapping = undefined;
813
771
  if (custom && custom.apiUrl) {
814
772
  apiUrl = custom.apiUrl;
815
- apiKey = custom.apiKey || getNextApiKey();
773
+ apiKey = custom.apiKey || '';
816
774
  authHeaderType = custom.authHeaderType || 'Bearer';
817
775
  customHeaderName = custom.customHeaderName || 'X-API-Key';
818
776
  fieldMapping = parseFieldMapping(custom.fieldMapping);
819
777
  }
820
778
  else {
821
- apiKey = getNextApiKey();
779
+ apiKey = '';
822
780
  }
823
781
  const dedicatedFirst = config.platformDedicatedFirst?.[type] ?? false;
824
782
  if (!fieldMapping) {
@@ -1199,10 +1157,6 @@ function apply(ctx, config) {
1199
1157
  urlCacheLocal.set(cacheKey, { data: parsed, expire: Date.now() + cacheTTL });
1200
1158
  return parsed;
1201
1159
  }
1202
- if (res.data?.code === 403 || res.data?.code === 401) {
1203
- if (api.apiKey)
1204
- markApiKeyInvalid(api.apiKey);
1205
- }
1206
1160
  throw new Error(res.data?.msg || `API返回错误码: ${res.data?.code}`);
1207
1161
  }
1208
1162
  catch (error) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-video-parser-all",
3
3
  "description": "Koishi 全平台视频/图集解析插件,支持抖音/快手/B站/微博/小红书/剪映/YouTube/TikTok等20+平台",
4
- "version": "1.3.6",
4
+ "version": "1.3.7",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [