mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🌈 style: 代码格式化
This commit is contained in:
parent
2a917f20f9
commit
a0216dae4f
@ -8,7 +8,7 @@ import _ from "lodash";
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
// 常量
|
// 常量
|
||||||
import {CAT_LIMIT} from "../utils/constant.js";
|
import { CAT_LIMIT } from "../utils/constant.js";
|
||||||
|
|
||||||
export class query extends plugin {
|
export class query extends plugin {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -425,7 +425,7 @@ export class query extends plugin {
|
|||||||
headers: {
|
headers: {
|
||||||
"user-agent":
|
"user-agent":
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1660.14",
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1660.14",
|
||||||
"referer": "https://search.zhelper.net/"
|
referer: "https://search.zhelper.net/",
|
||||||
},
|
},
|
||||||
keyword: keyword,
|
keyword: keyword,
|
||||||
page: 1,
|
page: 1,
|
||||||
@ -456,9 +456,9 @@ export class query extends plugin {
|
|||||||
`书籍类型:${extension}\n` +
|
`书籍类型:${extension}\n` +
|
||||||
`出版年月:${year}\n` +
|
`出版年月:${year}\n` +
|
||||||
`来源:${source}\n` +
|
`来源:${source}\n` +
|
||||||
`ISBN:${isbn||"暂无"}\n` +
|
`ISBN:${isbn || "暂无"}\n` +
|
||||||
`出版社:${publisher}\n` +
|
`出版社:${publisher}\n` +
|
||||||
`文件大小:${(Number(filesize)/1024/1024).toFixed(2)}MB`
|
`文件大小:${(Number(filesize) / 1024 / 1024).toFixed(2)}MB`,
|
||||||
},
|
},
|
||||||
...sendTemplate,
|
...sendTemplate,
|
||||||
});
|
});
|
||||||
@ -492,22 +492,25 @@ export class query extends plugin {
|
|||||||
*/
|
*/
|
||||||
async getDirectDownload(keyword) {
|
async getDirectDownload(keyword) {
|
||||||
// 下载字典(异步去执行)
|
// 下载字典(异步去执行)
|
||||||
return axios
|
return axios
|
||||||
.post("https://worker.zlib.app/api/search/", {
|
.post("https://worker.zlib.app/api/search/", {
|
||||||
headers: {
|
headers: {
|
||||||
"user-agent":
|
"user-agent":
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1660.14",
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1660.14",
|
||||||
"referer": "https://search.zhelper.net/"
|
referer: "https://search.zhelper.net/",
|
||||||
},
|
},
|
||||||
keyword: keyword,
|
keyword: keyword,
|
||||||
page: 1,
|
page: 1,
|
||||||
sensitive: false,
|
sensitive: false,
|
||||||
}).then(resp => {
|
|
||||||
// 标题去重
|
|
||||||
return resp.data.data.filter(item => {
|
|
||||||
return item.title === keyword
|
|
||||||
}).map(item => `https://worker.zlib.app/download/${item.id}`)
|
|
||||||
})
|
})
|
||||||
|
.then(resp => {
|
||||||
|
// 标题去重
|
||||||
|
return resp.data.data
|
||||||
|
.filter(item => {
|
||||||
|
return item.title === keyword;
|
||||||
|
})
|
||||||
|
.map(item => `https://worker.zlib.app/download/${item.id}`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -568,8 +571,12 @@ export class query extends plugin {
|
|||||||
year,
|
year,
|
||||||
} = resp.data;
|
} = resp.data;
|
||||||
const Libgen = `https://libgendown.1kbtool.com/${md5}`;
|
const Libgen = `https://libgendown.1kbtool.com/${md5}`;
|
||||||
const ipfs = `https://ipfs-checker.1kbtool.com/${ipfs_cid}?filename=${encodeURIComponent(title)}_${source}-search.${extension}`;
|
const ipfs = `https://ipfs-checker.1kbtool.com/${ipfs_cid}?filename=${encodeURIComponent(
|
||||||
const reqUrl = `${md5}#${filesize}#${encodeURIComponent(title)}_${encodeURIComponent(author)}_${id}_${source}-search.${extension}`;
|
title,
|
||||||
|
)}_${source}-search.${extension}`;
|
||||||
|
const reqUrl = `${md5}#${filesize}#${encodeURIComponent(
|
||||||
|
title,
|
||||||
|
)}_${encodeURIComponent(author)}_${id}_${source}-search.${extension}`;
|
||||||
const cleverPass = `https://rapidupload.1kbtool.com/${reqUrl}`;
|
const cleverPass = `https://rapidupload.1kbtool.com/${reqUrl}`;
|
||||||
const cleverPass2 = `https://rulite.1kbtool.com/${reqUrl}`;
|
const cleverPass2 = `https://rulite.1kbtool.com/${reqUrl}`;
|
||||||
let bookMethods = [
|
let bookMethods = [
|
||||||
@ -579,12 +586,12 @@ export class query extends plugin {
|
|||||||
`秒传Lite:${cleverPass2}`,
|
`秒传Lite:${cleverPass2}`,
|
||||||
].map(item => {
|
].map(item => {
|
||||||
return {
|
return {
|
||||||
message: {type: "text", text: item},
|
message: { type: "text", text: item },
|
||||||
nickname: this.e.sender.card || this.e.user_id,
|
nickname: this.e.sender.card || this.e.user_id,
|
||||||
user_id: this.e.user_id,
|
user_id: this.e.user_id,
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
await this.reply(await Bot.makeForwardMsg(bookMethods))
|
await this.reply(await Bot.makeForwardMsg(bookMethods));
|
||||||
// 异步获取直连
|
// 异步获取直连
|
||||||
console.log(source);
|
console.log(source);
|
||||||
console.log(source === Buffer.from("ei1saWJyYXJ5", "base64").toString("utf8"));
|
console.log(source === Buffer.from("ei1saWJyYXJ5", "base64").toString("utf8"));
|
||||||
@ -592,15 +599,15 @@ export class query extends plugin {
|
|||||||
this.getDirectDownload(title).then(async res => {
|
this.getDirectDownload(title).then(async res => {
|
||||||
const directDownloadUrls = res.map(item => {
|
const directDownloadUrls = res.map(item => {
|
||||||
return {
|
return {
|
||||||
message: {type: "text", text: item},
|
message: { type: "text", text: item },
|
||||||
nickname: this.e.sender.card || this.e.user_id,
|
nickname: this.e.sender.card || this.e.user_id,
|
||||||
user_id: this.e.user_id,
|
user_id: this.e.user_id,
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
if (directDownloadUrls.length) {
|
if (directDownloadUrls.length) {
|
||||||
await this.reply(await Bot.makeForwardMsg(directDownloadUrls))
|
await this.reply(await Bot.makeForwardMsg(directDownloadUrls));
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -610,4 +617,4 @@ export class query extends plugin {
|
|||||||
const titleRex = /<[^>]+>/g;
|
const titleRex = /<[^>]+>/g;
|
||||||
return title.replace(titleRex, "");
|
return title.replace(titleRex, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -641,15 +641,16 @@ export class tools extends plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async netease(e) {
|
async netease(e) {
|
||||||
const message = e.msg === undefined ? e.message.shift().data.replaceAll("\\", "") : e.msg.trim();
|
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 musicUrlReg = /(http:|https:)\/\/music.163.com\/song\/media\/outer\/url\?id=(\d+)/;
|
||||||
const id = musicUrlReg.exec(message)[2] || /id=(\d+)/.exec(message)[1];
|
const id = musicUrlReg.exec(message)[2] || /id=(\d+)/.exec(message)[1];
|
||||||
const musicJson = JSON.parse(message)
|
const musicJson = JSON.parse(message);
|
||||||
const {musicUrl, preview, title, desc} = musicJson.meta.music
|
const { musicUrl, preview, title, desc } = musicJson.meta.music;
|
||||||
// 如果没有下载地址跳出if
|
// 如果没有下载地址跳出if
|
||||||
if (_.isNull(musicUrl) || _.isUndefined(musicUrl)) {
|
if (_.isNull(musicUrl) || _.isUndefined(musicUrl)) {
|
||||||
e.reply(`识别:网易云音乐,解析失败!`);
|
e.reply(`识别:网易云音乐,解析失败!`);
|
||||||
return
|
return;
|
||||||
} else {
|
} else {
|
||||||
fetch(`https://www.oranges1.top/neteaseapi.do/song/url?id=${id}`, {
|
fetch(`https://www.oranges1.top/neteaseapi.do/song/url?id=${id}`, {
|
||||||
headers: {
|
headers: {
|
||||||
@ -657,16 +658,21 @@ export class tools extends plugin {
|
|||||||
"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",
|
"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",
|
||||||
},
|
},
|
||||||
}).then(async resp => {
|
}).then(async resp => {
|
||||||
const url = await JSON.parse(await resp.text()).data[0].url
|
const url = await JSON.parse(await resp.text()).data[0].url;
|
||||||
// 反之解析官方地址
|
// 反之解析官方地址
|
||||||
e.reply([`识别:网易云音乐,${title}--${desc}`, segment.image(preview)]);
|
e.reply([`识别:网易云音乐,${title}--${desc}`, segment.image(preview)]);
|
||||||
this.downloadMp3(url, 'follow').then(path => {
|
this.downloadMp3(url, "follow")
|
||||||
Bot.acquireGfs(e.group_id).upload(fs.readFileSync(path), '/', `${title.replace(/[\/\?<>\\:\*\|".… ]/g, '')}.mp3`)
|
.then(path => {
|
||||||
})
|
Bot.acquireGfs(e.group_id).upload(
|
||||||
|
fs.readFileSync(path),
|
||||||
|
"/",
|
||||||
|
`${title.replace(/[\/\?<>\\:\*\|".… ]/g, "")}.mp3`,
|
||||||
|
);
|
||||||
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error(`下载音乐失败,错误信息为: ${err.message}`);
|
console.error(`下载音乐失败,错误信息为: ${err.message}`);
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -835,31 +841,30 @@ export class tools extends plugin {
|
|||||||
* @param redirect
|
* @param redirect
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
async downloadMp3(mp3Url, redirect='manual') {
|
async downloadMp3(mp3Url, redirect = "manual") {
|
||||||
return fetch(mp3Url, {
|
return fetch(mp3Url, {
|
||||||
headers: {
|
headers: {
|
||||||
"User-Agent":
|
"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",
|
"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",
|
responseType: "stream",
|
||||||
redirect: redirect
|
redirect: redirect,
|
||||||
})
|
}).then(res => {
|
||||||
.then(res => {
|
const path = `${this.defaultPath}${this.e.group_id || this.e.user_id}/temp.mp3`;
|
||||||
const path = `${this.defaultPath}${this.e.group_id || this.e.user_id}/temp.mp3`
|
const fileStream = fs.createWriteStream(path);
|
||||||
const fileStream = fs.createWriteStream(path);
|
res.body.pipe(fileStream);
|
||||||
res.body.pipe(fileStream);
|
return new Promise((resolve, reject) => {
|
||||||
return new Promise((resolve, reject) => {
|
fileStream.on("finish", () => {
|
||||||
fileStream.on("finish", () => {
|
fileStream.close(() => {
|
||||||
fileStream.close(() => {
|
resolve(path);
|
||||||
resolve(path);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
fileStream.on("error", err => {
|
|
||||||
fs.unlink(path, () => {
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
fileStream.on("error", err => {
|
||||||
|
fs.unlink(path, () => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user