karin-plugin-kkk 1.1.3 → 1.1.4-pr46.d747316

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/Version.js ADDED
@@ -0,0 +1,13 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { karinDir } from 'node-karin/root';
5
+ const pluginPath = path.join(fileURLToPath(import.meta.url), '../..');
6
+ const pkg = JSON.parse(fs.readFileSync(path.join(pluginPath, 'package.json'), 'utf-8'));
7
+ export const Version = {
8
+ pluginName: pkg.name,
9
+ pluginVersion: pkg.version,
10
+ pluginPath,
11
+ karinVersion: process.env.KARIN_VERSION,
12
+ karinPath: karinDir
13
+ };
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import { logger, tempPath } from 'node-karin';
3
3
  import { Config } from '../../module/utils/index.js';
4
- import { Version } from './Version.js';
4
+ import { Version } from '../../Version.js';
5
5
  /** 常用工具合集 */
6
6
  class Tools {
7
7
  /**
@@ -772,17 +772,17 @@ declare class Cfg {
772
772
  */
773
773
  Modify(name: keyof ConfigType, key: string, value: any, type?: ConfigDirType): void;
774
774
  /**
775
- * 修改整个配置文件,保留注释
776
- * @param name 文件名
777
- * @param config 完整的配置对象
778
- * @param type 配置文件类型,默认为用户配置文件 `config`
779
- */
775
+ * 修改整个配置文件,保留注释
776
+ * @param name 文件名
777
+ * @param config 完整的配置对象
778
+ * @param type 配置文件类型,默认为用户配置文件 `config`
779
+ */
780
780
  ModifyPro<T extends keyof ConfigType>(name: T, config: ConfigType[T], type?: ConfigDirType): boolean;
781
781
  /**
782
- * 深度合并YAML节点(保留目标注释)
783
- * @param target 目标节点(保留注释的原始节点)
784
- * @param source 源节点(提供新值的节点)
785
- */
782
+ * 深度合并YAML节点(保留目标注释)
783
+ * @param target 目标节点(保留注释的原始节点)
784
+ * @param source 源节点(提供新值的节点)
785
+ */
786
786
  private deepMergeYaml;
787
787
  /**
788
788
  * 在YAML映射中设置嵌套值
@@ -2,7 +2,7 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { basePath, copyConfigSync, filesByExt, logger, requireFileSync, watch } from 'node-karin';
4
4
  import YAML from 'node-karin/yaml';
5
- import { Version } from './Version.js';
5
+ import { Version } from '../../Version.js';
6
6
  class Cfg {
7
7
  /** 用户配置文件路径 */
8
8
  dirCfgPath;
@@ -102,11 +102,11 @@ class Cfg {
102
102
  fs.writeFileSync(path, yamlData.toString({ lineWidth: -1 }), 'utf8');
103
103
  }
104
104
  /**
105
- * 修改整个配置文件,保留注释
106
- * @param name 文件名
107
- * @param config 完整的配置对象
108
- * @param type 配置文件类型,默认为用户配置文件 `config`
109
- */
105
+ * 修改整个配置文件,保留注释
106
+ * @param name 文件名
107
+ * @param config 完整的配置对象
108
+ * @param type 配置文件类型,默认为用户配置文件 `config`
109
+ */
110
110
  ModifyPro(name, config, type = 'config') {
111
111
  const filePath = type === 'config'
112
112
  ? `${this.dirCfgPath}/${name}.yaml`
@@ -129,31 +129,29 @@ class Cfg {
129
129
  }
130
130
  }
131
131
  /**
132
- * 深度合并YAML节点(保留目标注释)
133
- * @param target 目标节点(保留注释的原始节点)
134
- * @param source 源节点(提供新值的节点)
135
- */
132
+ * 深度合并YAML节点(保留目标注释)
133
+ * @param target 目标节点(保留注释的原始节点)
134
+ * @param source 源节点(提供新值的节点)
135
+ */
136
136
  deepMergeYaml(target, source) {
137
137
  if (YAML.isMap(target) && YAML.isMap(source)) {
138
- // 遍历源节点的所有键
139
138
  for (const pair of source.items) {
140
139
  const key = pair.key;
141
140
  const sourceVal = pair.value;
142
141
  const targetVal = target.get(key);
143
142
  if (targetVal === undefined) {
144
- // 新增键:直接添加
145
143
  target.set(key, sourceVal);
146
144
  }
147
145
  else if (YAML.isMap(targetVal) && YAML.isMap(sourceVal)) {
148
- // 递归合并嵌套Map
149
146
  this.deepMergeYaml(targetVal, sourceVal);
150
147
  }
151
148
  else if (YAML.isSeq(targetVal) && YAML.isSeq(sourceVal)) {
152
- // 替换序列内容但保留注释
149
+ // 替换序列内容并保持源序列格式
153
150
  targetVal.items = sourceVal.items;
151
+ // 同步序列的显示格式
152
+ targetVal.flow = sourceVal.flow;
154
153
  }
155
154
  else {
156
- // 覆盖标量值但保留原键的注释
157
155
  target.set(key, sourceVal);
158
156
  }
159
157
  }
@@ -4,4 +4,4 @@ export * from './Config.js';
4
4
  export * from './FFmpeg.js';
5
5
  export * from './Networks.js';
6
6
  export * from './Render.js';
7
- export * from './Version.js';
7
+ export * from '../../Version.js';
@@ -4,4 +4,4 @@ export * from './Config.js';
4
4
  export * from './FFmpeg.js';
5
5
  export * from './Networks.js';
6
6
  export * from './Render.js';
7
- export * from './Version.js';
7
+ export * from '../../Version.js';
package/lib/web.config.js CHANGED
@@ -690,8 +690,13 @@ const deepEqual = (a, b) => {
690
690
  * @returns
691
691
  */
692
692
  function convertToNumber(value) {
693
- const num = parseInt(value);
694
- return isNaN(num) ? value : num;
693
+ // 检查字符串是否为有效的数字
694
+ if (/^\d+$/.test(value)) {
695
+ const num = parseInt(value, 10);
696
+ return num;
697
+ }
698
+ else
699
+ return value;
695
700
  }
696
701
  /**
697
702
  * 获取数组中的第一个对象,如果数组为空则返回空对象
@@ -718,10 +723,15 @@ function processFrontendData(data) {
718
723
  result[key] = {};
719
724
  for (const prop in firstObj) {
720
725
  let value = firstObj[prop];
721
- value = convertToNumber(value);
726
+ if (typeof value === 'string') { // 确保仅对字符串类型进行转换
727
+ value = convertToNumber(value);
728
+ }
722
729
  if (prop.includes(':')) {
723
730
  const [parent, child] = prop.split(':');
724
- if (!result[key][parent]) {
731
+ if (!result[key] || typeof result[key] !== 'object') {
732
+ result[key] = {};
733
+ }
734
+ if (!result[key][parent] || typeof result[key][parent] !== 'object') {
725
735
  result[key][parent] = {};
726
736
  }
727
737
  result[key][parent][child] = value;
@@ -733,7 +743,12 @@ function processFrontendData(data) {
733
743
  }
734
744
  result.pushlist = {
735
745
  douyin: data['pushlist:douyin'] || [],
736
- bilibili: data['pushlist:bilibili'] || []
746
+ bilibili: data['pushlist:bilibili'].map(item => {
747
+ return {
748
+ ...item,
749
+ host_mid: Number(item.host_mid)
750
+ };
751
+ }) || []
737
752
  };
738
753
  return result;
739
754
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karin-plugin-kkk",
3
- "version": "1.1.3",
3
+ "version": "1.1.4-pr46.d747316",
4
4
  "description": "a Karin video parsing tool",
5
5
  "keywords": [
6
6
  "karin-plugin",
@@ -1,271 +0,0 @@
1
- -
2
- # 配置文件描述
3
- name: Cookies相关
4
- # 配置文件名
5
- file: cookies.yaml
6
- # 视图信息
7
- view:
8
- -
9
- # 配置项
10
- key: 抖音ck
11
- # 配置描述
12
- comment: 抖音ck,用于请求官方API数据
13
- # 配置路径
14
- path: 'douyin'
15
- # 配置类型
16
- type: 'text'
17
- -
18
- key: B站ck
19
- comment: B站ck,用于请求官方API数据
20
- path: 'bilibili'
21
- type: 'text'
22
-
23
- -
24
- # 配置文件描述
25
- name: 应用设置
26
- # 配置文件名
27
- file: app.yaml
28
- # 视图信息
29
- view:
30
- -
31
- # 配置项
32
- key: 总开关
33
- # 配置描述
34
- comment: 视频解析工具总开关,修改后重启生效,关闭后可使用 kkk/kkk解析/解析 + 视频分享链接代替
35
- # 配置路径
36
- path: 'videotool'
37
- # 配置类型
38
- type: 'boolean'
39
- -
40
- key: 默认解析
41
- comment: 识别最高优先级,修改后重启生效
42
- path: 'defaulttool'
43
- type: 'boolean'
44
- -
45
- key: 发送合并转发消息
46
- comment: 可能多用于抖音解析
47
- path: 'sendforwardmsg'
48
- type: 'boolean'
49
- -
50
- key: 视频文件上传限制
51
- comment: 开启后会根据解析的视频文件大小判断是否需要上传(B站番剧无影响)
52
- path: 'usefilelimit'
53
- type: 'boolean'
54
- -
55
- key: 缓存删除
56
- comment: 非必要不修改!
57
- path: 'rmmp4'
58
- type: 'boolean'
59
- -
60
- key: API服务
61
- comment: '将所有api接口放出,作为一个本地的视频解析API服务,默认端口4567'
62
- path: 'APIServer'
63
- type: 'boolean'
64
- -
65
- key: API服务端口
66
- comment: 'API服务端口'
67
- path: 'APIServerPort'
68
- type: 'number'
69
- -
70
- key: API服务日志
71
- comment: '打开或关闭运行日志'
72
- path: 'APIServerLog'
73
- type: 'boolean'
74
- -
75
- key: 自定义优先级
76
- comment: 「默认解析」关闭后才会生效。修改后重启生效
77
- path: 'priority'
78
- type: 'number'
79
- -
80
- key: 视频文件大小限制
81
- comment: '视频文件大于该数值则不会上传 单位: MB,「视频文件上传限制」开启后才会生效(B站番剧无影响)'
82
- path: 'filelimit'
83
- type: 'number'
84
- -
85
- key: 渲染精度
86
- comment: 可选值50~200,建议100。设置高精度会提高图片的精细度,过高可能会影响渲染与发送速度
87
- path: 'renderScale'
88
- type: 'number'
89
-
90
- -
91
- # 配置文件描述
92
- name: 抖音相关
93
- # 配置文件名
94
- file: douyin.yaml
95
- # 视图信息
96
- view:
97
- -
98
- # 配置项
99
- key: 抖音解析开关
100
- # 配置描述
101
- comment: 单独开关,受「总开关」影响
102
- # 配置路径
103
- path: 'douyintool'
104
- # 配置类型
105
- type: 'boolean'
106
- -
107
- key: 抖音解析提示
108
- comment: 发送提示信息:“检测到抖音链接,开始解析”
109
- path: 'douyintip'
110
- type: 'boolean'
111
- -
112
- key: 抖音评论解析
113
- path: 'comments'
114
- type: 'boolean'
115
- -
116
- key: 抖音评论数量
117
- comment: 范围1~50条
118
- path: 'numcomments'
119
- type: 'number'
120
- -
121
- key: 发送抖音作品评论图
122
- path: 'commentsimg'
123
- type: 'boolean'
124
- -
125
- key: 抖音推送
126
- comment: 开启后需重启;使用[#设置抖音推送+抖音号]配置推送列表
127
- path: 'douyinpush'
128
- type: 'boolean'
129
- -
130
- key: 抖音推送日志
131
- comment: 打开或关闭定时任务日志
132
- path: 'douyinpushlog'
133
- type: 'boolean'
134
- -
135
- key: 抖音推送设置权限
136
- comment: '0: (all)所有人;1: (admin)群主和管理员;2: (owner)群主;3: (master)主人'
137
- path: 'douyinpushGroup'
138
- type: 'select'
139
- # 是否可以多选
140
- multiple: false
141
- # 选项
142
- item:
143
- -
144
- name: 所有人都可以添加
145
- value: all
146
- -
147
- name: 只有群管理员可以添加
148
- value: admin
149
- -
150
- name: 只有群主可以添加
151
- value: owner
152
- -
153
- name: 只有主人可以添加
154
- value: master
155
- -
156
- key: 抖音推送表达式
157
- path: 'douyinpushcron'
158
- type: 'boolean'
159
- -
160
- key: 图集BGM是否使用高清语音发送
161
- comment: 高清语音「ios/PC」系统均无法播放,自行衡量开关(仅icqq)
162
- path: 'sendHDrecord'
163
- type: 'boolean'
164
- -
165
- key: 抖音推送是否一同发送作品视频
166
- comment: 和推送图一同将新作品内容发送出去(图集暂未支持)
167
- path: 'senddynamicwork'
168
- type: 'boolean'
169
-
170
- -
171
- # 配置文件描述
172
- name: bilibili相关
173
- # 配置文件名
174
- file: bilibili.yaml
175
- # 视图信息
176
- view:
177
- -
178
- # 配置项
179
- key: B站解析开关
180
- # 配置描述
181
- comment: 单独开关,受「总开关」影响
182
- # 配置路径
183
- path: 'bilibilitool'
184
- # 配置类型
185
- type: 'boolean'
186
- -
187
- key: B站解析提示
188
- comment: 发送提示信息:“检测到B站链接,开始解析”
189
- path: 'bilibilitip'
190
- type: 'boolean'
191
- -
192
- key: B站评论图
193
- comment: 发送哔哩哔哩作品评论图
194
- path: 'bilibilicommentsimg'
195
- type: 'boolean'
196
- -
197
- key: B站评论数量
198
- comment: 范围1~20条
199
- path: 'bilibilinumcomments'
200
- type: 'number'
201
- -
202
- key: B站推送
203
- comment: 开启后需重启;使用[#设置B站推送+UID]配置推送列表
204
- path: 'bilibilipush'
205
- type: 'boolean'
206
- -
207
- key: B站推送日志
208
- comment: 打开或关闭定时任务日志
209
- path: 'bilibilipushlog'
210
- type: 'boolean'
211
- -
212
- key: B站推送设置权限
213
- comment: '0: (all)所有人;1: (admin)群主和管理员;2: (owner)群主;3: (master)主人'
214
- path: 'bilibilipushGroup'
215
- type: 'select'
216
- # 是否可以多选
217
- multiple: false
218
- # 选项
219
- item:
220
- -
221
- name: 所有人都可以添加
222
- value: all
223
- -
224
- name: 只有群管理员可以添加
225
- value: admin
226
- -
227
- name: 只有群主可以添加
228
- value: owner
229
- -
230
- name: 只有主人可以添加
231
- value: master
232
- -
233
- key: B站推送表达式
234
- path: 'bilibilipushcron'
235
- type: 'boolean'
236
- -
237
- key: B站动态视频发送
238
- comment: 该UP的最新动态可能是视频,可选是否与推送图片一同发送
239
- path: 'senddynamicvideo'
240
- type: 'boolean'
241
- -
242
- key: B站动态视频发送
243
- comment: 解析视频是否优先保内容,打开为优先保证上传将使用最低分辨率,关闭为优先保清晰度将使用最高分辨率
244
- path: 'videopriority'
245
- type: 'boolean'
246
- -
247
- # 配置文件描述
248
- name: 快手相关
249
- # 配置文件名
250
- file: kuaishou.yaml
251
- # 视图信息
252
- view:
253
- -
254
- # 配置项
255
- key: 快手解析开关
256
- # 配置描述
257
- comment: 单独开关,受「总开关」影响
258
- # 配置路径
259
- path: 'kuaishoutool'
260
- # 配置类型
261
- type: 'boolean'
262
- -
263
- key: 快手解析提示
264
- comment: 发送提示信息:“检测到快手链接,开始解析”
265
- path: 'kuaishoutip'
266
- type: 'boolean'
267
- -
268
- key: 快手评论数量
269
- comment: 范围1~30条
270
- path: 'kuaishounumcomments'
271
- type: 'number'
@@ -1,20 +0,0 @@
1
- import { basename, dirname, join } from 'node:path';
2
- import { fileURLToPath } from 'node:url';
3
- import { config, getPkgVersion, getPluginInfo } from 'node-karin';
4
- const __filename = fileURLToPath(import.meta.url);
5
- const __dirname = dirname(__filename);
6
- const pluginPath = join(__dirname, '..', '..', '..').replace(/\\/g, '/');
7
- const pluginName = basename(pluginPath);
8
- const Ver = {
9
- /** 插件名字 */
10
- pluginName,
11
- /** 插件版本号 */
12
- pluginVersion: getPluginInfo('karin-plugin-kkk')?.pkg?.version || await getPkgVersion(pluginName),
13
- /** 插件路径 */
14
- pluginPath: join(__dirname, '..', '..', '..').replace(/\\/g, '/'),
15
- /** Karin版本 */
16
- karinVersion: config.pkg().version,
17
- /** Karin程序/客户端路径 */
18
- karinPath: (process.cwd()).replace(/\\/g, '/')
19
- };
20
- export const Version = Ver;
File without changes