mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00

- 在 guoba.support.js 中添加了哔哩哔哩封面、信息、简介和在线人数显示选项 - 在 config/version.yaml 中更新版本至 1.8.1 并添加自定义识别功能,修正油管分辨率问题,新增小飞机解析 Beta 功能 - 在 config/tools.yaml 中添加哔哩哔哩显示选项配置 - 在 apps/tools.js 中实现哔哩哔哩信息动态构建,优化视频信息获取逻辑 - 优化 yt-dlp-util.js 中的命令行参数构建,添加视频质量限制选项
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
import { exec, execSync } from "child_process";
|
|
|
|
/**
|
|
* 构建梯子参数
|
|
* @param isOversea
|
|
* @param proxy
|
|
* @returns {string|string}
|
|
*/
|
|
function constructProxyParam(isOversea, proxy) {
|
|
return isOversea ? "" : `--proxy ${proxy}`;
|
|
}
|
|
|
|
/**
|
|
* 获取标题
|
|
* @param url
|
|
* @param isOversea
|
|
* @param proxy
|
|
* @returns string
|
|
*/
|
|
export function ytDlpGetTilt(url, isOversea, proxy) {
|
|
return execSync(`yt-dlp --get-title ${constructProxyParam(isOversea, proxy)} ${url}`);
|
|
}
|
|
|
|
/**
|
|
* yt-dlp 工具类
|
|
* @returns {Promise<void>}
|
|
* @param path 下载路径
|
|
* @param url 下载链接
|
|
* @param isOversea 是否是海外用户
|
|
* @param proxy 代理地址
|
|
* @param merge 是否合并输出为 mp4 格式 (仅适用于视频合并需求)
|
|
*/
|
|
export async function ytDlpHelper(path, url, isOversea, proxy, merge = false) {
|
|
return new Promise((resolve, reject) => {
|
|
const mergeOption = merge ? '--merge-output-format "mp4"' : '';
|
|
// 添加 -f 参数来限制视频质量
|
|
const qualityOption = '-f "bestvideo[height<=720]+bestaudio/best[height<=720]"';
|
|
const command = `yt-dlp ${constructProxyParam(isOversea, proxy)} -P ${path} -o "temp.%(ext)s" ${mergeOption} ${qualityOption} ${url}`;
|
|
|
|
exec(command, (error, stdout) => {
|
|
if (error) {
|
|
console.error(`Error executing command: ${error}`);
|
|
reject(error);
|
|
} else {
|
|
console.log(`Command output: ${stdout}`);
|
|
resolve(stdout);
|
|
}
|
|
});
|
|
});
|
|
}
|