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
6e4a175d3a
commit
b76a452404
@ -206,19 +206,11 @@ export class query extends plugin {
|
||||
|
||||
async hotSearch(e) {
|
||||
let keyword = e.msg.replace(/#|热搜/g, "").trim();
|
||||
console.log(keyword);
|
||||
// 虎扑/知乎/36氪/百度/哔哩哔哩/贴吧/微博/抖音/豆瓣/少数派/IT资讯/微信
|
||||
let url = "https://api.vvhan.com/api/hotlist?type=";
|
||||
switch (keyword) {
|
||||
case "虎扑":
|
||||
url += "huPu";
|
||||
break;
|
||||
case "知乎":
|
||||
url += "zhihuHot";
|
||||
break;
|
||||
case "36氪":
|
||||
url += "36Ke";
|
||||
break;
|
||||
case "百度":
|
||||
url += "baiduRD";
|
||||
break;
|
||||
@ -234,20 +226,8 @@ export class query extends plugin {
|
||||
case "抖音":
|
||||
url += "douyinHot";
|
||||
break;
|
||||
case "豆瓣":
|
||||
url += "douban";
|
||||
break;
|
||||
case "少数派":
|
||||
url += "ssPai";
|
||||
break;
|
||||
case "IT资讯":
|
||||
url += "itInfo";
|
||||
break;
|
||||
case "微信":
|
||||
url += "wxHot";
|
||||
break;
|
||||
default:
|
||||
url += "history";
|
||||
url += "bili";
|
||||
break;
|
||||
}
|
||||
let sendTemplate = {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// 主库
|
||||
import fetch from "node-fetch";
|
||||
import fs from "node:fs";
|
||||
import { segment } from "oicq";
|
||||
import { Gfs, segment } from "oicq";
|
||||
// 其他库
|
||||
import md5 from "md5";
|
||||
import axios from "axios";
|
||||
@ -15,6 +15,7 @@ import { parseUrl, parseM3u8, downloadM3u8Videos, mergeAcFileToMp4 } from "../ut
|
||||
import { transMap, douyinTypeMap, TEN_THOUSAND } from "../utils/constant.js";
|
||||
import { getIdVideo } from "../utils/common.js";
|
||||
import config from "../model/index.js";
|
||||
import { resolve } from "patch-package/dist/path.js";
|
||||
|
||||
export class tools extends plugin {
|
||||
constructor() {
|
||||
@ -49,8 +50,8 @@ export class tools extends plugin {
|
||||
fnc: "twitter",
|
||||
},
|
||||
{
|
||||
reg: "https://(m.)?v.qq.com/(.*)",
|
||||
fnc: "tx",
|
||||
reg: "music.163.com",
|
||||
fnc: "netease",
|
||||
},
|
||||
{
|
||||
reg: "(acfun.cn)",
|
||||
@ -68,7 +69,7 @@ export class tools extends plugin {
|
||||
reg: "^#清理data垃圾$",
|
||||
fnc: "clearTrash",
|
||||
permission: "master",
|
||||
}
|
||||
},
|
||||
],
|
||||
});
|
||||
// http://api.tuwei.space/girl
|
||||
@ -623,7 +624,7 @@ export class tools extends plugin {
|
||||
|
||||
// 清理垃圾文件
|
||||
async clearTrash(e) {
|
||||
const directory = './data/';
|
||||
const directory = "./data/";
|
||||
try {
|
||||
fs.readdir(directory, (err, files) => {
|
||||
for (const file of files) {
|
||||
@ -636,10 +637,63 @@ export class tools extends plugin {
|
||||
await e.reply(`清理完成!`);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
e.reply("清理失败,重试或者自动清理即可")
|
||||
e.reply("清理失败,重试或者自动清理即可");
|
||||
}
|
||||
}
|
||||
|
||||
async netease(e) {
|
||||
const message = e.msg === undefined ? e.message.shift().data.replaceAll("\\", "") : e.msg.trim();
|
||||
const musicUrlReg = /(http:|https:)\/\/music.163.com\/song\/media\/outer\/url\?id=(\d+)/;
|
||||
const realMusicUrl = musicUrlReg.exec(message)[0];
|
||||
const id = musicUrlReg.exec(message)[2];
|
||||
console.log(id);
|
||||
fetch(`https://api.vvhan.com/api/music?id=${id}&type=song&media=netease`, {
|
||||
headers: {
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Mobile Safari/537.36",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then(resp => resp.json())
|
||||
.then(resp => {
|
||||
console.log(resp);
|
||||
const { name, author, mp3url, cover } = resp;
|
||||
e.reply([`识别:网易云音乐,${name}--${author}`, segment.image(cover)]);
|
||||
console.log(mp3url);
|
||||
fetch(mp3url, {
|
||||
headers: {
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Mobile Safari/537.36",
|
||||
},
|
||||
responseType: "stream",
|
||||
redirect: 'manual'
|
||||
})
|
||||
.then(res => {
|
||||
const path = `${this.defaultPath}${this.e.group_id || this.e.user_id}/temp.mp3`
|
||||
const fileStream = fs.createWriteStream(path);
|
||||
res.body.pipe(fileStream);
|
||||
return new Promise((resolve, reject) => {
|
||||
fileStream.on("finish", () => {
|
||||
fileStream.close(() => {
|
||||
resolve(path);
|
||||
});
|
||||
});
|
||||
fileStream.on("error", err => {
|
||||
fs.unlink(path, () => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
}).then(path => {
|
||||
Bot.acquireGfs(e.group_id).upload(fs.readFileSync(path), '/', `${name}.mp3`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(`Error downloading file: ${err.message}`);
|
||||
});
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 哔哩哔哩下载
|
||||
* @param title
|
||||
|
@ -53,6 +53,9 @@
|
||||
- icon: literature
|
||||
title: "论文"
|
||||
desc: SCI论文实时解析
|
||||
- icon: netease
|
||||
title: "网易云音乐",
|
||||
desc: 网易云音乐解析
|
||||
- group: 其他指令
|
||||
list:
|
||||
- icon: update
|
||||
|
BIN
resources/img/icon/netease.png
Normal file
BIN
resources/img/icon/netease.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
Loading…
x
Reference in New Issue
Block a user