feat: 添加上传云盘功能

This commit is contained in:
秋刀鱼 2024-11-12 13:22:05 +08:00
parent d44bcd6502
commit 5dba8caa2f

View File

@ -283,13 +283,7 @@ export class songRequest extends plugin {
const title = msg.message[0].data.match(/"title":"([^"]+)"/)[1] const title = msg.message[0].data.match(/"title":"([^"]+)"/)[1]
const desc = msg.message[0].data.match(/"desc":"([^"]+)"/)[1] const desc = msg.message[0].data.match(/"desc":"([^"]+)"/)[1]
if (id === "") return if (id === "") return
let paths = [ let path = this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.flac'
this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.flac',
this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.mp3',
this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.mp4'
];
for (let path of paths) {
try { try {
// 上传群文件 // 上传群文件
await this.uploadGroupFile(e, path); await this.uploadGroupFile(e, path);
@ -299,7 +293,6 @@ export class songRequest extends plugin {
logger.error(error); logger.error(error);
} }
} }
}
// 上传云盘 // 上传云盘
async uploadCloud(e) { async uploadCloud(e) {
@ -316,18 +309,12 @@ export class songRequest extends plugin {
const title = msg.message[0].data.match(/"title":"([^"]+)"/)[1] const title = msg.message[0].data.match(/"title":"([^"]+)"/)[1]
const desc = msg.message[0].data.match(/"desc":"([^"]+)"/)[1] const desc = msg.message[0].data.match(/"desc":"([^"]+)"/)[1]
if (id === "") return if (id === "") return
let paths = [ let path = this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.flac'
this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.flac',
this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.mp3',
this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.mp4'
];
for (let path of paths) {
try { try {
await formData.append('songFile', fs.createReadStream(path)) await formData.append('songFile', fs.createReadStream(path))
} catch (error) { } catch (error) {
logger.error(error); logger.error(error);
} }
}
let formData = new FormData() let formData = new FormData()
const headers = { const headers = {
...formData.getHeaders(), ...formData.getHeaders(),
@ -353,8 +340,8 @@ export class songRequest extends plugin {
}).then(res => { }).then(res => {
logger.info('歌曲信息匹配成功') logger.info('歌曲信息匹配成功')
}) })
.catch(error =>{ .catch(error => {
logger.error('歌曲信息匹配错误',error) logger.error('歌曲信息匹配错误', error)
}) })
this.songCloudUpdate(e) this.songCloudUpdate(e)
} }