mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🐞 fix: 热修复tiktok问题
This commit is contained in:
parent
8e03019b44
commit
9c7d7869f8
@ -29,7 +29,7 @@ export class tools extends plugin {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
this.path = "./data/rcmp4/";
|
this.defaultPath = `./data/rcmp4/`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 翻译插件
|
// 翻译插件
|
||||||
@ -64,8 +64,10 @@ export class tools extends plugin {
|
|||||||
.then((resp) => resp.json())
|
.then((resp) => resp.json())
|
||||||
.then((json) => json.item_list[0])
|
.then((json) => json.item_list[0])
|
||||||
.then((item) => item.video.play_addr.url_list[0])
|
.then((item) => item.video.play_addr.url_list[0])
|
||||||
.then(async (url) => {
|
.then((url) => {
|
||||||
await e.reply(await segment.video(await this.downloadVideo(url)));
|
this.downloadVideo(url).then(video => {
|
||||||
|
e.reply(segment.video(`${this.defaultPath}${this.e.group_id || this.e.user_id}/temp.mp4`));
|
||||||
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
@ -80,8 +82,10 @@ export class tools extends plugin {
|
|||||||
e.reply("识别:tiktok, 解析中...");
|
e.reply("识别:tiktok, 解析中...");
|
||||||
fetch(tiktokApi)
|
fetch(tiktokApi)
|
||||||
.then(resp => resp.json())
|
.then(resp => resp.json())
|
||||||
.then(async json => {
|
.then(json => {
|
||||||
await e.reply(await segment.video(await this.downloadVideo(json.wm_video_url.replace("https","http"))))
|
this.downloadVideo(json.wm_video_url.replace("https","http")).then(video => {
|
||||||
|
e.reply(segment.video(`${this.defaultPath}${this.e.group_id || this.e.user_id}/temp.mp4`))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -110,11 +114,10 @@ export class tools extends plugin {
|
|||||||
|
|
||||||
// 根URL据下载视频 / 音频
|
// 根URL据下载视频 / 音频
|
||||||
async downloadVideo(url) {
|
async downloadVideo(url) {
|
||||||
let target = `${this.path}${this.e.group_id || this.e.user_id}`;
|
if (!fs.existsSync(this.defaultPath)) {
|
||||||
if (!fs.existsSync(target)) {
|
this.mkdirsSync(this.defaultPath);
|
||||||
this.mkdirsSync(`${this.path}${this.e.group_id || this.e.user_id}`);
|
|
||||||
}
|
}
|
||||||
target += '/temp.mp4'
|
const target = this.defaultPath + `${this.e.group_id || this.e.user_id}/temp.mp4`
|
||||||
// 待优化
|
// 待优化
|
||||||
if (fs.existsSync(target)) {
|
if (fs.existsSync(target)) {
|
||||||
console.log(`视频已存在`);
|
console.log(`视频已存在`);
|
||||||
@ -130,11 +133,11 @@ export class tools extends plugin {
|
|||||||
console.log(`开始下载: ${url}`);
|
console.log(`开始下载: ${url}`);
|
||||||
const writer = fs.createWriteStream(target);
|
const writer = fs.createWriteStream(target);
|
||||||
res.data.pipe(writer);
|
res.data.pipe(writer);
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
writer.on("finish", resolve);
|
writer.on("finish", resolve);
|
||||||
writer.on("error", reject);
|
writer.on("error", reject);
|
||||||
});
|
});
|
||||||
return target;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 同步递归创建文件夹
|
// 同步递归创建文件夹
|
||||||
|
Loading…
x
Reference in New Issue
Block a user