🐞 fix: 修复Windows下解析ytb出现错误[#I9QCR8]

1. 修复Windows下解析ytb出现错误
2. 修复 xhs 文档问题
3. 上传视频增加兜底策略
This commit is contained in:
zhiyu1998 2024-08-08 23:02:11 +08:00
parent b25835c7e5
commit 156e2b5bfc

View File

@ -989,7 +989,7 @@ export class tools extends plugin {
const downloadPath = `${this.getCurDownloadPath(e)}`; const downloadPath = `${this.getCurDownloadPath(e)}`;
// 检测没有 cookie 则退出 // 检测没有 cookie 则退出
if (_.isEmpty(this.xiaohongshuCookie)) { if (_.isEmpty(this.xiaohongshuCookie)) {
e.reply(`2024-8-2后反馈必须使用ck不然无法解析请填写相关ck\n文档:${HELP_DOC}`); e.reply(`2024-8-2后反馈必须使用ck不然无法解析请填写相关ck\n${HELP_DOC}`);
return; return;
} }
// 获取信息 // 获取信息
@ -1325,7 +1325,7 @@ export class tools extends plugin {
*/ */
async dy2b(path, url, isOversea) { async dy2b(path, url, isOversea) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const command = `yt-dlp ${isOversea ? "" : `--proxy ${this.myProxy}`} -P ${path} -o "temp.%(ext)s" -f 'best[height<=720][ext=mp4]' --merge-output-format "mp4" ${url}`; const command = `yt-dlp ${isOversea ? "" : `--proxy ${this.myProxy}`} -P ${path} -o "temp.%(ext)s" --merge-output-format "mp4" ${url}`;
exec(command, (error, stdout) => { exec(command, (error, stdout) => {
if (error) { if (error) {
console.error(`Error executing command: ${error}`); console.error(`Error executing command: ${error}`);
@ -2084,27 +2084,33 @@ export class tools extends plugin {
* @param videoSizeLimit 发送转上传视频的大小限制默认70MB * @param videoSizeLimit 发送转上传视频的大小限制默认70MB
*/ */
async sendVideoToUpload(e, path, videoSizeLimit = this.videoSizeLimit) { async sendVideoToUpload(e, path, videoSizeLimit = this.videoSizeLimit) {
// logger.info(videoSizeLimit); try {
const isLag = await this.isLagRangeDriver(); // logger.info(videoSizeLimit);
// 判断是否是拉格朗日 const isLag = await this.isLagRangeDriver();
if (isLag === 1) { // 判断是否是拉格朗日
// 构造拉格朗日适配器 if (isLag === 1) {
const lagrange = new LagrangeAdapter(this.toolsConfig.lagrangeForwardWebSocket); // 构造拉格朗日适配器
// 上传群文件 const lagrange = new LagrangeAdapter(this.toolsConfig.lagrangeForwardWebSocket);
await lagrange.uploadGroupFile(e.user_id || e.sender.card, e.group_id, path); // 上传群文件
// 上传完直接返回 await lagrange.uploadGroupFile(e.user_id || e.sender.card, e.group_id, path);
return; // 上传完直接返回
} return;
// 判断文件是否存在 }
if (!fs.existsSync(path)) { // 判断文件是否存在
return e.reply('视频不存在'); if (!fs.existsSync(path)) {
} return e.reply('视频不存在');
const stats = fs.statSync(path); }
const videoSize = (stats.size / (1024 * 1024)).toFixed(2); const stats = fs.statSync(path);
if (videoSize > videoSizeLimit) { const videoSize = (stats.size / (1024 * 1024)).toFixed(2);
e.reply(`当前视频大小:${videoSize}MB\n大于设置的最大限制,\n改为上传群文件`); if (videoSize > videoSizeLimit) {
await this.uploadGroupFile(e, path); e.reply(`当前视频大小:${ videoSize }MB\n大于设置的最大限制,\n改为上传群文件`);
} else { await this.uploadGroupFile(e, path);
} else {
e.reply(segment.video(path));
}
} catch (err) {
logger.error(`[R插件][发送视频判断是否需要上传] 发生错误:\n ${err}`);
e.reply(`上传发生错误R插件正在为你采用备用策略请稍等如果发不出来请再次尝试`);
e.reply(segment.video(path)); e.reply(segment.video(path));
} }
} }