karin-plugin-kkk 1.0.7 → 1.0.8-pr32.b8da68c
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/cli/pr.js
CHANGED
|
@@ -22,7 +22,7 @@ const updateVersion = (pkg) => {
|
|
|
22
22
|
const list = pkg.version.split('.');
|
|
23
23
|
const shortHash = process.env.GITHUB_SHA?.substring(0, 7) ?? 'unknown';
|
|
24
24
|
list[2] = `${Number(list[2]) + 1}`;
|
|
25
|
-
pkg.version = `${list.join('.')}
|
|
25
|
+
pkg.version = `${list.join('.')}-pr${process.env.PR_NUMBER}.${shortHash}`;
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
28
|
* @description 设置环境变量
|
|
@@ -26,7 +26,8 @@ export type dyVideo = {
|
|
|
26
26
|
export declare class DouYin extends Base {
|
|
27
27
|
e: Message;
|
|
28
28
|
type: DouyinDataTypes[keyof DouyinDataTypes];
|
|
29
|
-
is_mp4:
|
|
29
|
+
is_mp4: boolean | undefined;
|
|
30
|
+
is_slides: boolean;
|
|
30
31
|
get botadapter(): string;
|
|
31
32
|
constructor(e: Message, iddata: ExtendedDouyinOptionsType);
|
|
32
33
|
RESOURCES(data: any): Promise<true | undefined>;
|
|
@@ -11,6 +11,7 @@ export class DouYin extends Base {
|
|
|
11
11
|
e;
|
|
12
12
|
type;
|
|
13
13
|
is_mp4;
|
|
14
|
+
is_slides;
|
|
14
15
|
get botadapter() {
|
|
15
16
|
return this.e.bot?.adapter?.name;
|
|
16
17
|
}
|
|
@@ -19,47 +20,118 @@ export class DouYin extends Base {
|
|
|
19
20
|
this.e = e;
|
|
20
21
|
this.type = iddata?.type;
|
|
21
22
|
this.is_mp4 = iddata?.is_mp4;
|
|
23
|
+
this.is_slides = false;
|
|
22
24
|
}
|
|
23
25
|
async RESOURCES(data) {
|
|
24
26
|
switch (this.type) {
|
|
25
27
|
case 'one_work': {
|
|
26
28
|
if (Config.douyin.tip)
|
|
27
29
|
this.e.reply('检测到抖音链接,开始解析');
|
|
30
|
+
this.is_slides = data.VideoData.aweme_detail.is_slides === true;
|
|
28
31
|
let g_video_url = '';
|
|
29
32
|
let g_title;
|
|
30
|
-
const full_data = [];
|
|
31
33
|
/** 图集 */
|
|
32
34
|
let imagenum = 0;
|
|
33
35
|
const image_res = [];
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
image_url
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
switch (true) {
|
|
37
|
+
// 图集
|
|
38
|
+
case this.is_slides === false: {
|
|
39
|
+
const image_data = [];
|
|
40
|
+
const imageres = [];
|
|
41
|
+
let image_url;
|
|
42
|
+
for (let i = 0; i < data.VideoData.aweme_detail.images.length; i++) {
|
|
43
|
+
image_url = data.VideoData.aweme_detail.images[i].url_list[2] || data.VideoData.aweme_detail.images[i].url_list[1]; // 图片地址
|
|
44
|
+
const title = data.VideoData.aweme_detail.preview_title.substring(0, 50).replace(/[\\/:\*\?"<>\|\r\n]/g, ' '); // 标题,去除特殊字符
|
|
45
|
+
g_title = title;
|
|
46
|
+
imageres.push(segment.image(image_url));
|
|
47
|
+
imagenum++;
|
|
48
|
+
if (Config.app.rmmp4 === false) {
|
|
49
|
+
mkdirSync(`${Common.tempDri.images}${g_title}`);
|
|
50
|
+
const path = `${Common.tempDri.images}${g_title}/${i + 1}.png`;
|
|
51
|
+
await new Networks({ url: image_url, type: 'arraybuffer' }).getData().then((data) => fs.promises.writeFile(path, Buffer.from(data)));
|
|
52
|
+
}
|
|
48
53
|
}
|
|
54
|
+
const res = common.makeForward(imageres, this.e.sender.userId, this.e.sender.nick);
|
|
55
|
+
image_data.push(res);
|
|
56
|
+
image_res.push(image_data);
|
|
57
|
+
if (imageres.length === 1) {
|
|
58
|
+
await this.e.reply(segment.image(image_url));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
await this.e.bot.sendForwardMsg(this.e.contact, res, {
|
|
62
|
+
source: '图片合集',
|
|
63
|
+
summary: `查看${res.length}张图片消息`,
|
|
64
|
+
prompt: '抖音图集解析结果',
|
|
65
|
+
news: [{ text: '点击查看解析结果' }]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
49
69
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
// 合辑
|
|
71
|
+
case data.VideoData.aweme_detail.is_slides === true: {
|
|
72
|
+
const images = [];
|
|
73
|
+
const temp = [];
|
|
74
|
+
/** BGM */
|
|
75
|
+
const liveimgbgm = await this.DownLoadFile(data.VideoData.aweme_detail.music.play_url.uri, {
|
|
76
|
+
title: `Douyin_tmp_A_${Date.now()}.mp3`,
|
|
77
|
+
headers: this.headers
|
|
78
|
+
});
|
|
79
|
+
temp.push(liveimgbgm);
|
|
80
|
+
for (const item of data.VideoData.aweme_detail.images) {
|
|
81
|
+
imagenum++;
|
|
82
|
+
// 静态图片,clip_type为2
|
|
83
|
+
if (item.clip_type === 2) {
|
|
84
|
+
images.push(segment.image((item.url_list[0])));
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
/** 动图 */
|
|
88
|
+
const liveimg = await this.DownLoadFile(`https://aweme.snssdk.com/aweme/v1/play/?video_id=${item.video.play_addr_h264.uri}&ratio=1080p&line=0`, {
|
|
89
|
+
title: `Douyin_tmp_V_${Date.now()}.mp4`,
|
|
90
|
+
headers: this.headers
|
|
91
|
+
});
|
|
92
|
+
if (liveimg.filepath) {
|
|
93
|
+
const resolvefilepath = Common.tempDri.video + `Douyin_Result_${Date.now()}.mp4`;
|
|
94
|
+
await mergeFile('视频*3 + 音频', {
|
|
95
|
+
path: liveimg.filepath,
|
|
96
|
+
path2: liveimgbgm.filepath,
|
|
97
|
+
resultPath: resolvefilepath,
|
|
98
|
+
callback: async (success, resultPath) => {
|
|
99
|
+
if (success) {
|
|
100
|
+
const filePath = Common.tempDri.video + `tmp_${Date.now()}.mp4`;
|
|
101
|
+
fs.renameSync(resultPath, filePath);
|
|
102
|
+
await this.removeFile(liveimg.filepath, true);
|
|
103
|
+
temp.push({ filepath: filePath, totalBytes: 0 });
|
|
104
|
+
images.push(segment.video('file://' + filePath));
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
await this.removeFile(liveimg.filepath, true);
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const Element = common.makeForward(images, this.e.sender.userId, this.e.sender.nick);
|
|
116
|
+
try {
|
|
117
|
+
await this.e.bot.sendForwardMsg(this.e.contact, Element, {
|
|
118
|
+
source: '合辑内容',
|
|
119
|
+
summary: `查看${Element.length}张图片/视频消息`,
|
|
120
|
+
prompt: '抖音合辑解析结果',
|
|
121
|
+
news: [{ text: '点击查看解析结果' }]
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
await this.e.reply(JSON.stringify(error, null, 2));
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
for (const item of temp) {
|
|
129
|
+
await this.removeFile(item.filepath, true);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
58
133
|
}
|
|
59
134
|
}
|
|
60
|
-
else {
|
|
61
|
-
image_res.push('图集信息解析失败');
|
|
62
|
-
}
|
|
63
135
|
/** 背景音乐 */
|
|
64
136
|
if (data.VideoData.aweme_detail.music) {
|
|
65
137
|
const music = data.VideoData.aweme_detail.music;
|
|
@@ -118,7 +190,7 @@ export class DouYin extends Base {
|
|
|
118
190
|
const list = await Emoji(EmojiData);
|
|
119
191
|
const commentsArray = await douyinComments(data.CommentsData, list);
|
|
120
192
|
const img = await Render('douyin/comment', {
|
|
121
|
-
Type: this.is_mp4 ? '视频' : '图集',
|
|
193
|
+
Type: this.is_mp4 ? '视频' : this.is_slides ? '合辑' : '图集',
|
|
122
194
|
CommentsData: commentsArray,
|
|
123
195
|
CommentLength: String(commentsArray.jsonArray?.length ? commentsArray.jsonArray.length : 0),
|
|
124
196
|
share_url: this.is_mp4
|
|
@@ -135,75 +207,6 @@ export class DouYin extends Base {
|
|
|
135
207
|
sendvideofile && this.is_mp4 && await this.DownLoadVideo({ video_url: g_video_url, title: { timestampTitle: `tmp_${Date.now()}.mp4`, originTitle: `${g_title}.mp4` } });
|
|
136
208
|
return true;
|
|
137
209
|
}
|
|
138
|
-
case 'user_mix_videos': {
|
|
139
|
-
const emojiData = await getDouyinData('Emoji数据');
|
|
140
|
-
const commentsData = await douyinComments(data.CommentsData, Emoji(emojiData));
|
|
141
|
-
const commentImage = await Render('douyin/comment', {
|
|
142
|
-
Type: '合辑作品',
|
|
143
|
-
CommentsData: commentsData,
|
|
144
|
-
CommentLength: String(commentsData.jsonArray?.length ? commentsData.jsonArray.length : 0),
|
|
145
|
-
share_url: data.LiveImageData.aweme_details[0].share_url,
|
|
146
|
-
VideoSize: '???',
|
|
147
|
-
VideoFPS: '???',
|
|
148
|
-
ImageLength: '???'
|
|
149
|
-
});
|
|
150
|
-
await this.e.reply(commentImage);
|
|
151
|
-
const images = [];
|
|
152
|
-
const temp = [];
|
|
153
|
-
/** BGM */
|
|
154
|
-
const liveimgbgm = await this.DownLoadFile(data.LiveImageData.aweme_details[0].music.play_url.uri, {
|
|
155
|
-
title: `Douyin_tmp_A_${Date.now()}.mp3`,
|
|
156
|
-
headers: this.headers
|
|
157
|
-
});
|
|
158
|
-
temp.push(liveimgbgm);
|
|
159
|
-
for (const item of data.LiveImageData.aweme_details[0].images) {
|
|
160
|
-
// 静态图片,clip_type为2
|
|
161
|
-
if (item.clip_type === 2) {
|
|
162
|
-
images.push(segment.image((item.url_list[0])));
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
/** 动图 */
|
|
166
|
-
const liveimg = await this.DownLoadFile(`https://aweme.snssdk.com/aweme/v1/play/?video_id=${item.video.play_addr_h264.uri}&ratio=1080p&line=0`, {
|
|
167
|
-
title: `Douyin_tmp_V_${Date.now()}.mp4`,
|
|
168
|
-
headers: this.headers
|
|
169
|
-
});
|
|
170
|
-
if (liveimg.filepath) {
|
|
171
|
-
const resolvefilepath = Common.tempDri.video + `Douyin_Result_${Date.now()}.mp4`;
|
|
172
|
-
await mergeFile('视频*3 + 音频', {
|
|
173
|
-
path: liveimg.filepath,
|
|
174
|
-
path2: liveimgbgm.filepath,
|
|
175
|
-
resultPath: resolvefilepath,
|
|
176
|
-
callback: async (success, resultPath) => {
|
|
177
|
-
if (success) {
|
|
178
|
-
const filePath = Common.tempDri.video + `tmp_${Date.now()}.mp4`;
|
|
179
|
-
fs.renameSync(resultPath, filePath);
|
|
180
|
-
await this.removeFile(liveimg.filepath, true);
|
|
181
|
-
temp.push({ filepath: filePath, totalBytes: 0 });
|
|
182
|
-
images.push(segment.video('file://' + filePath));
|
|
183
|
-
return true;
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
await this.removeFile(liveimg.filepath, true);
|
|
187
|
-
return true;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
const Element = common.makeForward(images, this.e.sender.userId, this.e.sender.nick);
|
|
194
|
-
try {
|
|
195
|
-
await this.e.bot.sendForwardMsg(this.e.contact, Element);
|
|
196
|
-
}
|
|
197
|
-
catch (error) {
|
|
198
|
-
await this.e.reply(JSON.stringify(error, null, 2));
|
|
199
|
-
}
|
|
200
|
-
finally {
|
|
201
|
-
for (const item of temp) {
|
|
202
|
-
await this.removeFile(item.filepath, true);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return true;
|
|
206
|
-
}
|
|
207
210
|
case 'user_dynamic': {
|
|
208
211
|
const veoarray = [];
|
|
209
212
|
veoarray.unshift('------------------------------ | ---------------------------- |\n');
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
{{if Type == '视频'}}
|
|
13
13
|
<div class="top-info">视频大小:{{VideoSize}}MB</div>
|
|
14
14
|
<div class="top-info">视频帧率:{{VideoFPS}}Hz</div>
|
|
15
|
-
{{else if Type == '图集'}}
|
|
15
|
+
{{else if Type == '图集' || Type == '合辑'}}
|
|
16
16
|
<div class="top-info">图片数量:{{ImageLength}}张</div>
|
|
17
17
|
{{/if}}
|
|
18
18
|
</div>
|