karin-plugin-kkk 1.0.7 → 1.0.8-pr32.022e593
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,46 +20,119 @@ 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
36
|
if (this.is_mp4 === false) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
switch (true) {
|
|
38
|
+
// 图集
|
|
39
|
+
case this.is_slides === false: {
|
|
40
|
+
const image_data = [];
|
|
41
|
+
const imageres = [];
|
|
42
|
+
let image_url;
|
|
43
|
+
for (let i = 0; i < data.VideoData.aweme_detail.images.length; i++) {
|
|
44
|
+
image_url = data.VideoData.aweme_detail.images[i].url_list[2] || data.VideoData.aweme_detail.images[i].url_list[1]; // 图片地址
|
|
45
|
+
const title = data.VideoData.aweme_detail.preview_title.substring(0, 50).replace(/[\\/:\*\?"<>\|\r\n]/g, ' '); // 标题,去除特殊字符
|
|
46
|
+
g_title = title;
|
|
47
|
+
imageres.push(segment.image(image_url));
|
|
48
|
+
imagenum++;
|
|
49
|
+
if (Config.app.rmmp4 === false) {
|
|
50
|
+
mkdirSync(`${Common.tempDri.images}${g_title}`);
|
|
51
|
+
const path = `${Common.tempDri.images}${g_title}/${i + 1}.png`;
|
|
52
|
+
await new Networks({ url: image_url, type: 'arraybuffer' }).getData().then((data) => fs.promises.writeFile(path, Buffer.from(data)));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const res = common.makeForward(imageres, this.e.sender.userId, this.e.sender.nick);
|
|
56
|
+
image_data.push(res);
|
|
57
|
+
image_res.push(image_data);
|
|
58
|
+
if (imageres.length === 1) {
|
|
59
|
+
await this.e.reply(segment.image(image_url));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
await this.e.bot.sendForwardMsg(this.e.contact, res, {
|
|
63
|
+
source: '图片合集',
|
|
64
|
+
summary: `查看${res.length}张图片消息`,
|
|
65
|
+
prompt: '抖音图集解析结果',
|
|
66
|
+
news: [{ text: '点击查看解析结果' }]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
// 合辑
|
|
72
|
+
case data.VideoData.aweme_detail.is_slides === true: {
|
|
73
|
+
const images = [];
|
|
74
|
+
const temp = [];
|
|
75
|
+
/** BGM */
|
|
76
|
+
const liveimgbgm = await this.DownLoadFile(data.VideoData.aweme_detail.music.play_url.uri, {
|
|
77
|
+
title: `Douyin_tmp_A_${Date.now()}.mp3`,
|
|
78
|
+
headers: this.headers
|
|
79
|
+
});
|
|
80
|
+
temp.push(liveimgbgm);
|
|
81
|
+
for (const item of data.VideoData.aweme_detail.images) {
|
|
82
|
+
imagenum++;
|
|
83
|
+
// 静态图片,clip_type为2
|
|
84
|
+
if (item.clip_type === 2) {
|
|
85
|
+
images.push(segment.image((item.url_list[0])));
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
/** 动图 */
|
|
89
|
+
const liveimg = await this.DownLoadFile(`https://aweme.snssdk.com/aweme/v1/play/?video_id=${item.video.play_addr_h264.uri}&ratio=1080p&line=0`, {
|
|
90
|
+
title: `Douyin_tmp_V_${Date.now()}.mp4`,
|
|
91
|
+
headers: this.headers
|
|
92
|
+
});
|
|
93
|
+
if (liveimg.filepath) {
|
|
94
|
+
const resolvefilepath = Common.tempDri.video + `Douyin_Result_${Date.now()}.mp4`;
|
|
95
|
+
await mergeFile('视频*3 + 音频', {
|
|
96
|
+
path: liveimg.filepath,
|
|
97
|
+
path2: liveimgbgm.filepath,
|
|
98
|
+
resultPath: resolvefilepath,
|
|
99
|
+
callback: async (success, resultPath) => {
|
|
100
|
+
if (success) {
|
|
101
|
+
const filePath = Common.tempDri.video + `tmp_${Date.now()}.mp4`;
|
|
102
|
+
fs.renameSync(resultPath, filePath);
|
|
103
|
+
await this.removeFile(liveimg.filepath, true);
|
|
104
|
+
temp.push({ filepath: filePath, totalBytes: 0 });
|
|
105
|
+
images.push(segment.video('file://' + filePath));
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
await this.removeFile(liveimg.filepath, true);
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const Element = common.makeForward(images, this.e.sender.userId, this.e.sender.nick);
|
|
117
|
+
try {
|
|
118
|
+
await this.e.bot.sendForwardMsg(this.e.contact, Element, {
|
|
119
|
+
source: '合辑内容',
|
|
120
|
+
summary: `查看${Element.length}张图片/视频消息`,
|
|
121
|
+
prompt: '抖音合辑解析结果',
|
|
122
|
+
news: [{ text: '点击查看解析结果' }]
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
await this.e.reply(JSON.stringify(error, null, 2));
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
for (const item of temp) {
|
|
130
|
+
await this.removeFile(item.filepath, true);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
48
134
|
}
|
|
49
135
|
}
|
|
50
|
-
const res = common.makeForward(imageres, this.e.sender.userId, this.e.sender.nick);
|
|
51
|
-
image_data.push(res);
|
|
52
|
-
image_res.push(image_data);
|
|
53
|
-
if (imageres.length === 1) {
|
|
54
|
-
await this.e.reply(segment.image(image_url));
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
await this.e.bot.sendForwardMsg(this.e.contact, res);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
image_res.push('图集信息解析失败');
|
|
62
136
|
}
|
|
63
137
|
/** 背景音乐 */
|
|
64
138
|
if (data.VideoData.aweme_detail.music) {
|
|
@@ -118,7 +192,7 @@ export class DouYin extends Base {
|
|
|
118
192
|
const list = await Emoji(EmojiData);
|
|
119
193
|
const commentsArray = await douyinComments(data.CommentsData, list);
|
|
120
194
|
const img = await Render('douyin/comment', {
|
|
121
|
-
Type: this.is_mp4 ? '视频' : '图集',
|
|
195
|
+
Type: this.is_mp4 ? '视频' : this.is_slides ? '合辑' : '图集',
|
|
122
196
|
CommentsData: commentsArray,
|
|
123
197
|
CommentLength: String(commentsArray.jsonArray?.length ? commentsArray.jsonArray.length : 0),
|
|
124
198
|
share_url: this.is_mp4
|
|
@@ -135,75 +209,6 @@ export class DouYin extends Base {
|
|
|
135
209
|
sendvideofile && this.is_mp4 && await this.DownLoadVideo({ video_url: g_video_url, title: { timestampTitle: `tmp_${Date.now()}.mp4`, originTitle: `${g_title}.mp4` } });
|
|
136
210
|
return true;
|
|
137
211
|
}
|
|
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
212
|
case 'user_dynamic': {
|
|
208
213
|
const veoarray = [];
|
|
209
214
|
veoarray.unshift('------------------------------ | ---------------------------- |\n');
|
|
@@ -241,6 +246,10 @@ export class DouYin extends Base {
|
|
|
241
246
|
}
|
|
242
247
|
const search_data = new_userdata;
|
|
243
248
|
}
|
|
249
|
+
if (!data.music_info.play_url) {
|
|
250
|
+
await this.e.reply('解析错误!该音乐抖音未提供下载链接,无法下载', { reply: true });
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
244
253
|
img = await Render('douyin/musicinfo', {
|
|
245
254
|
image_url: data.music_info.cover_hd.url_list[0],
|
|
246
255
|
desc: data.music_info.title,
|
|
@@ -15,16 +15,6 @@ export async function getDouyinID(url, log = true) {
|
|
|
15
15
|
}).getLongLink();
|
|
16
16
|
let result = {};
|
|
17
17
|
switch (true) {
|
|
18
|
-
case /https:\/\/(?:www\.iesdouyin\.com)\/share\/slides/.test(longLink):
|
|
19
|
-
case longLink === 'https://www.douyin.com/': {
|
|
20
|
-
const match = longLink.match(/share\/slides\/(\d+)/);
|
|
21
|
-
result = {
|
|
22
|
-
type: 'user_mix_videos',
|
|
23
|
-
aweme_id: match ? match[1] : undefined,
|
|
24
|
-
is_mp4: false
|
|
25
|
-
};
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
18
|
case longLink.includes('webcast.amemv.com'):
|
|
29
19
|
case longLink.includes('live.douyin.com'): {
|
|
30
20
|
if (longLink.includes('webcast.amemv.com')) {
|
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>
|