mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00
✨ feat: 添加网易云云盘功能
This commit is contained in:
parent
ea8b6a8d0b
commit
1026ccc475
@ -12,6 +12,8 @@ import {
|
||||
getSong,
|
||||
getSongDetail,
|
||||
getUserRecord,
|
||||
getCloud,
|
||||
getCloudMusicDetail
|
||||
} from "../utils/netease.js";
|
||||
import { ha12store, store2ha1 } from "../utils/encrypt.js";
|
||||
import { downloadMp3 } from "../utils/common.js";
|
||||
@ -43,6 +45,10 @@ export class neteasepro extends plugin {
|
||||
reg: "^#网易云听歌排行$",
|
||||
fnc: "neteaseListenRank",
|
||||
},
|
||||
{
|
||||
reg: "^#网易云云盘$",
|
||||
fnc: "neteaseCloud",
|
||||
},
|
||||
{
|
||||
reg: "music.163.com",
|
||||
fnc: "netease",
|
||||
@ -141,6 +147,31 @@ export class neteasepro extends plugin {
|
||||
await e.reply(await this.musicForwardPack(forwardMsg));
|
||||
}
|
||||
|
||||
async neteaseCloud(e) {
|
||||
const userInfo = await this.aopBefore(e);
|
||||
const realCookie = userInfo.cookie;
|
||||
if (realCookie === "") {
|
||||
return true;
|
||||
}
|
||||
const cloudMusics = (await getCloud(realCookie)).map(async item => {
|
||||
let music = await getSong(item.songId, realCookie)
|
||||
let finalMusic;
|
||||
if (music instanceof Array) {
|
||||
music = music[0];
|
||||
finalMusic = await this.cloudMusicPack(item, music.url);
|
||||
} else {
|
||||
finalMusic = await this.musicPack(music);
|
||||
}
|
||||
return {
|
||||
message: segment.json(finalMusic),
|
||||
nickname: e.sender.card || e.user_id,
|
||||
user_id: e.user_id,
|
||||
}
|
||||
})
|
||||
let forwardMsg = await Bot.makeForwardMsg(await Promise.all(cloudMusics));
|
||||
await e.reply(await this.musicForwardPack(forwardMsg));
|
||||
}
|
||||
|
||||
async netease(e) {
|
||||
const message =
|
||||
e.msg === undefined ? e.message.shift().data.replaceAll("\\", "") : e.msg.trim();
|
||||
@ -287,6 +318,36 @@ export class neteasepro extends plugin {
|
||||
});
|
||||
}
|
||||
|
||||
async cloudMusicPack(item, url) {
|
||||
return {
|
||||
app: "com.tencent.structmsg",
|
||||
desc: "音乐",
|
||||
view: "music",
|
||||
ver: "0.0.0.1",
|
||||
prompt: "[分享]" + item.songName + "-" + item.album,
|
||||
meta: {
|
||||
music: {
|
||||
app_type: 1,
|
||||
appid: 100495085,
|
||||
desc: item.artist,
|
||||
jumpUrl: `https://y.music.163.com/m/song?id=${item.songId}`,
|
||||
musicUrl: url,
|
||||
preview: "https://i.gtimg.cn/open/app_icon/00/49/50/85/100495085_100_m.png",
|
||||
sourceMsgId: "0",
|
||||
source_icon: "https://i.gtimg.cn/open/app_icon/00/49/50/85/100495085_100_m.png",
|
||||
source_url: "",
|
||||
tag: "网易云音乐",
|
||||
title: item.fileName,
|
||||
},
|
||||
},
|
||||
config: {
|
||||
type: "normal",
|
||||
forward: true,
|
||||
ctime: Date.now(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// 包装分享小程序数据
|
||||
async musicPack(song) {
|
||||
const title = song.name;
|
||||
|
@ -2,7 +2,7 @@
|
||||
import fetch from "node-fetch";
|
||||
import axios from "axios";
|
||||
|
||||
const BASE_URL = "http://cloud-music.pl-fe.cn";
|
||||
const BASE_URL = "http://127.0.0.1:3000";
|
||||
|
||||
/**
|
||||
* 获取cookie
|
||||
@ -124,6 +124,30 @@ async function getSongDetail(ids) {
|
||||
});
|
||||
}
|
||||
|
||||
async function getCloud(cookie) {
|
||||
return axios({
|
||||
url: `${BASE_URL}/user/cloud?timestamp=${Date.now()}`,
|
||||
method: "get",
|
||||
data: {
|
||||
cookie,
|
||||
},
|
||||
}).then(resp => {
|
||||
return resp.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
async function getCloudMusicDetail(id, cookie) {
|
||||
return axios({
|
||||
url: `${BASE_URL}/user/cloud/detail?id=${id}×tamp=${Date.now()}`,
|
||||
method: "get",
|
||||
data: {
|
||||
cookie,
|
||||
},
|
||||
}).then(resp => {
|
||||
return resp.data;
|
||||
});
|
||||
}
|
||||
|
||||
export {
|
||||
getCookies,
|
||||
getLoginStatus,
|
||||
@ -133,5 +157,7 @@ export {
|
||||
getUserRecord,
|
||||
checkMusic,
|
||||
getSong,
|
||||
getSongDetail
|
||||
getSongDetail,
|
||||
getCloud,
|
||||
getCloudMusicDetail
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user