🐞 fix: 修复在文件拓展名为mp3无法上传的问题

This commit is contained in:
秋刀鱼 2024-11-12 15:48:58 +08:00
parent cd661501de
commit 012191eab5
2 changed files with 7 additions and 2 deletions

View File

@ -13,6 +13,8 @@ import { sendMusicCard } from "../utils/yunzai-util.js";
import config from "../model/config.js";
import FormData from 'form-data';
let FileSuffix = 'flac'
export class songRequest extends plugin {
constructor() {
super({
@ -282,7 +284,7 @@ export class songRequest extends plugin {
const title = msg.message[0].data.match(/"title":"([^"]+)"/)[1]
const desc = msg.message[0].data.match(/"desc":"([^"]+)"/)[1]
if (id === "") return
let path = this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.flac'
let path = this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.' + FileSuffix
try {
// 上传群文件
await this.uploadGroupFile(e, path);
@ -308,7 +310,7 @@ export class songRequest extends plugin {
const title = msg.message[0].data.match(/"title":"([^"]+)"/)[1]
const desc = msg.message[0].data.match(/"desc":"([^"]+)"/)[1]
if (id === "") return
let path = this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.flac'
let path = this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.' + FileSuffix
let tryCount = 0
const tryUpload = async () => {
let formData = new FormData()
@ -537,6 +539,7 @@ export class songRequest extends plugin {
}
// 动态判断后缀名
let musicExt = resp.data.data?.[0]?.type
FileSuffix = musicExt
// 下载音乐
downloadAudio(url, this.getCurDownloadPath(e), title, 'follow', musicExt).then(async path => {
try {

View File

@ -107,6 +107,8 @@ import { convertToSeconds, removeParams, ytbFormatTime } from "../utils/youtube.
import { ytDlpGetDuration, ytDlpGetThumbnail, ytDlpGetTilt, ytDlpHelper } from "../utils/yt-dlp-util.js";
import { textArrayToMakeForward, sendMusicCard } from "../utils/yunzai-util.js";
export class tools extends plugin {
/**
* 用于计数applemusic达到一定数量清理文件