mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
✨ feat: 添加上传飞机
劫持下载
This commit is contained in:
parent
3bf7329299
commit
7f318779ea
@ -90,7 +90,7 @@ import { contentEstimator } from "../utils/link-share-summary-util.js";
|
|||||||
import { getDS } from "../utils/mihoyo.js";
|
import { getDS } from "../utils/mihoyo.js";
|
||||||
import { OpenaiBuilder } from "../utils/openai-builder.js";
|
import { OpenaiBuilder } from "../utils/openai-builder.js";
|
||||||
import { redisExistKey, redisGetKey, redisSetKey } from "../utils/redis-util.js";
|
import { redisExistKey, redisGetKey, redisSetKey } from "../utils/redis-util.js";
|
||||||
import { saveTDL, startTDL } from "../utils/tdl-util.js";
|
import { saveTDL, startTDL, uploadTDL } from "../utils/tdl-util.js";
|
||||||
import Translate from "../utils/trans-strategy.js";
|
import Translate from "../utils/trans-strategy.js";
|
||||||
import { mid2id } from "../utils/weibo.js";
|
import { mid2id } from "../utils/weibo.js";
|
||||||
import { ytDlpGetTilt, ytDlpHelper } from "../utils/yt-dlp-util.js";
|
import { ytDlpGetTilt, ytDlpHelper } from "../utils/yt-dlp-util.js";
|
||||||
@ -2409,6 +2409,14 @@ export class tools extends plugin {
|
|||||||
}
|
}
|
||||||
const stats = fs.statSync(path);
|
const stats = fs.statSync(path);
|
||||||
const videoSize = Math.floor(stats.size / (1024 * 1024));
|
const videoSize = Math.floor(stats.size / (1024 * 1024));
|
||||||
|
// 顺便发送一份到小飞机
|
||||||
|
if (e.msg.startsWith("上传飞机")) {
|
||||||
|
this.queue.add(async () => {
|
||||||
|
await uploadTDL(path, this.isOverseasServer(), this.proxyAddr);
|
||||||
|
e.reply("✈️ 已发送一份到您的小飞机收藏夹了!");
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 正常发送视频
|
||||||
if (videoSize > videoSizeLimit) {
|
if (videoSize > videoSizeLimit) {
|
||||||
e.reply(`当前视频大小:${ videoSize }MB,\n大于设置的最大限制:${ videoSizeLimit }MB,\n改为上传群文件`);
|
e.reply(`当前视频大小:${ videoSize }MB,\n大于设置的最大限制:${ videoSizeLimit }MB,\n改为上传群文件`);
|
||||||
await this.uploadGroupFile(e, path);
|
await this.uploadGroupFile(e, path);
|
||||||
|
@ -31,20 +31,50 @@ export async function startTDL(url, curPath, isOversea, proxyAddr, videoDownload
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function saveTDL(urk, isOversea, proxyAddr) {
|
/**
|
||||||
|
* 保存小飞机内容到小飞机的收藏
|
||||||
|
* @param url
|
||||||
|
* @param isOversea
|
||||||
|
* @param proxyAddr
|
||||||
|
* @returns {Promise<unknown>}
|
||||||
|
*/
|
||||||
|
export async function saveTDL(url, isOversea, proxyAddr) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const proxyStr = isOversea ? `` : `--proxy ${ proxyAddr }`;
|
const proxyStr = isOversea ? `` : `--proxy ${ proxyAddr }`;
|
||||||
const command = `tdl forward --from ${urk} ${proxyStr}`
|
const command = `tdl forward --from ${url} ${proxyStr}`
|
||||||
exec(command, (error, stdout, stderr) => {
|
exec(command, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
reject(`[R插件][TDL]执行出错: ${error.message}`);
|
reject(`[R插件][TDL保存]执行出错: ${error.message}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
reject(`[R插件][TDL]错误信息: ${stderr}`);
|
reject(`[R插件][TDL保存]错误信息: ${stderr}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resolve(stdout);
|
resolve(stdout);
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件到飞机收藏夹
|
||||||
|
* @param filePath
|
||||||
|
* @param isOversea
|
||||||
|
* @param proxyAddr
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
export async function uploadTDL(filePath, isOversea, proxyAddr) {
|
||||||
|
const proxyStr = isOversea ? `` : `--proxy ${ proxyAddr }`;
|
||||||
|
const command = `tdl up -p ${ filePath } ${ proxyStr }`;
|
||||||
|
exec(command, (error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
reject(`[R插件][TDL上传]执行出错: ${error.message}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (stderr) {
|
||||||
|
reject(`[R插件][TDL上传]错误信息: ${stderr}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve(stdout);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user