diff --git a/apps/tools.js b/apps/tools.js index c78dcfe..fbf2abf 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -90,7 +90,7 @@ import { contentEstimator } from "../utils/link-share-summary-util.js"; import { getDS } from "../utils/mihoyo.js"; import { OpenaiBuilder } from "../utils/openai-builder.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 { mid2id } from "../utils/weibo.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 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) { e.reply(`当前视频大小:${ videoSize }MB,\n大于设置的最大限制:${ videoSizeLimit }MB,\n改为上传群文件`); await this.uploadGroupFile(e, path); diff --git a/utils/tdl-util.js b/utils/tdl-util.js index aa02b7d..332d084 100644 --- a/utils/tdl-util.js +++ b/utils/tdl-util.js @@ -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} + */ +export async function saveTDL(url, isOversea, proxyAddr) { return new Promise((resolve, reject) => { const proxyStr = isOversea ? `` : `--proxy ${ proxyAddr }`; - const command = `tdl forward --from ${urk} ${proxyStr}` + const command = `tdl forward --from ${url} ${proxyStr}` exec(command, (error, stdout, stderr) => { if (error) { - reject(`[R插件][TDL]执行出错: ${error.message}`); + reject(`[R插件][TDL保存]执行出错: ${error.message}`); return; } if (stderr) { - reject(`[R插件][TDL]错误信息: ${stderr}`); + reject(`[R插件][TDL保存]错误信息: ${stderr}`); return; } resolve(stdout); }) }) -} \ No newline at end of file +} + +/** + * 上传文件到飞机收藏夹 + * @param filePath + * @param isOversea + * @param proxyAddr + * @returns {Promise} + */ +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); + }) +}