增加视频下载延迟

This commit is contained in:
zyc404 2024-05-08 00:23:42 +08:00
parent 8bd58cf429
commit f66b4a8548

View file

@ -16,7 +16,7 @@ export default class BingSunoClient {
messages.push(`歌名:${song.title}\n风格: ${song.musicalStyle}\n歌词:\n${song.prompt}\n`) messages.push(`歌名:${song.title}\n风格: ${song.musicalStyle}\n歌词:\n${song.prompt}\n`)
messages.push(`音频链接:${song.audioURL}\n视频链接:${song.videoURL}\n封面链接:${song.imageURL}\n`) messages.push(`音频链接:${song.audioURL}\n视频链接:${song.videoURL}\n封面链接:${song.imageURL}\n`)
messages.push(segment.image(song.imageURL)) messages.push(segment.image(song.imageURL))
let retry = 3 let retry = 10
let videoPath let videoPath
while (!videoPath && retry >= 0) { while (!videoPath && retry >= 0) {
try { try {
@ -25,12 +25,12 @@ export default class BingSunoClient {
}) })
} catch (err) { } catch (err) {
retry-- retry--
await common.sleep(1000) await common.sleep(3000)
} }
} }
if (videoPath) { if (videoPath) {
const data = fs.readFileSync(videoPath) const data = fs.readFileSync(videoPath)
messages.push(segment.video(`base64://${data.toString('base64')}`)) await e.reply(segment.video(`base64://${data.toString('base64')}`))
// 60秒后删除文件避免占用体积 // 60秒后删除文件避免占用体积
setTimeout(() => { setTimeout(() => {
fs.unlinkSync(videoPath) fs.unlinkSync(videoPath)