karin-plugin-kkk 0.1.10-pr21.d6cca63 → 1.0.1-commit.069f646

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.0](https://github.com/ikenxuan/karin-plugin-kkk/compare/v0.1.9...v1.0.0) (2025-01-15)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * 适配新版Karin ([#21](https://github.com/ikenxuan/karin-plugin-kkk/issues/21))
9
+
10
+ ### Features
11
+
12
+ * 适配新版Karin ([#21](https://github.com/ikenxuan/karin-plugin-kkk/issues/21)) ([ef46290](https://github.com/ikenxuan/karin-plugin-kkk/commit/ef46290c67452237cb83fc4e552c3f3901f5a0a8))
13
+
3
14
  ## [0.1.9](https://github.com/ikenxuan/karin-plugin-kkk/compare/v0.1.8...v0.1.9) (2025-01-02)
4
15
 
5
16
 
package/README.md CHANGED
@@ -40,7 +40,7 @@
40
40
 
41
41
  在 **Karin 根目录** 下运行
42
42
  ```sh
43
- pnpm add karin-plugin-kkk -w
43
+ pnpm add karin-plugin-kkk@latest -w
44
44
  ```
45
45
  </details>
46
46
 
@@ -52,7 +52,7 @@
52
52
 
53
53
  1. 打开 Release 页面: https://github.com/ikenxuan/karin-plugin-kkk/releases
54
54
  2. 找到最新的版本,下载名为 `build.zip` 的压缩包
55
- 3. 在 `plugins/` 目录下解压该压缩包
55
+ 3. 在 `plugins/` 目录下解压该压缩包,选择替换所有文件。
56
56
 
57
57
  * 完成后相关源码应在 `Karin根目录/plugins/karin-plugin-kkk/` 内<br><br>
58
58
 
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'fs';
3
+ /**
4
+ * @description 获取package.json路径
5
+ */
6
+ const getPkgPath = () => process.cwd() + '/package.json';
7
+ /**
8
+ * @description 读取package.json
9
+ */
10
+ const readPkg = () => JSON.parse(fs.readFileSync(getPkgPath(), 'utf-8'));
11
+ /**
12
+ * @description 写入package.json
13
+ * @param pkg package.json
14
+ */
15
+ const writePkg = (pkg) => fs.writeFileSync(getPkgPath(), JSON.stringify(pkg, null, 2));
16
+ /**
17
+ * @description 构建pr版本号 <主版本号>.<次版本号>.<修订号>.<PR标识PR编号>.<当前提交唯一短哈希>
18
+ * @example 1.0.0.pr.184.a1b2c3d
19
+ * @param pkg package.json
20
+ */
21
+ const updateVersion = (pkg) => {
22
+ const list = pkg.version.split('.');
23
+ console.log('COMMIT_HASH: ' + process.env.COMMIT_HASH);
24
+ const shortHash = process.env.COMMIT_HASH?.substring(0, 7) ?? 'unknown';
25
+ list[2] = `${Number(list[2]) + 1}`;
26
+ pkg.version = `${list.join('.')}-commit.${shortHash}`;
27
+ };
28
+ /**
29
+ * @description 设置环境变量
30
+ * @param pkg package.json
31
+ */
32
+ const setEnvVariables = (pkg) => {
33
+ const githubEnvPath = process.env.GITHUB_ENV;
34
+ if (!githubEnvPath) {
35
+ throw new Error('GITHUB_ENV 环境变量未定义');
36
+ }
37
+ fs.appendFileSync(githubEnvPath, `PKG_NAME=${pkg.name}\nPKG_VERSION=${pkg.version}\n`);
38
+ };
39
+ /**
40
+ * @description 更新版本号并设置环境变量
41
+ */
42
+ const version = () => {
43
+ console.log('开始执行版本更新...');
44
+ const pkg = readPkg();
45
+ console.log(`当前版本: ${pkg.version}`);
46
+ updateVersion(pkg);
47
+ console.log(`更新后版本: ${pkg.version}`);
48
+ writePkg(pkg);
49
+ console.log('package.json 写入成功');
50
+ setEnvVariables(pkg);
51
+ console.log('环境变量设置完成');
52
+ };
53
+ /**
54
+ * @description 删除devDependencies和peerDependencies
55
+ */
56
+ const clean = () => {
57
+ console.log('开始清理依赖...');
58
+ const pkg = readPkg();
59
+ console.log('正在删除 devDependencies');
60
+ delete pkg.devDependencies;
61
+ writePkg(pkg);
62
+ console.log('依赖清理完成');
63
+ };
64
+ /**
65
+ * @description 执行所有操作
66
+ */
67
+ const all = () => {
68
+ console.log('开始执行所有操作...');
69
+ const pkg = readPkg();
70
+ console.log(`当前版本: ${pkg.version}`);
71
+ updateVersion(pkg);
72
+ console.log(`更新后版本: ${pkg.version}`);
73
+ console.log('正在删除 devDependencies');
74
+ delete pkg.devDependencies;
75
+ writePkg(pkg);
76
+ console.log('package.json 写入成功');
77
+ setEnvVariables(pkg);
78
+ console.log('环境变量设置完成');
79
+ console.log('所有操作执行完毕');
80
+ };
81
+ const cmd = process.argv[2];
82
+ console.log(`执行命令: ${cmd}`);
83
+ if (cmd.includes('version')) {
84
+ version();
85
+ }
86
+ else if (cmd.includes('clean')) {
87
+ clean();
88
+ }
89
+ else if (cmd.includes('all')) {
90
+ all();
91
+ }
92
+ else {
93
+ console.log('未知命令,可用命令: version, clean, all');
94
+ }
@@ -49,11 +49,6 @@ interface downLoadFileOptions {
49
49
  * @default {}
50
50
  */
51
51
  headers?: object;
52
- /**
53
- * 下载文件类型,默认为'.mp4'。
54
- * @default '.mp4'
55
- */
56
- filetype?: string;
57
52
  }
58
53
  export declare class Base {
59
54
  e: Message;
@@ -128,8 +128,7 @@ export class Base {
128
128
  // 下载文件,视频URL,标题和自定义headers
129
129
  let res = await this.DownLoadFile(downloadOpt.video_url, {
130
130
  title: Config.app.rmmp4 ? downloadOpt.title.timestampTitle : downloadOpt.title.originTitle,
131
- headers: downloadOpt.headers ?? this.headers,
132
- filetype: '.mp4'
131
+ headers: downloadOpt.headers ?? this.headers
133
132
  });
134
133
  res = { ...res, ...downloadOpt.title };
135
134
  // 将下载的文件大小转换为MB并保留两位小数
@@ -150,7 +149,7 @@ export class Base {
150
149
  const { filepath, totalBytes } = await new Networks({
151
150
  url: videoUrl, // 视频地址
152
151
  headers: opt.headers ?? this.headers, // 请求头
153
- filepath: Common.tempDri.video + `${opt.title}${opt.filetype ?? '.mp4'}`, // 文件保存路径
152
+ filepath: Common.tempDri.video + opt.title, // 文件保存路径
154
153
  timeout: 30000 // 设置 30 秒超时
155
154
  }).downloadStream((downloadedBytes, totalBytes) => {
156
155
  // 定义进度条长度及生成进度条字符串的函数
@@ -181,8 +180,8 @@ export class Base {
181
180
  const downloadedSizeMB = (downloadedBytes / 1048576).toFixed(1);
182
181
  const totalSizeMB = (totalBytes / 1048576).toFixed(1);
183
182
  // 打印下载进度、速度和剩余时间
184
- console.log(`🚀 Downloading 🚀 ${opt.title}${opt.filetype ?? '.mp4'} ${generateProgressBar(progressPercentage)} ${coloredPercentage} ${downloadedSizeMB}/${totalSizeMB} MB | ${formattedSpeed} 剩余: ${formattedRemainingTime}\r`);
185
- });
183
+ console.log(`🚀 Downloading 🚀 ${opt.title} ${generateProgressBar(progressPercentage)} ${coloredPercentage} ${downloadedSizeMB}/${totalSizeMB} MB | ${formattedSpeed} 剩余: ${formattedRemainingTime}\r`);
184
+ }, 3);
186
185
  return { filepath, totalBytes };
187
186
  }
188
187
  /** 删文件 */
@@ -66,9 +66,11 @@ export async function Render(path, params) {
66
66
  * @returns Preview | Stable
67
67
  */
68
68
  const releaseType = () => {
69
- if (Version.pluginVersion.includes('beta')) {
69
+ const versionPattern = /^\d+\.\d+\.\d+$/;
70
+ if (versionPattern.test(Version.pluginVersion)) {
71
+ return 'Stable';
72
+ }
73
+ else {
70
74
  return 'Preview';
71
75
  }
72
- else
73
- return 'Stable';
74
76
  };
@@ -429,14 +429,12 @@ export class Bilibili extends Base {
429
429
  switch (this.STATUS) {
430
430
  case 'isLogin': {
431
431
  const bmp4 = await this.DownLoadFile(this.TYPE === 'one_video' ? OBJECT.DATA.data?.dash?.video[0].base_url : OBJECT.video_url, {
432
- title: `Bil_V_${this.TYPE === 'one_video' ? OBJECT.INFODATA.data.bvid : OBJECT.INFODATA.result.season_id}`,
433
- headers: this.headers,
434
- filetype: '.mp4'
432
+ title: `Bil_V_${this.TYPE === 'one_video' ? OBJECT.INFODATA.data.bvid : OBJECT.INFODATA.result.season_id}.mp4`,
433
+ headers: this.headers
435
434
  });
436
435
  const bmp3 = await this.DownLoadFile(this.TYPE === 'one_video' ? OBJECT.DATA.data?.dash?.audio[0].base_url : OBJECT.audio_url, {
437
- title: `Bil_A_${this.TYPE === 'one_video' ? OBJECT.INFODATA.data.bvid : OBJECT.INFODATA.result.season_id}`,
438
- headers: this.headers,
439
- filetype: '.mp3'
436
+ title: `Bil_A_${this.TYPE === 'one_video' ? OBJECT.INFODATA.data.bvid : OBJECT.INFODATA.result.season_id}.mp3`,
437
+ headers: this.headers
440
438
  });
441
439
  if (bmp4.filepath && bmp3.filepath) {
442
440
  await mergeFile('二合一(视频 + 音频)', {
@@ -473,7 +471,7 @@ export class Bilibili extends Base {
473
471
  }
474
472
  case '!isLogin': {
475
473
  /** 没登录(没配置ck)情况下直接发直链,传直链在DownLoadVideo()处理 */
476
- await this.DownLoadVideo({ video_url: OBJECT.DATA.data.durl[0].url, title: { timestampTitle: 'tmp_' + Date.now(), originTitle: this.downloadfilename } });
474
+ await this.DownLoadVideo({ video_url: OBJECT.DATA.data.durl[0].url, title: { timestampTitle: `tmp_${Date.now()}.mp4`, originTitle: `${this.downloadfilename}.mp4` } });
477
475
  break;
478
476
  }
479
477
  default:
@@ -17,6 +17,14 @@ export async function getBilibiliID(url) {
17
17
  };
18
18
  break;
19
19
  }
20
+ case /festival\/([A-Za-z0-9]+)/.test(longLink): {
21
+ const festivalMatch = /festival\/([A-Za-z0-9]+)\?bvid=([A-Za-z0-9]+)/.exec(longLink);
22
+ result = {
23
+ type: 'one_video',
24
+ id: festivalMatch ? festivalMatch[2] : undefined
25
+ };
26
+ break;
27
+ }
20
28
  case /play\/(\S+?)\??/.test(longLink): {
21
29
  const playMatch = /play\/(\w+)/.exec(longLink);
22
30
  const id = playMatch ? playMatch[1] : '';
@@ -294,7 +294,7 @@ export class Bilibilipush extends Base {
294
294
  if (send_video) {
295
295
  await this.DownLoadVideo({
296
296
  video_url: nocd_data.data.durl[0].url,
297
- title: { timestampTitle: 'tmp_' + Date.now(), originTitle: dycrad.title }
297
+ title: { timestampTitle: `tmp_${Date.now()}.mp4`, originTitle: `${dycrad.title}.mp4` }
298
298
  }, { active: true, activeOption: { uin, group_id } });
299
299
  }
300
300
  break;
@@ -102,7 +102,7 @@ export class DouYin extends Base {
102
102
  const cover = video.origin_cover.url_list[0]; // video cover image
103
103
  const title = data.VideoData.aweme_detail.preview_title.substring(0, 80).replace(/[\\/:\*\?"<>\|\r\n]/g, ' '); // video title
104
104
  g_title = title;
105
- mp4size = (video.play_addr.data_size / (1024 * 1024)).toFixed(2);
105
+ mp4size = (video.bit_rate[0].play_addr.data_size / (1024 * 1024)).toFixed(2);
106
106
  videores.push(segment.text(`标题:\n${title}`));
107
107
  videores.push(segment.text(`视频帧率:${'' + FPS}\n视频大小:${mp4size}MB`));
108
108
  videores.push(segment.text(`永久直链(302跳转)\nhttps://aweme.snssdk.com/aweme/v1/play/?video_id=${data.VideoData.aweme_detail.video.play_addr.uri}&ratio=1080p&line=0`));
@@ -132,7 +132,7 @@ export class DouYin extends Base {
132
132
  await this.e.reply(img);
133
133
  }
134
134
  /** 发送视频 */
135
- sendvideofile && this.is_mp4 && await this.DownLoadVideo({ video_url: g_video_url, title: { timestampTitle: 'tmp_' + Date.now(), originTitle: g_title } });
135
+ sendvideofile && this.is_mp4 && await this.DownLoadVideo({ video_url: g_video_url, title: { timestampTitle: `tmp_${Date.now()}.mp4`, originTitle: `${g_title}.mp4` } });
136
136
  return true;
137
137
  }
138
138
  case 'user_mix_videos': {
@@ -147,15 +147,13 @@ export class DouYin extends Base {
147
147
  images.push(segment.text(`动图直链:\nhttps://aweme.snssdk.com/aweme/v1/play/?video_id=${item.video.play_addr_h264.uri}&ratio=1080p&line=0`));
148
148
  // 动图
149
149
  const liveimg = await this.DownLoadFile(`https://aweme.snssdk.com/aweme/v1/play/?video_id=${item.video.play_addr_h264.uri}&ratio=1080p&line=0`, {
150
- title: 'Douyin_tmp_' + Date.now(),
151
- headers: this.headers,
152
- filetype: '.mp4'
150
+ title: `Douyin_tmp_V_${Date.now()}.mp4`,
151
+ headers: this.headers
153
152
  });
154
153
  // BGM
155
154
  const liveimgbgm = await this.DownLoadFile(bgmurl, {
156
- title: 'Douyin_tmp_' + Date.now(),
157
- headers: this.headers,
158
- filetype: '.mp3'
155
+ title: `Douyin_tmp_A_${Date.now()}.mp3`,
156
+ headers: this.headers
159
157
  });
160
158
  if (liveimg.filepath && liveimgbgm.filepath) {
161
159
  const resolvefilepath = Common.tempDri.video + `Douyin_Result_${Date.now()}.mp4`;
@@ -120,7 +120,7 @@ export class DouYinpush extends Base {
120
120
  // 下载视频
121
121
  await this.DownLoadVideo({
122
122
  video_url: downloadUrl,
123
- title: { timestampTitle: 'tmp_' + Date.now(), originTitle: Detail_Data.desc }
123
+ title: { timestampTitle: `tmp_${Date.now()}.mp4`, originTitle: `${Detail_Data.desc}.mp4` }
124
124
  }, { active: true, activeOption: { uin, group_id } });
125
125
  }
126
126
  catch (error) {
@@ -33,7 +33,7 @@ export class Kuaishou extends Base {
33
33
  likeCount: data.VideoData.data.visionVideoDetail.photo.likeCount
34
34
  });
35
35
  await this.e.reply(img);
36
- await this.DownLoadVideo({ video_url, title: Config.app.rmmp4 ? 'tmp_' + Date.now() : data.VideoData.data.visionVideoDetail.photo.caption });
36
+ await this.DownLoadVideo({ video_url, title: { timestampTitle: `tmp_${Date.now()}.mp4`, originTitle: `${data.VideoData.data.visionVideoDetail.photo.caption}.mp4` } });
37
37
  return true;
38
38
  }
39
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karin-plugin-kkk",
3
- "version": "0.1.10-pr21.d6cca63",
3
+ "version": "1.0.1-commit.069f646",
4
4
  "description": "a Karin video parsing tool",
5
5
  "keywords": [
6
6
  "karin-plugin",
@@ -32,6 +32,7 @@
32
32
  "clean": "npm lib/cli/pr.js clean",
33
33
  "fix": "eslint src/**/*.ts --fix",
34
34
  "pr": "node lib/cli/pr.js",
35
+ "commit": "node lib/cli/commit.js",
35
36
  "pub": "npm publish --access public",
36
37
  "pub-beta": "npm publish --tag beta",
37
38
  "sort": "npx sort-package-json",