Merge pull request #51 from nikoyoke1/master

🐞 fix: 修复在文件拓展名为mp3无法上传的问题
This commit is contained in:
Zhiyu 2024-11-12 15:51:59 +08:00 committed by GitHub
commit 8f156e74c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 2 deletions

View File

@ -13,6 +13,8 @@ import { sendMusicCard } from "../utils/yunzai-util.js";
import config from "../model/config.js"; import config from "../model/config.js";
import FormData from 'form-data'; import FormData from 'form-data';
let FileSuffix = 'flac'
export class songRequest extends plugin { export class songRequest extends plugin {
constructor() { constructor() {
super({ super({
@ -282,7 +284,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 path = this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.flac' let path = this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.' + FileSuffix
try { try {
// 上传群文件 // 上传群文件
await this.uploadGroupFile(e, path); await this.uploadGroupFile(e, path);
@ -308,7 +310,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 path = this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.flac' let path = this.getCurDownloadPath(e) + '/' + title + '-' + desc + '.' + FileSuffix
let tryCount = 0 let tryCount = 0
const tryUpload = async () => { const tryUpload = async () => {
let formData = new FormData() let formData = new FormData()
@ -537,6 +539,7 @@ export class songRequest extends plugin {
} }
// 动态判断后缀名 // 动态判断后缀名
let musicExt = resp.data.data?.[0]?.type let musicExt = resp.data.data?.[0]?.type
FileSuffix = musicExt
// 下载音乐 // 下载音乐
downloadAudio(url, this.getCurDownloadPath(e), title, 'follow', musicExt).then(async path => { downloadAudio(url, this.getCurDownloadPath(e), title, 'follow', musicExt).then(async path => {
try { 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 { ytDlpGetDuration, ytDlpGetThumbnail, ytDlpGetTilt, ytDlpHelper } from "../utils/yt-dlp-util.js";
import { textArrayToMakeForward, sendMusicCard } from "../utils/yunzai-util.js"; import { textArrayToMakeForward, sendMusicCard } from "../utils/yunzai-util.js";
export class tools extends plugin { export class tools extends plugin {
/** /**
* 用于计数applemusic达到一定数量清理文件 * 用于计数applemusic达到一定数量清理文件

View File

@ -65,6 +65,7 @@ html {
width: 70px; width: 70px;
font-size: 25px; font-size: 25px;
height: 100%; height: 100%;
align-content: center;
text-align: center; text-align: center;
} }
.cloudBox{ .cloudBox{