mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🐞 fix: 修复netease无法解析歌曲问题
This commit is contained in:
parent
a9a1faba83
commit
94b30c66f1
@ -34,7 +34,7 @@ import {
|
||||
} from "../constants/constant.js";
|
||||
import {
|
||||
downloadImg,
|
||||
downloadMp3, estimateReadingTime,
|
||||
downloadAudio, estimateReadingTime,
|
||||
formatBiliInfo,
|
||||
getIdVideo, retryAxiosReq,
|
||||
secondsToTime,
|
||||
@ -1026,8 +1026,11 @@ export class tools extends plugin {
|
||||
// 不是VIP歌曲,直接识别完就下一步
|
||||
e.reply(`识别:网易云音乐,${ title }`);
|
||||
}
|
||||
// 动态判断后缀名
|
||||
const extensionPattern = /\.([a-zA-Z0-9]+)$/;
|
||||
const musicExt = url.match(extensionPattern);
|
||||
// 下载音乐
|
||||
downloadMp3(url, this.getCurDownloadPath(e), title, 'follow').then(async path => {
|
||||
downloadAudio(url, this.getCurDownloadPath(e), title, 'follow', musicExt).then(async path => {
|
||||
// 发送语音
|
||||
// e.reply(segment.record(path));
|
||||
// 判断是不是icqq
|
||||
@ -1490,7 +1493,7 @@ export class tools extends plugin {
|
||||
});
|
||||
const url = vipMusicData.data.mp3;
|
||||
// 下载音乐
|
||||
downloadMp3(url, this.getCurDownloadPath(e), title, 'follow').then(async path => {
|
||||
downloadAudio(url, this.getCurDownloadPath(e), title, 'follow').then(async path => {
|
||||
// 发送语音
|
||||
// e.reply(segment.record(path));
|
||||
// 判断是不是icqq
|
||||
|
@ -128,14 +128,15 @@ export function generateRandomStr(randomlength = 16) {
|
||||
* @param path 下载目录
|
||||
* @param title 音乐名
|
||||
* @param redirect 是否要重定向
|
||||
* @param audioType 建议填写 mp3 / m4a / flac 类型
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
export async function downloadMp3(mp3Url, path, title = "temp", redirect = "manual") {
|
||||
export async function downloadAudio(mp3Url, path, title = "temp", redirect = "manual", audioType = "mp3") {
|
||||
// 如果没有目录就创建一个
|
||||
await mkdirIfNotExists(path)
|
||||
|
||||
// 补充保存文件名
|
||||
path += `/${ title }.mp3`;
|
||||
path += `/${ title }.${audioType}`;
|
||||
if (fs.existsSync(path)) {
|
||||
console.log(`音频已存在`);
|
||||
fs.unlinkSync(path);
|
||||
|
Loading…
x
Reference in New Issue
Block a user