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
74486e51e3
commit
a3687141c0
@ -154,28 +154,36 @@ export class neteasepro extends plugin {
|
|||||||
musicUrlReg2.exec(message)[3] ||
|
musicUrlReg2.exec(message)[3] ||
|
||||||
musicUrlReg.exec(message)[2] ||
|
musicUrlReg.exec(message)[2] ||
|
||||||
/id=(\d+)/.exec(message)[1];
|
/id=(\d+)/.exec(message)[1];
|
||||||
const isMessageJson = await this.isJSON(message);
|
// 是游客
|
||||||
// 如果是小程序 & 是游客
|
if (!(await redis.get(await this.getRedisKey(e.user_id)))) {
|
||||||
if (isMessageJson && !(await redis.get(await this.getRedisKey(e.user_id)))) {
|
// 是小程序
|
||||||
const musicJson = JSON.parse(message);
|
if (await this.isJSON(message)) {
|
||||||
const { preview, title, desc } = musicJson.meta.music || musicJson.meta.news;
|
const musicJson = JSON.parse(message);
|
||||||
// console.log(musicUrl, preview, title, desc);
|
const { preview, title, desc } = musicJson.meta.music || musicJson.meta.news;
|
||||||
// 如果没有登陆,就使用官方接口
|
// console.log(musicUrl, preview, title, desc);
|
||||||
e.reply([`识别:网易云音乐,${title}--${desc}`, segment.image(preview)]);
|
// 如果没有登陆,就使用官方接口
|
||||||
if (!(await redis.exists(await this.getRedisKey(e.user_id)))) {
|
e.reply([`识别:网易云音乐,${title}--${desc}`, segment.image(preview)]);
|
||||||
this.downloadMp3(`music.163.com/song/media/outer/url?id=${id}`, "follow")
|
} else {
|
||||||
.then(path => {
|
// 非小程序
|
||||||
Bot.acquireGfs(e.group_id).upload(
|
const title = await getSongDetail(id).then(res => {
|
||||||
fs.readFileSync(path),
|
const song = res.songs[0];
|
||||||
"/",
|
return `${song?.name}-${song?.ar?.[0].name}`.replace(/[\/\?<>\\:\*\|".… ]/g, "");
|
||||||
`${title.replace(/[\/\?<>\\:\*\|".… ]/g, "")}.mp3`,
|
});
|
||||||
);
|
e.reply(`识别:网易云音乐,${title}`);
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.error(`下载音乐失败,错误信息为: ${err.message}`);
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
// 下载游客歌曲
|
||||||
|
this.downloadMp3(`https://music.163.com/song/media/outer/url?id=${id}`, "follow")
|
||||||
|
.then(path => {
|
||||||
|
Bot.acquireGfs(e.group_id).upload(
|
||||||
|
fs.readFileSync(path),
|
||||||
|
"/",
|
||||||
|
`${id}.mp3`,
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(`下载音乐失败,错误信息为: ${err.message}`);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
// 检查当前歌曲是否可用
|
// 检查当前歌曲是否可用
|
||||||
const checkOne = await checkMusic(id);
|
const checkOne = await checkMusic(id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user